Java Code Examples for javax.swing.table.JTableHeader#getWidth()

The following examples show how to use javax.swing.table.JTableHeader#getWidth() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainPanel.java    From java-swing-tips with MIT License 6 votes vote down vote up
@Override public void paint(Graphics g, JComponent c) {
  super.paint(g, c);
  if (c instanceof JLayer) {
    JScrollPane scroll = (JScrollPane) ((JLayer<?>) c).getView();
    JTable table = (JTable) scroll.getViewport().getView();
    JTableHeader header = table.getTableHeader();

    int width = header.getWidth();
    TableColumnModel cm = header.getColumnModel();
    for (int i = 0; i < cm.getColumnCount(); i++) {
      width -= cm.getColumn(i).getWidth();
    }

    Point pt = SwingUtilities.convertPoint(header, 0, 0, c);
    filler.setLocation(pt.x + header.getWidth() - width, pt.y);
    filler.setSize(width, header.getHeight());
    fillerColumn.setWidth(width);

    SwingUtilities.paintComponent(g, filler, tempTable, filler.getBounds());
  }
}
 
Example 2
Source File: bug6884066.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Robot robot = new Robot();
        robot.setAutoDelay(20);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                // just to quickly grab a column model
                JTable table = new JTable(10, 5);
                header = new JTableHeader(table.getColumnModel());
                checkColumn(0, "A");
                JFrame frame = new JFrame("standalone header");
                frame.add(header);
                frame.pack();
                frame.setVisible(true);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            }
        });
        toolkit.realSync();
        Point point = header.getLocationOnScreen();
        robot.mouseMove(point.x + 3, point.y + 3);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        for (int i = 0; i < header.getWidth() - 3; i++) {
            robot.mouseMove(point.x + i, point.y + 3);
        }
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                TableColumnModel model = header.getColumnModel();
                checkColumn(model.getColumnCount() - 1, "A");
            }
        });
    }
 
Example 3
Source File: bug6884066.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Robot robot = new Robot();
        robot.setAutoDelay(20);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                // just to quickly grab a column model
                JTable table = new JTable(10, 5);
                header = new JTableHeader(table.getColumnModel());
                checkColumn(0, "A");
                JFrame frame = new JFrame("standalone header");
                frame.add(header);
                frame.pack();
                frame.setVisible(true);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            }
        });
        toolkit.realSync();
        Point point = header.getLocationOnScreen();
        robot.mouseMove(point.x + 3, point.y + 3);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        for (int i = 0; i < header.getWidth() - 3; i++) {
            robot.mouseMove(point.x + i, point.y + 3);
        }
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                TableColumnModel model = header.getColumnModel();
                checkColumn(model.getColumnCount() - 1, "A");
            }
        });
    }
 
Example 4
Source File: bug6884066.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Robot robot = new Robot();
        robot.setAutoDelay(20);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                // just to quickly grab a column model
                JTable table = new JTable(10, 5);
                header = new JTableHeader(table.getColumnModel());
                checkColumn(0, "A");
                JFrame frame = new JFrame("standalone header");
                frame.add(header);
                frame.pack();
                frame.setVisible(true);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            }
        });
        toolkit.realSync();
        Point point = header.getLocationOnScreen();
        robot.mouseMove(point.x + 3, point.y + 3);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        for (int i = 0; i < header.getWidth() - 3; i++) {
            robot.mouseMove(point.x + i, point.y + 3);
        }
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                TableColumnModel model = header.getColumnModel();
                checkColumn(model.getColumnCount() - 1, "A");
            }
        });
    }
 
