List of usage examples for javax.swing.table JTableHeader getHeight
@BeanProperty(bound = false) public int getHeight()
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);/*from ww w. ja va 2s . co m*/ g2D.translate(0, tableHeaderComp.getHeight()); table.paint(g2D); 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);// ww w .j a v a2 s.c o m g2D.translate(0, tableHeaderComp.getHeight()); table.paint(g2D); 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);//from ww w . j av a2s . co m g2D.translate(0, tableHeaderComp.getHeight()); applianceTable.paint(g2D); 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()); } }