use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug7004134 method main.
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
label = new JLabel("A JLabel used as object for an HTML-formatted tooltip");
label.setToolTipText("<html><body bgcolor=FFFFE1>An HTML-formatted ToolTip</body></html>");
frame = new JFrame();
frame.add(label);
frame.pack();
frame.setVisible(true);
}
});
((SunToolkit) SunToolkit.getDefaultToolkit()).realSync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
ToolTipManager toolTipManager = ToolTipManager.sharedInstance();
toolTipManager.setInitialDelay(0);
toolTipManager.mouseMoved(new MouseEvent(label, 0, 0, 0, 0, 0, 0, false));
}
});
Thread.sleep(500);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
toolTipWidth = getTipWindow().getWidth();
frame.dispose();
}
});
Thread thread = new Thread(new ThreadGroup("Some ThreadGroup"), new Runnable() {
public void run() {
SunToolkit.createNewAppContext();
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
frame = new JFrame();
frame.add(label);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
});
((SunToolkit) SunToolkit.getDefaultToolkit()).realSync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
ToolTipManager toolTipManager = ToolTipManager.sharedInstance();
toolTipManager.setInitialDelay(0);
toolTipManager.mouseMoved(new MouseEvent(label, 0, 0, 0, 0, 0, 0, false));
}
});
Thread.sleep(500);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
int newToolTipWidth = getTipWindow().getWidth();
frame.dispose();
if (toolTipWidth != newToolTipWidth) {
throw new RuntimeException("Tooltip width is different. Initial: " + toolTipWidth + ", new: " + newToolTipWidth);
}
}
});
} catch (Exception e) {
throw new RuntimeException(e);
}
}
});
thread.start();
thread.join();
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug6824395 method main.
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
JFrame frame = new JFrame("testing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JEditorPane editorPane = new JEditorPane();
String str = "hello\n";
for (int i = 0; i < 5; i++) {
str += str;
}
editorPane.setText(str);
JLayer<JEditorPane> editorPaneLayer = new JLayer<JEditorPane>(editorPane);
LayerUI<JComponent> layerUI = new LayerUI<JComponent>();
editorPaneLayer.setUI(layerUI);
scrollPane = new JScrollPane(editorPaneLayer);
scrollPane.setPreferredSize(new Dimension(200, 250));
frame.add(scrollPane);
frame.setSize(200, 200);
frame.pack();
frame.setVisible(true);
}
});
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
if (scrollPane.getViewportBorderBounds().width != scrollPane.getViewport().getView().getWidth()) {
throw new RuntimeException("Wrong component's width!");
}
}
});
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug7138665 method main.
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();
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug4966112 method main.
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
robot = new Robot();
robot.setAutoDelay(100);
createAndShowButton();
toolkit.realSync();
setClickPoint(testButton);
clickMouse(InputEvent.BUTTON1_MASK);
clickMouse(InputEvent.BUTTON2_MASK);
clickMouse(InputEvent.BUTTON3_MASK);
toolkit.realSync();
closeFrame();
if (popupButton == NO_MOUSE_BUTTON) {
System.out.println("Test can't identify the popup trigger button. Test skipped");
return;
}
setButtonMask();
// Test Split Pane
createAndShowSplitPane();
toolkit.realSync();
clickMouse(jsp);
toolkit.realSync();
closeFrame();
if (!shown) {
throw new RuntimeException("Popup was not shown on splitpane");
}
// Test Spinner
createAndShowSpinner();
toolkit.realSync();
clickMouse(spin);
toolkit.realSync();
closeFrame();
if (!shown) {
throw new RuntimeException("Popup was not shown on spinner");
}
// Test File Chooser
createAndShowFileChooser();
toolkit.realSync();
clickMouse(filec);
toolkit.realSync();
Util.hitKeys(robot, KeyEvent.VK_ESCAPE);
toolkit.realSync();
Util.hitKeys(robot, KeyEvent.VK_ESCAPE);
toolkit.realSync();
closeFrame();
if (!shown) {
throw new RuntimeException("Popup was not shown on filechooser");
}
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug6209975 method main.
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.");
}
}
Aggregations