本文整理汇总了Java中javax.swing.table.JTableHeader.getLocationOnScreen方法的典型用法代码示例。如果您正苦于以下问题:Java JTableHeader.getLocationOnScreen方法的具体用法?Java JTableHeader.getLocationOnScreen怎么用?Java JTableHeader.getLocationOnScreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.table.JTableHeader
的用法示例。
在下文中一共展示了JTableHeader.getLocationOnScreen方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
});
}
示例3: main
import javax.swing.table.JTableHeader; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(20);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel(new MetalLookAndFeel());
} catch (Exception e) {
e.printStackTrace();
}
JTable table = new JTable(new AbstractTableModel() {
public int getRowCount() {
return 10;
}
public int getColumnCount() {
return 10;
}
public Object getValueAt(int rowIndex, int columnIndex) {
return "" + rowIndex + " " + columnIndex;
}
});
header = new JTableHeader(table.getColumnModel());
header.setToolTipText("hello");
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(header);
frame.setSize(300, 300);
frame.setVisible(true);
}
});
toolkit.realSync();
Point point = header.getLocationOnScreen();
robot.mouseMove(point.x + 20, point.y + 50);
robot.mouseMove(point.x + 30, point.y + 50);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
示例4: main
import javax.swing.table.JTableHeader; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Robot robot = new Robot();
robot.setAutoDelay(20);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel(new MetalLookAndFeel());
} catch (Exception e) {
e.printStackTrace();
}
JTable table = new JTable(new AbstractTableModel() {
public int getRowCount() {
return 10;
}
public int getColumnCount() {
return 10;
}
public Object getValueAt(int rowIndex, int columnIndex) {
return "" + rowIndex + " " + columnIndex;
}
});
header = new JTableHeader(table.getColumnModel());
header.setToolTipText("hello");
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(header);
frame.setSize(300, 300);
frame.setVisible(true);
}
});
robot.waitForIdle();
Point point = header.getLocationOnScreen();
robot.mouseMove(point.x + 20, point.y + 50);
robot.mouseMove(point.x + 30, point.y + 50);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}