本文整理汇总了Java中sun.awt.SunToolkit.realSync方法的典型用法代码示例。如果您正苦于以下问题:Java SunToolkit.realSync方法的具体用法?Java SunToolkit.realSync怎么用?Java SunToolkit.realSync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.awt.SunToolkit
的用法示例。
在下文中一共展示了SunToolkit.realSync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
toolkit.realSync();
Point point = getRowPointToClick(1);
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync();
Boolean result = (Boolean)tree.getCellEditor().getCellEditorValue();
if (!result) {
throw new RuntimeException("Test Failed!");
}
}
示例2: main
import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowUI();
}
});
toolkit.realSync();
clickCell(robot, 1, 1);
Util.hitKeys(robot, KeyEvent.VK_BACK_SPACE, KeyEvent.VK_BACK_SPACE,
KeyEvent.VK_BACK_SPACE);
toolkit.realSync();
clickColumnHeader(robot, 1);
toolkit.realSync();
clickColumnHeader(robot, 1);
}
示例3: testDispose
import sun.awt.SunToolkit; //导入方法依赖的package包/类
public void testDispose() throws InvocationTargetException,
InterruptedException {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
frame = new JFrame("Test");
textArea = new TextArea("editable textArea");
textArea.setEditable(true);
// textArea.setEditable(false); // this testcase passes if textArea is non-editable
frame.setLayout(new FlowLayout());
frame.add(textArea);
frame.pack();
frame.setVisible(true);
}
});
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
frame.dispose();
}
});
toolkit.realSync();
}
示例4: test
import sun.awt.SunToolkit; //导入方法依赖的package包/类
private void test() throws Exception {
Robot robot = new Robot();
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
UIManager.setLookAndFeel(info.getClassName());
SwingUtilities.invokeAndWait(this);
toolkit.realSync(); // after creation
Thread.sleep(1000);
Point point = this.bar.getLocation();
SwingUtilities.convertPointToScreen(point, this.bar);
point.x += this.bar.getWidth() >> 2;
point.y += this.bar.getHeight() >> 1;
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync(); // before validation
Thread.sleep(1000);
SwingUtilities.invokeAndWait(this);
if (this.bar != null) {
this.bar = null; // allows to reuse the instance
if (AUTO) { // error reporting only for automatic testing
throw new Error("TEST FAILED");
}
}
}
}
示例5: main
import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
toolkit.realSync();
Point movePoint = getButtonPoint();
robot.mouseMove(movePoint.x, movePoint.y);
toolkit.realSync();
long timeout = System.currentTimeMillis() + 9000;
while (!isTooltipAdded && (System.currentTimeMillis() < timeout)) {
try {Thread.sleep(500);} catch (Exception e) {}
}
checkToolTip();
}
示例6: main
import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JOptionPane pane = new JOptionPane("Enter value", JOptionPane.QUESTION_MESSAGE,
JOptionPane.OK_CANCEL_OPTION, null, null, null);
pane.setWantsInput(true);
JDialog dialog = pane.createDialog(null, "My Dialog");
dialog.setVisible(true);
Object result = pane.getValue();
if (result == null || ((Integer) result).intValue() != JOptionPane.OK_OPTION) {
throw new RuntimeException("Invalid result: " + result);
}
System.out.println("Test bug7138665 passed");
}
});
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
toolkit.realSync();
Robot robot = new Robot();
robot.setAutoDelay(100);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
toolkit.realSync();
}
示例7: main
import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(20);
final JFrame frame = new JFrame();
frame.setUndecorated(true);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTableHeader th = new JTableHeader();
th.setColumnModel(new JTable(20, 5).getColumnModel());
th.setUI(new MyTableHeaderUI());
frame.add(th);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
});
toolkit.realSync();
Point point = frame.getLocationOnScreen();
int shift = 10;
int x = point.x;
int y = point.y + frame.getHeight()/2;
for(int i = -shift; i < frame.getWidth() + 2*shift; i++) {
robot.mouseMove(x++, y);
}
toolkit.realSync();
// 9 is a magic test number
if (MyTableHeaderUI.getTestValue() != 9) {
throw new RuntimeException("Unexpected test number "
+ MyTableHeaderUI.getTestValue());
}
System.out.println("ok");
}
示例8: main
import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Test7024235 test = new Test7024235();
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
UIManager.setLookAndFeel(info.getClassName());
test.test();
toolkit.realSync();
Thread.sleep(1000);
test.test();
}
}
示例9: main
import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(500);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
createAndShowGUI();
}
});
toolkit.realSync();
Point clickPoint = getButtonClickPoint();
robot.mouseMove(clickPoint.x, clickPoint.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync();
clickPoint = getMenuClickPoint();
robot.mouseMove(clickPoint.x, clickPoint.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync();
if (RO1.itsValue <= RO2.itsValue) {
throw new RuntimeException("Offset if the second icon is invalid.");
}
}
示例10: main
import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createGui();
}
});
toolkit.realSync();
// Get screen insets
screenInsets = toolkit.getScreenInsets(frame.getGraphicsConfiguration());
if (screenInsets.bottom == 0) {
// This test is only for configurations with taskbar on the bottom
return;
}
System.setSecurityManager(new SecurityManager(){
private String allowsAlwaysOnTopPermission = SecurityConstants.AWT.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION.getName();
@Override
public void checkPermission(Permission perm) {
if (allowsAlwaysOnTopPermission.equals(perm.getName())) {
throw new SecurityException();
}
}
});
// Show popup as if from an applet
// The popup shouldn't overlap the task bar. It should be shifted up.
checkPopup();
}
示例11: main
import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Robot robot = new Robot();
robot.setAutoDelay(50);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
EventQueue.invokeAndWait(() -> {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JComboBox<String> comboBox = new JComboBox<>(new String[]{"one", "two"});
comboBox.setEditable(true);
comboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if ("comboBoxEdited".equals(e.getActionCommand())) {
isComboBoxEdited = true;
}
}
});
frame.add(comboBox);
frame.pack();
frame.setVisible(true);
comboBox.requestFocusInWindow();
});
toolkit.realSync();
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
toolkit.realSync();
if(!isComboBoxEdited){
throw new RuntimeException("ComboBoxEdited event is not fired!");
}
}
示例12: main
import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
frame = new JFrame("Test");
TextArea textArea = new TextArea("Non-editable textArea");
textArea.setEditable(false);
frame.setLayout(new FlowLayout());
frame.add(textArea);
frame.pack();
frame.setVisible(true);
try {
Class XTextAreaPeerClzz = textArea.getPeer().getClass();
System.out.println(XTextAreaPeerClzz.getName());
if (!XTextAreaPeerClzz.getName().equals("sun.awt.X11.XTextAreaPeer")) {
fastreturn = true;
return;
}
Field jtextField = XTextAreaPeerClzz.getDeclaredField("jtext");
jtextField.setAccessible(true);
JTextArea jtext = (JTextArea)jtextField.get(textArea.getPeer());
caret = (DefaultCaret) jtext.getCaret();
textArea.requestFocusInWindow();
} catch (NoSuchFieldException | SecurityException
| IllegalArgumentException | IllegalAccessException e) {
/* These exceptions mean the implementation of XTextAreaPeer is
* changed, this testcase is not valid any more, fix it or remove.
*/
frame.dispose();
throw new RuntimeException("This testcase is not valid any more!");
}
}
});
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
try{
if (fastreturn) {
return;
}
boolean passed = caret.isActive();
System.out.println("is caret visible : " + passed);
if (!passed) {
throw new RuntimeException("The test for bug 71297422 failed");
}
} finally {
frame.dispose();
}
}
});
}
示例13: main
import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
txtField.requestFocus();
}
});
toolkit.realSync();
if (!focusGained) {
throw new RuntimeException("Couldn't gain focus for text field");
}
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
tab.addChangeListener((ChangeListener) listener);
txtField.removeFocusListener((FocusListener) listener);
}
});
toolkit.realSync();
if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_B);
} else {
Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_B);
}
toolkit.realSync();
if (!stateChanged || tab.getSelectedIndex() != 1) {
throw new RuntimeException("JTabbedPane mnemonics don't work from outside the tabbed pane");
}
}
示例14: main
import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
toolkit.realSync();
Point point = getButtonCenter();
robot.mouseMove(point.x, point.y);
toolkit.realSync();
checkButtonsSize();
}
示例15: main
import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
String systemLAF = UIManager.getSystemLookAndFeelClassName();
// the test is not applicable to Motif L&F
if(systemLAF.endsWith("MotifLookAndFeel")){
return;
}
UIManager.setLookAndFeel(systemLAF);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(10);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowUI();
}
});
toolkit.realSync();
// test mouse press
Point point = Util.getCenterPoint(menu);
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync();
point = Util.getCenterPoint(menuItem);
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync();
if (!isMenuItemShowing()) {
throw new RuntimeException("Popup is unexpectedly closed");
}
// test mouse drag
point = Util.getCenterPoint(menu);
robot.mouseMove(point.x, point.y);
Point menuLocation = Util.invokeOnEDT(new Callable<Point>() {
@Override
public Point call() throws Exception {
return menu.getLocationOnScreen();
}
});
Point itemLocation = Util.invokeOnEDT(new Callable<Point>() {
@Override
public Point call() throws Exception {
return menuItem.getLocationOnScreen();
}
});
int x0 = menuLocation.x + 10;
int y0 = menuLocation.y + 10;
int x1 = itemLocation.x + 10;
int y1 = itemLocation.y + 10;
// close menu
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync();
robot.mousePress(InputEvent.BUTTON1_MASK);
Util.glide(robot, x0, y0, x1, y1);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync();
if (!isMenuItemShowing()) {
throw new RuntimeException("Popup is unexpectedly closed");
}
}