I have a button on my program, to Print the JTable with the Data that is displayed in it (it's filled with data that the user searches from the database). I want to print 2 lines on the header: one with the name of the selected item in the combobox (this is working) and other one with the name of the student (this one is not working). Here is my code:
MessageFormat header = new MessageFormat("Ficha Pedagógica - "+jComboBox1.getSelectedItem());
MessageFormat footer = new MessageFormat("Página {0,number,integer}");
try{
jTable2.print(JTable.PrintMode.NORMAL, header, null);
}
catch(java.awt.print.PrinterException e){
System.out.println("error");
}
When I tried to do this with the header, it didn't break the line, instead, it showed "/nAl..." in front of the first line:
MessageFormat header = new MessageFormat("Ficha Pedagógica - "+jComboBox1.getSelectedItem()+"\nNome do Aluno - "+jTextField1.getText());
Also, when I tried using 2 headers, I couldn't do it because the print function doesn't allow it. So, how can I have 2 header lines?