List of usage examples for javax.swing.table JTableHeader paint
public void paint(Graphics g)
From source file:Main.java
public static BufferedImage createImage(JTable table) { JTableHeader tableHeaderComp = table.getTableHeader(); int totalWidth = tableHeaderComp.getWidth() + table.getWidth(); int totalHeight = tableHeaderComp.getHeight() + table.getHeight(); BufferedImage tableImage = new BufferedImage(totalWidth, totalHeight, BufferedImage.TYPE_INT_RGB); Graphics2D g2D = (Graphics2D) tableImage.getGraphics(); tableHeaderComp.paint(g2D); g2D.translate(0, tableHeaderComp.getHeight()); table.paint(g2D);/*from ww w . ja v a 2 s .c o m*/ return tableImage; }
From source file:table.FrequencyTablePanel.java
public static BufferedImage createImage(JTable table) { JTableHeader tableHeaderComp = table.getTableHeader(); int totalWidth = tableHeaderComp.getWidth(); int totalHeight = tableHeaderComp.getHeight() + table.getHeight(); BufferedImage tableImage = new BufferedImage(totalWidth, totalHeight, BufferedImage.TYPE_INT_RGB); Graphics2D g2D = (Graphics2D) tableImage.getGraphics(); tableHeaderComp.paint(g2D); g2D.translate(0, tableHeaderComp.getHeight()); table.paint(g2D);/*from w w w . ja v a 2 s. c o m*/ return tableImage; }
From source file:userInterface.EnergySourceBoardSupervisor.ManageEnergyConsumptionsJPanel.java
private void saveBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveBtnActionPerformed JTableHeader tableHeaderComp = applianceTable.getTableHeader(); int totalWidth = tableHeaderComp.getWidth() + applianceTable.getWidth(); int totalHeight = tableHeaderComp.getHeight() + applianceTable.getHeight(); BufferedImage tableImage = new BufferedImage(totalWidth, totalHeight, BufferedImage.TYPE_INT_RGB); Graphics2D g2D = (Graphics2D) tableImage.getGraphics(); tableHeaderComp.paint(g2D); g2D.translate(0, tableHeaderComp.getHeight()); applianceTable.paint(g2D);//ww w . jav a2 s . com String name = fileNameTxt.getText(); try { if (!name.equals("")) { ImageIO.write(tableImage, "png", new File("C:\\Users\\Reshmi\\Documents\\NetBeansProjects\\FinalProject\\Saved Files\\" + name + ".png")); JOptionPane.showMessageDialog(null, "image saved as " + name + ".png", "Saved", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "enter name to be saved", "No image name", JOptionPane.ERROR_MESSAGE); } } catch (Exception e) { System.out.println(e.getMessage()); } }