TLDR: Insert an image in a JTextArea that will be generated afterwards.
I'm new on using Java, doing my first real project. I am trying to make an application that creates documents based on input variables that represent the keywords in a "template". Basically I created on the left of the GUI a few JTextFields that I print out in the JTextArea with append and then I generate the document.
What I am trying to do atm is to insert an image in that append, image that will be in the generated document.
The code so far for what I specified below.
JTextArea append, where I would like to insert the image:
private void ADDActionPerformed(java.awt.event.ActionEvent evt) {
txtReceipt.append(
"\t\t CONTRACT DETAILS \n\n" +
"LEASE NUMBER:\t\t\t" + txtContract.getText() +
"insert text template here"
);
}
Between the lines of text I would like to add the image. The txtContract variable is a JTextField and the txtReceipt is the JTextArea.
Generate button:
private void GENERATEActionPerformed(java.awt.event.ActionEvent evt) {
try {
txtReceipt.print();
} catch (PrinterException ex) {
Logger.getLogger(GeneratorContracte.class.getName()).log(Level.SEVERE, null, ex);
}
}
I found another threads on this subject but they were adding images in an already created document or generating a doc. The problem is that I didn't figure out what line of the codes does print the image. Also, I don't know if JTextArea supports images.
I am using NetBeans if that matters. Sorry for the wall of text, but I tried to specify the issue without posting the whole code. I believe this way makes it easier to find a solution.
Thanks for your time guys!