Example 5
Source File: bug6884066.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Robot robot = new Robot();
        robot.setAutoDelay(20);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                // just to quickly grab a column model
                JTable table = new JTable(10, 5);
                header = new JTableHeader(table.getColumnModel());
                checkColumn(0, "A");
                JFrame frame = new JFrame("standalone header");
                frame.add(header);
                frame.pack();
                frame.setVisible(true);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            }
        });
        toolkit.realSync();
        Point point = header.getLocationOnScreen();
        robot.mouseMove(point.x + 3, point.y + 3);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        for (int i = 0; i < header.getWidth() - 3; i++) {
            robot.mouseMove(point.x + i, point.y + 3);
        }
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                TableColumnModel model = header.getColumnModel();
                checkColumn(model.getColumnCount() - 1, "A");
            }
        });
    }
 
Example 6
Source File: bug6884066.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Robot robot = new Robot();
        robot.setAutoDelay(20);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                // just to quickly grab a column model
                JTable table = new JTable(10, 5);
                header = new JTableHeader(table.getColumnModel());
                checkColumn(0, "A");
                JFrame frame = new JFrame("standalone header");
                frame.add(header);
                frame.pack();
                frame.setVisible(true);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            }
        });
        toolkit.realSync();
        Point point = header.getLocationOnScreen();
        robot.mouseMove(point.x + 3, point.y + 3);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        for (int i = 0; i < header.getWidth() - 3; i++) {
            robot.mouseMove(point.x + i, point.y + 3);
        }
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                TableColumnModel model = header.getColumnModel();
                checkColumn(model.getColumnCount() - 1, "A");
            }
        });
    }
 
Example 7
Source File: bug6884066.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        Robot robot = new Robot();
        robot.setAutoDelay(20);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                // just to quickly grab a column model
                JTable table = new JTable(10, 5);
                header = new JTableHeader(table.getColumnModel());
                checkColumn(0, "A");
                JFrame frame = new JFrame("standalone header");
                frame.add(header);
                frame.pack();
                frame.setVisible(true);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            }
        });
        robot.waitForIdle();
        Point point = header.getLocationOnScreen();
        robot.mouseMove(point.x + 3, point.y + 3);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        for (int i = 0; i < header.getWidth() - 3; i++) {
            robot.mouseMove(point.x + i, point.y + 3);
        }
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                TableColumnModel model = header.getColumnModel();
                checkColumn(model.getColumnCount() - 1, "A");
            }
        });
    }
 
Example 8
Source File: bug6884066.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Robot robot = new Robot();
        robot.setAutoDelay(20);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                // just to quickly grab a column model
                JTable table = new JTable(10, 5);
                header = new JTableHeader(table.getColumnModel());
                checkColumn(0, "A");
                JFrame frame = new JFrame("standalone header");
                frame.add(header);
                frame.pack();
                frame.setVisible(true);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            }
        });
        toolkit.realSync();
        Point point = header.getLocationOnScreen();
        robot.mouseMove(point.x + 3, point.y + 3);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        for (int i = 0; i < header.getWidth() - 3; i++) {
            robot.mouseMove(point.x + i, point.y + 3);
        }
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                TableColumnModel model = header.getColumnModel();
                checkColumn(model.getColumnCount() - 1, "A");
            }
        });
    }
 
Example 9
Source File: bug6884066.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Robot robot = new Robot();
        robot.setAutoDelay(20);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                // just to quickly grab a column model
                JTable table = new JTable(10, 5);
                header = new JTableHeader(table.getColumnModel());
                checkColumn(0, "A");
                JFrame frame = new JFrame("standalone header");
                frame.add(header);
                frame.pack();
                frame.setVisible(true);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            }
        });
        toolkit.realSync();
        Point point = header.getLocationOnScreen();
        robot.mouseMove(point.x + 3, point.y + 3);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        for (int i = 0; i < header.getWidth() - 3; i++) {
            robot.mouseMove(point.x + i, point.y + 3);
        }
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                TableColumnModel model = header.getColumnModel();
                checkColumn(model.getColumnCount() - 1, "A");
            }
        });
    }
 
