Search in sources :

Example 51 with SunToolkit

use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.

the class Dialog method modalityPushed.

final void modalityPushed() {
    Toolkit tk = Toolkit.getDefaultToolkit();
    if (tk instanceof SunToolkit) {
        SunToolkit stk = (SunToolkit) tk;
        stk.notifyModalityPushed(this);
    }
}
Also used : SunToolkit(sun.awt.SunToolkit) SunToolkit(sun.awt.SunToolkit)

Example 52 with SunToolkit

use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.

the class JPopupMenu method canPopupOverlapTaskBar.

/**
     * Returns whether popup is allowed to be shown above the task bar.
     */
static boolean canPopupOverlapTaskBar() {
    boolean result = true;
    Toolkit tk = Toolkit.getDefaultToolkit();
    if (tk instanceof SunToolkit) {
        result = ((SunToolkit) tk).canPopupOverlapTaskBar();
    }
    return result;
}
Also used : SunToolkit(sun.awt.SunToolkit) SunToolkit(sun.awt.SunToolkit)

Example 53 with SunToolkit

use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.

the class MaximizedToMaximized method main.

public static void main(String[] args) throws Exception {
    Frame frame = new Frame();
    final Toolkit toolkit = Toolkit.getDefaultToolkit();
    final GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsDevice graphicsDevice = graphicsEnvironment.getDefaultScreenDevice();
    final Dimension screenSize = toolkit.getScreenSize();
    final Insets screenInsets = toolkit.getScreenInsets(graphicsDevice.getDefaultConfiguration());
    final Rectangle availableScreenBounds = new Rectangle(screenSize);
    availableScreenBounds.x += screenInsets.left;
    availableScreenBounds.y += screenInsets.top;
    availableScreenBounds.width -= (screenInsets.left + screenInsets.right);
    availableScreenBounds.height -= (screenInsets.top + screenInsets.bottom);
    frame.setBounds(availableScreenBounds.x, availableScreenBounds.y, availableScreenBounds.width, availableScreenBounds.height);
    frame.setVisible(true);
    Rectangle frameBounds = frame.getBounds();
    frame.setExtendedState(Frame.MAXIMIZED_BOTH);
    ((SunToolkit) toolkit).realSync();
    Rectangle maximizedFrameBounds = frame.getBounds();
    if (maximizedFrameBounds.width < frameBounds.width || maximizedFrameBounds.height < frameBounds.height) {
        throw new RuntimeException("Maximized frame is smaller than non maximized");
    }
}
Also used : Frame(java.awt.Frame) GraphicsDevice(java.awt.GraphicsDevice) Insets(java.awt.Insets) Rectangle(java.awt.Rectangle) SunToolkit(sun.awt.SunToolkit) SunToolkit(sun.awt.SunToolkit) Toolkit(java.awt.Toolkit) Dimension(java.awt.Dimension) GraphicsEnvironment(java.awt.GraphicsEnvironment)

Example 54 with SunToolkit

use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.

the class bug7129742 method main.

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();
            }
        }
    });
}
Also used : Field(java.lang.reflect.Field) FlowLayout(java.awt.FlowLayout) JTextArea(javax.swing.JTextArea) DefaultCaret(javax.swing.text.DefaultCaret) JFrame(javax.swing.JFrame) TextArea(java.awt.TextArea) JTextArea(javax.swing.JTextArea) SunToolkit(sun.awt.SunToolkit)

Example 55 with SunToolkit

use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.

the class TestDispose method testDispose.

public void testDispose() throws InvocationTargetException, InterruptedException {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            frame = new JFrame("Test");
            textField = new TextField("editable textArea");
            textField.setEditable(true);
            // textField.setEditable(false); // this testcase passes if textField is non-editable
            frame.setLayout(new FlowLayout());
            frame.add(textField);
            frame.pack();
            frame.setVisible(true);
        }
    });
    toolkit.realSync();
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            frame.dispose();
        }
    });
    toolkit.realSync();
}
Also used : FlowLayout(java.awt.FlowLayout) JFrame(javax.swing.JFrame) SunToolkit(sun.awt.SunToolkit) TextField(java.awt.TextField)

Aggregations

SunToolkit (sun.awt.SunToolkit)120 Robot (java.awt.Robot)26 Point (java.awt.Point)9 Frame (java.awt.Frame)7 JFrame (javax.swing.JFrame)7 BufferedImage (java.awt.image.BufferedImage)5 Rectangle (java.awt.Rectangle)4 FlowLayout (java.awt.FlowLayout)3 TextField (java.awt.TextField)3 Toolkit (java.awt.Toolkit)3 MouseEvent (java.awt.event.MouseEvent)3 JTableHeader (javax.swing.table.JTableHeader)3 Component (java.awt.Component)2 KeyEvent (java.awt.event.KeyEvent)2 VolatileImage (java.awt.image.VolatileImage)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 File (java.io.File)2 IOException (java.io.IOException)2 Field (java.lang.reflect.Field)2 URL (java.net.URL)2