How to Print JTable for example in java we got a table and the table contains data. nah such data would in Print. easy, create button / J...
How to Print JTable
for example in java we got a table and the table contains data. nah such data would in Print.
easy, create button / JButton named PRINT under tables or in which was up to you, which is when the button is pressed it will print all the existing data in JTable
then you right-click (Right Click) on the JButton -> Action -> ActionPerformed then enter the following code
try{
MessageFormat header=new MessageFormat("Data");
MessageFormat footer=new MessageFormat ("Page {0,number,integer}");
jTable1.print(JTable.PrintMode.FIT_WIDTH,heade,footer)
}catch(Exception e){
JOptionPane.showMessageDialog(null, "Cannot Print"+e);
}
for example in java we got a table and the table contains data. nah such data would in Print.
easy, create button / JButton named PRINT under tables or in which was up to you, which is when the button is pressed it will print all the existing data in JTable
then you right-click (Right Click) on the JButton -> Action -> ActionPerformed then enter the following code
try{
MessageFormat header=new MessageFormat("Data");
MessageFormat footer=new MessageFormat ("Page {0,number,integer}");
jTable1.print(JTable.PrintMode.FIT_WIDTH,heade,footer)
}catch(Exception e){
JOptionPane.showMessageDialog(null, "Cannot Print"+e);
}