Example 10
Source File: bug6884066.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Robot robot = new Robot();
        robot.setAutoDelay(20);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                // just to quickly grab a column model
                JTable table = new JTable(10, 5);
                header = new JTableHeader(table.getColumnModel());
                checkColumn(0, "A");
                JFrame frame = new JFrame("standalone header");
                frame.add(header);
                frame.pack();
                frame.setVisible(true);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            }
        });
        toolkit.realSync();
        Point point = header.getLocationOnScreen();
        robot.mouseMove(point.x + 3, point.y + 3);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        for (int i = 0; i < header.getWidth() - 3; i++) {
            robot.mouseMove(point.x + i, point.y + 3);
        }
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                TableColumnModel model = header.getColumnModel();
                checkColumn(model.getColumnCount() - 1, "A");
            }
        });
    }
 
Example 11
Source File: bug6884066.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Robot robot = new Robot();
        robot.setAutoDelay(20);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                // just to quickly grab a column model
                JTable table = new JTable(10, 5);
                header = new JTableHeader(table.getColumnModel());
                checkColumn(0, "A");
                JFrame frame = new JFrame("standalone header");
                frame.add(header);
                frame.pack();
                frame.setVisible(true);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            }
        });
        toolkit.realSync();
        Point point = header.getLocationOnScreen();
        robot.mouseMove(point.x + 3, point.y + 3);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        for (int i = 0; i < header.getWidth() - 3; i++) {
            robot.mouseMove(point.x + i, point.y + 3);
        }
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                TableColumnModel model = header.getColumnModel();
                checkColumn(model.getColumnCount() - 1, "A");
            }
        });
    }
 
Example 12
Source File: bug6884066.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Robot robot = new Robot();
        robot.setAutoDelay(20);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                // just to quickly grab a column model
                JTable table = new JTable(10, 5);
                header = new JTableHeader(table.getColumnModel());
                checkColumn(0, "A");
                JFrame frame = new JFrame("standalone header");
                frame.add(header);
                frame.pack();
                frame.setVisible(true);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            }
        });
        toolkit.realSync();
        Point point = header.getLocationOnScreen();
        robot.mouseMove(point.x + 3, point.y + 3);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        for (int i = 0; i < header.getWidth() - 3; i++) {
            robot.mouseMove(point.x + i, point.y + 3);
        }
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                TableColumnModel model = header.getColumnModel();
                checkColumn(model.getColumnCount() - 1, "A");
            }
        });
    }
 
Example 13
Source File: bug6884066.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Robot robot = new Robot();
        robot.setAutoDelay(20);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                // just to quickly grab a column model
                JTable table = new JTable(10, 5);
                header = new JTableHeader(table.getColumnModel());
                checkColumn(0, "A");
                JFrame frame = new JFrame("standalone header");
                frame.add(header);
                frame.pack();
                frame.setVisible(true);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            }
        });
        toolkit.realSync();
        Point point = header.getLocationOnScreen();
        robot.mouseMove(point.x + 3, point.y + 3);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        for (int i = 0; i < header.getWidth() - 3; i++) {
            robot.mouseMove(point.x + i, point.y + 3);
        }
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                TableColumnModel model = header.getColumnModel();
                checkColumn(model.getColumnCount() - 1, "A");
            }
        });
    }
 
Example 14
Source File: bug6884066.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Robot robot = new Robot();
        robot.setAutoDelay(20);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                // just to quickly grab a column model
                JTable table = new JTable(10, 5);
                header = new JTableHeader(table.getColumnModel());
                checkColumn(0, "A");
                JFrame frame = new JFrame("standalone header");
                frame.add(header);
                frame.pack();
                frame.setVisible(true);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            }
        });
        toolkit.realSync();
        Point point = header.getLocationOnScreen();
        robot.mouseMove(point.x + 3, point.y + 3);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        for (int i = 0; i < header.getWidth() - 3; i++) {
            robot.mouseMove(point.x + i, point.y + 3);
        }
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                TableColumnModel model = header.getColumnModel();
                checkColumn(model.getColumnCount() - 1, "A");
            }
        });
    }