Java Code Examples for java.awt.Toolkit#getDefaultToolkit()
The following examples show how to use
java.awt.Toolkit#getDefaultToolkit() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: bug7055065.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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); }
Example 2
Source File: SwingTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private void start() throws Throwable { do { if ((this.method != null) && Modifier.isStatic(this.method.getModifiers())) { run(); // invoke static method on the current thread } else { SwingUtilities.invokeLater(this); // invoke on the event dispatch thread } Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { SunToolkit stk = (SunToolkit) tk; stk.realSync(); // wait until done } } while (this.frame != null); if (this.error != null) { throw this.error; } }
Example 3
Source File: bug7055065.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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); }
Example 4
Source File: MultiResolutionToolkitImageTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) { if (isRVObserver()) { isRVObserverCalled = true; SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); Image resolutionVariant = getResolutionVariant(img); int rvFlags = toolkit.checkImage(resolutionVariant, width, height, new IdleImageObserver()); if (rvFlags < infoflags) { throw new RuntimeException("Info flags are greater than" + " resolution varint info flags"); } } else if ((infoflags & ALLBITS) != 0) { isImageLoaded = true; } return (infoflags & ALLBITS) == 0; }
Example 5
Source File: BasicPopupMenuUI.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
void ungrabWindow() { final Toolkit tk = Toolkit.getDefaultToolkit(); // The grab should be removed java.security.AccessController.doPrivileged( new java.security.PrivilegedAction<Object>() { public Object run() { tk.removeAWTEventListener(MouseGrabber.this); return null; } } ); realUngrabWindow(); }
Example 6
Source File: _AppEventLegacyHandler.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public void handleAbout(final AboutEvent e) { final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit()); sendEventToEachListenerUntilHandled(ae, new EventDispatcher() { public void dispatchEvent(final ApplicationListener listener) { listener.handleAbout(ae); } }); if (ae.isHandled()) return; parent.openCocoaAboutWindow(); }
Example 7
Source File: CPlatformResponder.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Handles mouse events. */ void handleMouseEvent(int eventType, int modifierFlags, int buttonNumber, int clickCount, int x, int y, int absoluteX, int absoluteY) { final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) : NSEvent.nsToJavaEventType(eventType); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED && jeventType != MouseEvent.MOUSE_ENTERED && jeventType != MouseEvent.MOUSE_EXITED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = clickCount; } int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber, modifierFlags); boolean jpopupTrigger = NSEvent.isPopupTrigger(jmodifiers); eventNotifier.notifyMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber, x, y, absoluteX, absoluteY, jmodifiers, jclickCount, jpopupTrigger, null); }
Example 8
Source File: MultiResolutionImageTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
static void testImageLoaded(Image image) { Toolkit toolkit = Toolkit.getDefaultToolkit(); int flags = toolkit.checkImage(image, IMAGE_WIDTH, IMAGE_WIDTH, new SilentImageObserver()); if ((flags & (ImageObserver.FRAMEBITS | ImageObserver.ALLBITS)) == 0) { throw new RuntimeException("Image is not loaded!"); } }
Example 9
Source File: ExecutableInputMethodManager.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
Locale getDefaultKeyboardLocale() { Toolkit toolkit = Toolkit.getDefaultToolkit(); if (toolkit instanceof InputMethodSupport) { return ((InputMethodSupport)toolkit).getDefaultKeyboardLocale(); } else { return Locale.getDefault(); } }
Example 10
Source File: CPlatformResponder.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Handles mouse events. */ void handleMouseEvent(int eventType, int modifierFlags, int buttonNumber, int clickCount, int x, int y, int absoluteX, int absoluteY) { final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) || buttonNumber > tk.getNumberOfButtons() - 1) { return; } int jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) : NSEvent.nsToJavaEventType(eventType); int jbuttonNumber = MouseEvent.NOBUTTON; int jclickCount = 0; if (jeventType != MouseEvent.MOUSE_MOVED && jeventType != MouseEvent.MOUSE_ENTERED && jeventType != MouseEvent.MOUSE_EXITED) { jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); jclickCount = clickCount; } int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber, modifierFlags); boolean jpopupTrigger = NSEvent.isPopupTrigger(jmodifiers); eventNotifier.notifyMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber, x, y, absoluteX, absoluteY, jmodifiers, jclickCount, jpopupTrigger, null); }
Example 11
Source File: LightweightFrame.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Override public void addNotify() { synchronized (getTreeLock()) { if (getPeer() == null) { SunToolkit stk = (SunToolkit)Toolkit.getDefaultToolkit(); try { setPeer(stk.createLightweightFrame(this)); } catch (Exception e) { throw new RuntimeException(e); } } super.addNotify(); } }
Example 12
Source File: jpeg.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("rawtypes") public Object getContent(URLConnection urlc, Class[] classes) throws IOException { Class<?>[] cls = classes; for (int i = 0; i < cls.length; i++) { if (cls[i].isAssignableFrom(URLImageSource.class)) { return new URLImageSource(urlc); } if (cls[i].isAssignableFrom(Image.class)) { Toolkit tk = Toolkit.getDefaultToolkit(); return tk.createImage(new URLImageSource(urlc)); } } return null; }
Example 13
Source File: DragSource.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Reports * whether or not drag * <code>Image</code> support * is available on the underlying platform. * <P> * @return if the Drag Image support is available on this platform */ public static boolean isDragImageSupported() { Toolkit t = Toolkit.getDefaultToolkit(); Boolean supported; try { supported = (Boolean)Toolkit.getDefaultToolkit().getDesktopProperty("DnD.isDragImageSupported"); return supported.booleanValue(); } catch (Exception e) { return false; } }
Example 14
Source File: bug8021253.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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() { fileChooser.setSelectedFile(file); } }); toolkit.realSync(); robot.keyPress(KeyEvent.VK_ENTER); robot.keyRelease(KeyEvent.VK_ENTER); toolkit.realSync(); if (!defaultKeyPressed) { throw new RuntimeException("Default button is not pressed"); } }
Example 15
Source File: Permissions.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { MySecurityManager sm = MySecurityManager.install(); Toolkit toolkit = Toolkit.getDefaultToolkit(); sm.prepare("Toolkit.getSystemClipboard()"); toolkit.getSystemClipboard(); sm.assertChecked(AWTPermission.class, "accessClipboard"); sm.prepare("Toolkit.getSystemEventQueue()"); toolkit.getSystemEventQueue(); sm.assertChecked(AWTPermission.class, "accessEventQueue"); sm.prepare("Toolkit.getSystemSelection()"); toolkit.getSystemSelection(); //sm.assertChecked(AWTPermission.class, "accessClipboard"); sm.prepare("Window(Frame)"); new Window((Frame)null); sm.assertChecked(AWTPermission.class, "showWindowWithoutWarningBanner"); sm.prepare("Window(Window)"); new Window((Window)null); sm.assertChecked(AWTPermission.class, "showWindowWithoutWarningBanner"); sm.prepare("Window(Window,GraphicsConfiguration)"); new Window((Window)null, (GraphicsConfiguration)null); sm.assertChecked(AWTPermission.class, "showWindowWithoutWarningBanner"); }
Example 16
Source File: GE_init4.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { Toolkit.getDefaultToolkit(); }
Example 17
Source File: Test7194184.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private static void testKeyBoardAccess() throws Exception { Robot robot = new Robot(); SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); SwingUtilities.invokeLater(new Test7194184()); toolkit.realSync(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { selectedColor = colorChooser.getColor(); Component recentSwatchPanel = Util.findSubComponent(colorChooser, "RecentSwatchPanel"); if (recentSwatchPanel == null) { throw new RuntimeException("RecentSwatchPanel not found"); } recentSwatchPanel.requestFocusInWindow(); } }); toolkit.realSync(); // Tab to move the focus to MainSwatch Util.hitKeys(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB); // Select the color on right Util.hitKeys(robot, KeyEvent.VK_RIGHT); Util.hitKeys(robot, KeyEvent.VK_RIGHT); Util.hitKeys(robot, KeyEvent.VK_SPACE); toolkit.realSync(); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { frame.dispose(); if (selectedColor == colorChooser.getColor()) { throw new RuntimeException("JColorChooser misses keyboard accessibility"); } } }); }
Example 18
Source File: GE_init1.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { Toolkit.getDefaultToolkit(); }
Example 19
Source File: WindowsRootPaneUI.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
void altReleased(KeyEvent ev) { if (menuCanceledOnPress) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); return; } MenuSelectionManager msm = MenuSelectionManager.defaultManager(); if (msm.getSelectedPath().length == 0) { // if no menu is active, we try activating the menubar JMenuBar mbar = root != null ? root.getJMenuBar() : null; if(mbar == null && winAncestor instanceof JFrame) { mbar = ((JFrame)winAncestor).getJMenuBar(); } JMenu menu = mbar != null ? mbar.getMenu(0) : null; // It might happen that the altRelease event is processed // with a reasonable delay since it has been generated. // Here we check the last deactivation time of the containing // window. If this time appears to be greater than the altRelease // event time the event is skipped to avoid unexpected menu // activation. See 7121442. // Also we must ensure that original source of key event belongs // to the same window object as winAncestor. See 8001633. boolean skip = false; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { Component originalSource = AWTAccessor.getKeyEventAccessor() .getOriginalSource(ev); skip = SunToolkit.getContainingWindow(originalSource) != winAncestor || ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor); } if (menu != null && !skip) { MenuElement[] path = new MenuElement[2]; path[0] = mbar; path[1] = menu; msm.setSelectedPath(path); } else if(!WindowsLookAndFeel.isMnemonicHidden()) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } else { if((msm.getSelectedPath())[0] instanceof ComboPopup) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } }
Example 20
Source File: MultiResolutionImageTest.java From TencentKona-8 with GNU General Public License v2.0 | 3 votes |
static void testToolkitMultiResolutionImagePrepare() throws Exception { generateImages(); File imageFile = new File(IMAGE_NAME_1X); String fileName = imageFile.getAbsolutePath(); Image image = Toolkit.getDefaultToolkit().getImage(fileName); SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); toolkit.prepareImage(image, IMAGE_WIDTH, IMAGE_HEIGHT, new LoadImageObserver(image)); testToolkitMultiResolutionImageLoad(image); }