本文整理汇总了Java中javax.swing.table.JTableHeader.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java JTableHeader.getWidth方法的具体用法?Java JTableHeader.getWidth怎么用?Java JTableHeader.getWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.table.JTableHeader
的用法示例。
在下文中一共展示了JTableHeader.getWidth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import javax.swing.table.JTableHeader; //导入方法依赖的package包/类
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");
}
});
}
示例2: main
import javax.swing.table.JTableHeader; //导入方法依赖的package包/类
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");
}
});
}