sun.awt.SunToolkit Java Examples
The following examples show how to use
sun.awt.SunToolkit.
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: SetBackgroundTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private static void initRoughColor(){ Canvas canvas = new Canvas(); canvas.setBackground(color); frame.add(canvas, BorderLayout.CENTER); frame.validate(); ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); Point loc = canvas.getLocationOnScreen(); Color robotColor = robot.getPixelColor(loc.x + canvas.getWidth()/2, loc.y + canvas.getHeight()/2); roughColor = robotColor; Sysout.println(" --- init rough color ... "); Sysout.println(" color = "+color); Sysout.println(" roughColor = "+roughColor); frame.remove(canvas); ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); }
Example #2
Source File: DefaultKeyboardFocusManager.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private boolean repostIfFollowsKeyEvents(WindowEvent e) { if (!(e instanceof TimedWindowEvent)) { return false; } TimedWindowEvent we = (TimedWindowEvent)e; long time = we.getWhen(); synchronized (this) { KeyEvent ke = enqueuedKeyEvents.isEmpty() ? null : enqueuedKeyEvents.getFirst(); if (ke != null && time >= ke.getWhen()) { TypeAheadMarker marker = typeAheadMarkers.isEmpty() ? null : typeAheadMarkers.getFirst(); if (marker != null) { Window toplevel = marker.untilFocused.getContainingWindow(); // Check that the component awaiting focus belongs to // the current focused window. See 8015454. if (toplevel != null && toplevel.isFocused()) { SunToolkit.postEvent(AppContext.getAppContext(), new SequencedEvent(e)); return true; } } } } return false; }
Example #3
Source File: KeyCharTest.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); Frame frame = new Frame(); frame.setSize(300, 300); frame.setVisible(true); toolkit.realSync(); Robot robot = new Robot(); robot.keyPress(KeyEvent.VK_DELETE); robot.keyRelease(KeyEvent.VK_DELETE); toolkit.realSync(); frame.dispose(); if (eventsCount != 3) { throw new RuntimeException("Wrong number of key events: " + eventsCount); } }
Example #4
Source File: bug4524490.java From hottub 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(); robot.setAutoDelay(50); UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); SwingUtilities.invokeLater(new Runnable() { public void run() { fileChooser = new JFileChooser(); fileChooser.showOpenDialog(null); } }); toolkit.realSync(); if (OSInfo.OSType.MACOSX.equals(OSInfo.getOSType())) { Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_L); } else { Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_L); } checkFocus(); }
Example #5
Source File: bug4524490.java From openjdk-8 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(); robot.setAutoDelay(50); UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); SwingUtilities.invokeLater(new Runnable() { public void run() { fileChooser = new JFileChooser(); fileChooser.showOpenDialog(null); } }); toolkit.realSync(); if (OSInfo.OSType.MACOSX.equals(OSInfo.getOSType())) { Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_L); } else { Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_L); } checkFocus(); }
Example #6
Source File: SingleModeDeselect.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static final void main(String args[]) { final Frame frame = new Frame(); final List list = new List(); list.add(" item 0 "); list.add(" item 1 "); frame.add(list); frame.setLayout(new FlowLayout()); frame.setBounds(100,100,300,300); frame.setVisible(true); list.select(0); list.deselect(1); ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); if (list.getSelectedIndex() != 0){ throw new RuntimeException("Test failed: List.getSelectedIndex() returns "+list.getSelectedIndex()); } }
Example #7
Source File: Container.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
private void stopLWModal() { synchronized (getTreeLock()) { if (modalAppContext != null) { Container nativeContainer = getHeavyweightContainer(); if(nativeContainer != null) { if (this.modalComp != null) { nativeContainer.modalComp = this.modalComp; this.modalComp = null; return; } else { nativeContainer.modalComp = null; } } // Wake up event dispatch thread on which the dialog was // initially shown SunToolkit.postEvent(modalAppContext, new PeerEvent(this, new WakingRunnable(), PeerEvent.PRIORITY_EVENT)); } EventQueue.invokeLater(new WakingRunnable()); getTreeLock().notifyAll(); } }
Example #8
Source File: GraphicsDevice.java From jdk-1.7-annotated with Apache License 2.0 | 6 votes |
boolean isWindowPerpixelTranslucencySupported() { /* * Per-pixel alpha is supported if all the conditions are TRUE: * 1. The toolkit is a sort of SunToolkit * 2. The toolkit supports translucency in general * (isWindowTranslucencySupported()) * 3. There's at least one translucency-capable * GraphicsConfiguration */ Toolkit curToolkit = Toolkit.getDefaultToolkit(); if (!(curToolkit instanceof SunToolkit)) { return false; } if (!((SunToolkit)curToolkit).isWindowTranslucencySupported()) { return false; } // TODO: cache translucency capable GC return getTranslucencyCapableGC() != null; }
Example #9
Source File: GraphicsDevice.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
boolean isWindowPerpixelTranslucencySupported() { /* * Per-pixel alpha is supported if all the conditions are TRUE: * 1. The toolkit is a sort of SunToolkit * 2. The toolkit supports translucency in general * (isWindowTranslucencySupported()) * 3. There's at least one translucency-capable * GraphicsConfiguration */ Toolkit curToolkit = Toolkit.getDefaultToolkit(); if (!(curToolkit instanceof SunToolkit)) { return false; } if (!((SunToolkit)curToolkit).isWindowTranslucencySupported()) { return false; } // TODO: cache translucency capable GC return getTranslucencyCapableGC() != null; }
Example #10
Source File: WDropTargetContextPeer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override protected void eventPosted(final SunDropTargetEvent e) { if (e.getID() != SunDropTargetEvent.MOUSE_DROPPED) { Runnable runnable = new Runnable() { @Override public void run() { e.getDispatcher().unregisterAllEvents(); } }; // NOTE: this PeerEvent must be a NORM_PRIORITY event to be // dispatched after this SunDropTargetEvent, but before the next // one, so we should pass zero flags. PeerEvent peerEvent = new PeerEvent(e.getSource(), runnable, 0); SunToolkit.executeOnEventHandlerThread(peerEvent); } }
Example #11
Source File: XTextAreaPeer.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static MouseEvent newMouseEvent( Component source, Point point, MouseEvent template ) { MouseEvent e = template; MouseEvent nme = new MouseEvent( source, e.getID(), e.getWhen(), e.getModifiersEx() | e.getModifiers(), point.x, point.y, e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), e.getButton() ); // Because these MouseEvents are dispatched directly to // their target, we need to mark them as being // system-generated here SunToolkit.setSystemGenerated(nme); return nme; }
Example #12
Source File: KeyCharTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); Frame frame = new Frame(); frame.setSize(300, 300); frame.setVisible(true); toolkit.realSync(); Robot robot = new Robot(); robot.keyPress(KeyEvent.VK_DELETE); robot.keyRelease(KeyEvent.VK_DELETE); toolkit.realSync(); frame.dispose(); if (eventsCount != 3) { throw new RuntimeException("Wrong number of key events: " + eventsCount); } }
Example #13
Source File: X11Renderer.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void drawPolyline(SunGraphics2D sg2d, int xpoints[], int ypoints[], int npoints) { SunToolkit.awtLock(); try { long xgc = validate(sg2d); XDrawPoly(sg2d.surfaceData.getNativeOps(), xgc, sg2d.transX, sg2d.transY, xpoints, ypoints, npoints, false); } finally { SunToolkit.awtUnlock(); } }
Example #14
Source File: X11Renderer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public void drawRect(SunGraphics2D sg2d, int x, int y, int width, int height) { SunToolkit.awtLock(); try { long xgc = validate(sg2d); XDrawRect(sg2d.surfaceData.getNativeOps(), xgc, x+sg2d.transX, y+sg2d.transY, width, height); } finally { SunToolkit.awtUnlock(); } }
Example #15
Source File: XWindowPeer.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public void dispose() { if (isGrabbed()) { if (grabLog.isLoggable(PlatformLogger.Level.FINE)) { grabLog.fine("Generating UngrabEvent on {0} because of the window disposal", this); } postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource())); } SunToolkit.awtLock(); try { windows.remove(this); } finally { SunToolkit.awtUnlock(); } if (warningWindow != null) { warningWindow.destroy(); } removeRootPropertyEventDispatcher(); mustControlStackPosition = false; super.dispose(); /* * Fix for 6457980. * When disposing an owned Window we should implicitly * return focus to its decorated owner because it won't * receive WM_TAKE_FOCUS. */ if (isSimpleWindow()) { if (target == XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow()) { Window owner = getDecoratedOwner((Window)target); ((XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(owner)).requestWindowFocus(); } } }
Example #16
Source File: Toolkit.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Override public void firePropertyChange(final PropertyChangeEvent evt) { Object oldValue = evt.getOldValue(); Object newValue = evt.getNewValue(); String propertyName = evt.getPropertyName(); if (oldValue != null && newValue != null && oldValue.equals(newValue)) { return; } Runnable updater = new Runnable() { public void run() { PropertyChangeSupport pcs = (PropertyChangeSupport) AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); if (null != pcs) { pcs.firePropertyChange(evt); } } }; final AppContext currentAppContext = AppContext.getAppContext(); for (AppContext appContext : AppContext.getAppContexts()) { if (null == appContext || appContext.isDisposed()) { continue; } if (currentAppContext == appContext) { updater.run(); } else { final PeerEvent e = new PeerEvent(source, updater, PeerEvent.ULTIMATE_PRIORITY_EVENT); SunToolkit.postEvent(appContext, e); } } }
Example #17
Source File: SwingPaintEventDispatcher.java From Bytecoder with Apache License 2.0 | 5 votes |
public boolean queueSurfaceDataReplacing(Component c, Runnable r) { if (c instanceof RootPaneContainer) { AppContext appContext = SunToolkit.targetToAppContext(c); RepaintManager.currentManager(appContext). nativeQueueSurfaceDataRunnable(appContext, c, r); return true; } return super.queueSurfaceDataReplacing(c, r); }
Example #18
Source File: KeyboardFocusManager.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns the Window which will be active after processing this request, * or null if this is a duplicate request. The active Window is useful * because some native platforms do not support setting the native focus * owner to null. On these platforms, the obvious choice is to set the * focus owner to the focus proxy of the active Window. */ static Window markClearGlobalFocusOwner() { // need to call this out of synchronized block to avoid possible deadlock // see 6454631. final Component nativeFocusedWindow = getCurrentKeyboardFocusManager().getNativeFocusedWindow(); synchronized (heavyweightRequests) { HeavyweightFocusRequest hwFocusRequest = getLastHWRequest(); if (hwFocusRequest == HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) { // duplicate request return null; } heavyweightRequests.add (HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER); Component activeWindow = ((hwFocusRequest != null) ? SunToolkit.getContainingWindow(hwFocusRequest.heavyweight) : nativeFocusedWindow); while (activeWindow != null && !((activeWindow instanceof Frame) || (activeWindow instanceof Dialog))) { activeWindow = activeWindow.getParent_NoClientCode(); } return (Window) activeWindow; } }
Example #19
Source File: bug8007006.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void sleep(int ms) { SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); tk.realSync(); try { Thread.sleep(ms); } catch (Exception ignore) { } }
Example #20
Source File: X11Renderer.java From hottub with GNU General Public License v2.0 | 5 votes |
public void fillRect(SunGraphics2D sg2d, int x, int y, int width, int height) { SunToolkit.awtLock(); try { long xgc = validate(sg2d); XFillRect(sg2d.surfaceData.getNativeOps(), xgc, x+sg2d.transX, y+sg2d.transY, width, height); } finally { SunToolkit.awtUnlock(); } }
Example #21
Source File: D3DSurfaceData.java From hottub with GNU General Public License v2.0 | 5 votes |
static void swapBuffers(D3DSurfaceData sd, final int x1, final int y1, final int x2, final int y2) { long pData = sd.getNativeOps(); D3DRenderQueue rq = D3DRenderQueue.getInstance(); // swapBuffers can be called from the toolkit thread by swing, we // should detect this and prevent the deadlocks if (rq.isRenderQueueThread()) { if (!rq.tryLock()) { // if we could not obtain the lock, repaint the area // that was supposed to be swapped, and no-op this swap final Component target = (Component)sd.getPeer().getTarget(); SunToolkit.executeOnEventHandlerThread(target, new Runnable() { public void run() { target.repaint(x1, y1, x2, y2); } }); return; } } else { rq.lock(); } try { RenderBuffer buf = rq.getBuffer(); rq.ensureCapacityAndAlignment(28, 4); buf.putInt(SWAP_BUFFERS); buf.putLong(pData); buf.putInt(x1); buf.putInt(y1); buf.putInt(x2); buf.putInt(y2); rq.flushNow(); } finally { rq.unlock(); } }
Example #22
Source File: ActionAfterRemove.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static final void main(String args[]) { final Frame frame = new Frame(); final List list = new List(); Robot robot = null; // In order to handle all uncaught exceptions in the EDT System.setProperty("sun.awt.exception.handler", "ActionAfterRemove"); list.add("will be removed"); frame.add(list); frame.setLayout(new FlowLayout()); frame.setBounds(100,100,300,300); frame.setVisible(true); list.select(0); list.remove(0); try{ robot = new Robot(); }catch(AWTException e){ throw new RuntimeException(e); } Util.clickOnComp(list, robot); ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); Util.clickOnComp(list, robot); ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); if (!passed){ throw new RuntimeException("Test failed: exception was thrown on EDT."); } }
Example #23
Source File: MissingDragExitEventTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static void sleep() { try { Thread.sleep(10000); } catch (InterruptedException ignored) { } ((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); }
Example #24
Source File: X11Renderer.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void fillRect(SunGraphics2D sg2d, int x, int y, int width, int height) { SunToolkit.awtLock(); try { long xgc = validate(sg2d); XFillRect(sg2d.surfaceData.getNativeOps(), xgc, x+sg2d.transX, y+sg2d.transY, width, height); } finally { SunToolkit.awtUnlock(); } }
Example #25
Source File: GestureHandler.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
static void handleGestureFromNative(final Window window, final int type, final double x, final double y, final double a, final double b) { if (window == null) return; // should never happen... SunToolkit.executeOnEventHandlerThread(window, new Runnable() { public void run() { final Component component = SwingUtilities.getDeepestComponentAt(window, (int)x, (int)y); final PerComponentNotifier firstNotifier; if (component instanceof RootPaneContainer) { firstNotifier = getNextNotifierForComponent(((RootPaneContainer)component).getRootPane()); } else { firstNotifier = getNextNotifierForComponent(component); } if (firstNotifier == null) return; switch (type) { case PHASE: firstNotifier.recursivelyHandlePhaseChange(a, new GesturePhaseEvent()); return; case ROTATE: firstNotifier.recursivelyHandleRotate(new RotationEvent(a)); return; case MAGNIFY: firstNotifier.recursivelyHandleMagnify(new MagnificationEvent(a)); return; case SWIPE: firstNotifier.recursivelyHandleSwipe(a, b, new SwipeEvent()); return; } } }); }
Example #26
Source File: KeyboardFocusManager.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static boolean isTemporary(Component to, Component from) { Window wto = SunToolkit.getContainingWindow(to); Window wfrom = SunToolkit.getContainingWindow(from); if (wto == null && wfrom == null) { return false; } if (wto == null) { return true; } if (wfrom == null) { return false; } return (wto != wfrom); }
Example #27
Source File: AppletClassLoader.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public void run() { appContext = SunToolkit.createNewAppContext(); created = true; synchronized(syncObject) { syncObject.notifyAll(); } }
Example #28
Source File: X11SurfaceData.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public boolean copyArea(SunGraphics2D sg2d, int x, int y, int w, int h, int dx, int dy) { if (x11pipe == null) { if (!isDrawableValid()) { return true; } makePipes(); } CompositeType comptype = sg2d.imageComp; if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE && (CompositeType.SrcOverNoEa.equals(comptype) || CompositeType.SrcNoEa.equals(comptype))) { x += sg2d.transX; y += sg2d.transY; SunToolkit.awtLock(); try { boolean needExposures = canSourceSendExposures(x, y, w, h); long xgc = getBlitGC(sg2d.getCompClip(), needExposures); x11pipe.devCopyArea(getNativeOps(), xgc, x, y, x + dx, y + dy, w, h); } finally { SunToolkit.awtUnlock(); } return true; } return false; }
Example #29
Source File: FontConfigManager.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
private static String getFCLocaleStr() { Locale l = SunToolkit.getStartupLocale(); String localeStr = l.getLanguage(); String country = l.getCountry(); if (!country.equals("")) { localeStr = localeStr + "-" + country; } return localeStr; }
Example #30
Source File: JPopupMenu.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * 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; }