Example usage for javax.swing.table JTableHeader getWidth

List of usage examples for javax.swing.table JTableHeader getWidth

Introduction

In this page you can find the example usage for javax.swing.table JTableHeader getWidth.

Prototype

@BeanProperty(bound = false)
public int getWidth() 

Source Link

Document

Returns the current width of this component.

Usage

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  w  ww.j a va  2  s. c o 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);//from w ww .  j a v  a 2s .c  o  m
    g2D.translate(0, tableHeaderComp.getHeight());
    table.paint(g2D);
    return tableImage;
}

From source file:nl.phanos.liteliveresultsclient.gui.ResultsWindows.java

public void ChangeFont(int fontSize) {
    JTableHeader header = jTable1.getTableHeader();
    header.setSize(header.getWidth(), fontSize + 5);
    jTable1.setFont(new java.awt.Font("Lucida Grande", 0, fontSize)); // NOI18N
    SerieLabel.setFont(new java.awt.Font("Lucida Grande", 0, fontSize)); // NOI18N
    SerieLabel.setSize(SerieLabel.getWidth(), fontSize + 5);
    jPanel1.setSize(SerieLabel.getWidth(), fontSize + 5);
    jTable1.setRowHeight(fontSize + 5);//from   ww w  .j  a v  a2  s  .c om
    logoLabel.setBounds(this.getWidth() - icon.getIconWidth(), this.getHeight() - icon.getIconHeight(),
            icon.getIconWidth(), icon.getIconHeight());
    header.setFont(new java.awt.Font("Lucida Grande", 0, fontSize)); // NOI18N
    clockLabel.setFont(new java.awt.Font("Lucida Grande", 0, fontSize)); // NOI18N
    clockLabel.setBounds(0, this.getHeight() - (fontSize + 15), fontSize * 30, (fontSize + 5));
    repaint();
}

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);// w w w.  j av a  2s . 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());
    }
}