use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug7107099 method main.
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
textarea = new JTextArea("before###1###\nbefore###2###\nbefore###3###\nbefore###4###\nbefore###5###\n");
scrollPane = new JScrollPane(textarea);
scrollPane.setPreferredSize(new Dimension(100, 50));
frame = new JFrame();
frame.setLayout(new BorderLayout());
frame.setSize(200, 200);
frame.add(scrollPane, BorderLayout.SOUTH);
frame.setVisible(true);
}
});
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
BoundedRangeModel model = scrollPane.getVerticalScrollBar().getModel();
value = model.getValue();
min = model.getMinimum();
max = model.getMaximum();
extent = model.getExtent();
// Do tricky manipulation for testing purpose
textarea.setText(null);
scrollPane.setViewportView(textarea);
textarea.setText("after###1###\nafter###1###\nafter###1###\nafter###1###\nafter###1###\n");
textarea.setCaretPosition(0);
}
});
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
BoundedRangeModel model = scrollPane.getVerticalScrollBar().getModel();
if (value != model.getValue() || min != model.getMinimum() || max != model.getMaximum() || extent != model.getExtent()) {
throw new RuntimeException("Test bug7107099 failed");
}
System.out.println("Test bug7107099 passed");
frame.dispose();
}
});
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class NonOpaquePopupMenuTest method main.
public static void main(String[] args) throws Throwable {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(250);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
new NonOpaquePopupMenuTest();
}
});
toolkit.realSync();
Point p = getMenuClickPoint();
robot.mouseMove(p.x, p.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync();
if (isParentOpaque()) {
throw new RuntimeException("Popup menu parent is opaque");
}
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class SwingTest method start.
private void start() throws Throwable {
do {
if ((this.method != null) && Modifier.isStatic(this.method.getModifiers())) {
// invoke static method on the current thread
run();
} else {
// invoke on the event dispatch thread
SwingUtilities.invokeLater(this);
}
Toolkit tk = Toolkit.getDefaultToolkit();
if (tk instanceof SunToolkit) {
SunToolkit stk = (SunToolkit) tk;
// wait until done
stk.realSync();
}
} while (this.frame != null);
if (this.error != null) {
throw this.error;
}
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class OwnedWindowsSerialization method main.
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(() -> {
topFrame = new Frame(TOP_FRAME_LABEL);
topFrame.setAlwaysOnTop(true);
dialog = new Dialog(topFrame, DIALOG_LABEL);
subDialog = new Dialog(dialog, SUBDIALOG_LABEL);
});
((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
if (!topFrame.isAlwaysOnTop() || !dialog.isAlwaysOnTop() || !subDialog.isAlwaysOnTop()) {
throw new RuntimeException("TEST FAILED: AlwaysOnTop was not set properly");
}
//Serialize
byte[] serializedObject;
try (ByteArrayOutputStream bytes = new ByteArrayOutputStream();
ObjectOutputStream outputStream = new ObjectOutputStream(bytes)) {
outputStream.writeObject(topFrame);
outputStream.flush();
serializedObject = bytes.toByteArray();
}
if (serializedObject == null) {
throw new RuntimeException("FAILED: Serialized byte array in null");
}
//Deserialize
Frame deserializedFrame;
try (ObjectInputStream inputStream = new ObjectInputStream(new ByteArrayInputStream(serializedObject))) {
deserializedFrame = (Frame) inputStream.readObject();
}
//Check the state of the deserialized objects
if (!TOP_FRAME_LABEL.equals(deserializedFrame.getTitle())) {
throw new RuntimeException("FAILED: Top frame deserialized incorrectly");
}
if (!deserializedFrame.isAlwaysOnTop()) {
throw new RuntimeException("FAILED: Top frame alwaysOnTop not set after deserialization");
}
Window[] topOwnedWindows = topFrame.getOwnedWindows();
if (topOwnedWindows.length != 1 || !DIALOG_LABEL.equals(((Dialog) topOwnedWindows[0]).getTitle())) {
throw new RuntimeException("FAILED: Dialog deserialized incorrectly");
}
if (!topOwnedWindows[0].isAlwaysOnTop()) {
throw new RuntimeException("FAILED: Dialog alwaysOnTop not set after deserialization");
}
Window dialog = topOwnedWindows[0];
Window[] dialogOwnedWindows = dialog.getOwnedWindows();
if (dialogOwnedWindows.length != 1 || !SUBDIALOG_LABEL.equals(((Dialog) dialogOwnedWindows[0]).getTitle())) {
throw new RuntimeException("FAILED: Subdialog deserialized incorrectly");
}
if (!dialogOwnedWindows[0].isAlwaysOnTop()) {
throw new RuntimeException("FAILED: Subdialog alwaysOnTop not set after deserialization");
}
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class Test6817933 method main.
public static void main(String[] args) throws Exception {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception exception) {
exception.printStackTrace();
// ignore test on non-Windows machines
return;
}
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
StyleSheet css = new StyleSheet();
css.addRule(STYLE);
HTMLEditorKit kit = new HTMLEditorKit();
kit.setStyleSheet(css);
JFrame frame = new JFrame(STYLE);
frame.add(chooser = new JFileChooser());
frame.setSize(640, 480);
frame.setVisible(true);
}
});
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
toolkit.realSync(500);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
try {
JToggleButton button = get(JToggleButton.class, get(WindowsPlacesBar.class, chooser));
int width = button.getWidth();
int height = button.getHeight() / 3;
Point point = new Point(0, height * 2);
SwingUtilities.convertPointToScreen(point, button);
width += point.x;
height += point.y;
int count = 0;
Robot robot = new Robot();
for (int x = point.x; x < width; x++) {
for (int y = point.y; y < height; y++) {
count += COLOR.equals(robot.getPixelColor(x, y)) ? -2 : 1;
}
}
if (count < 0) {
throw new Exception("TEST ERROR: a lot of red pixels");
}
} catch (Exception exception) {
throw new Error(exception);
} finally {
SwingUtilities.getWindowAncestor(chooser).dispose();
}
}
});
}
Aggregations