@BeforeMethod public void showDialog() throws Throwable {
SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() {
Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
@Override public void eventDispatched(AWTEvent event) {
}
}, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);
frame = new JFrame("My Dialog");
frame.setName("dialog-1");
Object[] listData = new Object[30];
for (int i = 1; i <= listData.length; i++) {
if (i == 25) {
listData[i - 1] = "List Item - '" + i + "'";
} else {
listData[i - 1] = "List Item - " + i;
}
}
list = new JList(listData);
list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
list.setName("list-1");
list.setDragEnabled(true);
JPanel p = new JPanel(new BorderLayout());
p.add(new JScrollPane(list), BorderLayout.NORTH);
textfield = new JTextField(80);
textfield.setName("text-field");
textfield.setDropMode(DropMode.USE_SELECTION);
p.add(textfield, BorderLayout.SOUTH);
frame.getContentPane().add(p);
frame.pack();
frame.setAlwaysOnTop(true);
frame.setVisible(true);
list.requestFocusInWindow();
}
});
}
JListXTest.java 文件源码
java
阅读 24
收藏 0
点赞 0
评论 0
项目:marathonv5
作者:
评论列表
文章目录