本文整理匯總了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");
}
});
}