java.awt.peer.ComponentPeer Java Examples
The following examples show how to use
java.awt.peer.ComponentPeer.
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: Container.java From jdk8u_jdk with GNU General Public License v2.0 | 7 votes |
private void recursiveHideHeavyweightChildren() { if (!hasHeavyweightDescendants()) { return; } for (int index = 0; index < getComponentCount(); index++) { Component comp = getComponent(index); if (comp.isLightweight()) { if (comp instanceof Container) { ((Container)comp).recursiveHideHeavyweightChildren(); } } else { if (comp.isVisible()) { ComponentPeer peer = comp.getPeer(); if (peer != null) { peer.setVisible(false); } } } } }
Example #2
Source File: DropTarget.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Notify the DropTarget that it has been associated with a Component * ********************************************************************** * This method is usually called from java.awt.Component.addNotify() of * the Component associated with this DropTarget to notify the DropTarget * that a ComponentPeer has been associated with that Component. * * Calling this method, other than to notify this DropTarget of the * association of the ComponentPeer with the Component may result in * a malfunction of the DnD system. ********************************************************************** * <P> * @param peer The Peer of the Component we are associated with! * */ public void addNotify(ComponentPeer peer) { if (peer == componentPeer) return; componentPeer = peer; for (Component c = component; c != null && peer instanceof LightweightPeer; c = c.getParent()) { peer = c.getPeer(); } if (peer instanceof DropTargetPeer) { nativePeer = peer; ((DropTargetPeer)peer).addDropTarget(this); } else { nativePeer = null; } }
Example #3
Source File: EventQueue.java From Java8CN with Apache License 2.0 | 6 votes |
private boolean coalescePaintEvent(PaintEvent e) { ComponentPeer sourcePeer = ((Component)e.getSource()).peer; if (sourcePeer != null) { sourcePeer.coalescePaintEvent(e); } EventQueueItem[] cache = ((Component)e.getSource()).eventCache; if (cache == null) { return false; } int index = eventToCacheIndex(e); if (index != -1 && cache[index] != null) { PaintEvent merged = mergePaintEvents(e, (PaintEvent)cache[index].event); if (merged != null) { cache[index].event = merged; return true; } } return false; }
Example #4
Source File: Container.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
private void recursiveShowHeavyweightChildren() { if (!hasHeavyweightDescendants() || !isVisible()) { return; } for (int index = 0; index < getComponentCount(); index++) { Component comp = getComponent(index); if (comp.isLightweight()) { if (comp instanceof Container) { ((Container)comp).recursiveShowHeavyweightChildren(); } } else { if (comp.isVisible()) { ComponentPeer peer = comp.getPeer(); if (peer != null) { peer.setVisible(true); } } } } }
Example #5
Source File: XInputMethod.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Returns peer of the given client component. If the given client component * doesn't have peer, peer of the native container of the client is returned. */ protected ComponentPeer getPeer(Component client) { XComponentPeer peer; if (log.isLoggable(PlatformLogger.Level.FINE)) { log.fine("Client is " + client); } peer = (XComponentPeer)XToolkit.targetToPeer(client); while (client != null && peer == null) { client = getParent(client); peer = (XComponentPeer)XToolkit.targetToPeer(client); } if (log.isLoggable(PlatformLogger.Level.FINE)) { log.fine("Peer is {0}, client is {1}", peer, client); } if (peer != null) return peer; return null; }
Example #6
Source File: Container.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private void recursiveShowHeavyweightChildren() { if (!hasHeavyweightDescendants() || !isVisible()) { return; } for (int index = 0; index < getComponentCount(); index++) { Component comp = getComponent(index); if (comp.isLightweight()) { if (comp instanceof Container) { ((Container)comp).recursiveShowHeavyweightChildren(); } } else { if (comp.isVisible()) { ComponentPeer peer = comp.getPeer(); if (peer != null) { peer.setVisible(true); } } } } }
Example #7
Source File: CDropTarget.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private CDropTarget(DropTarget dropTarget, Component component, ComponentPeer peer) { super(); fDropTarget = dropTarget; fComponent = component; fPeer = peer; long nativePeer = CPlatformWindow.getNativeViewPtr(((LWComponentPeer) peer).getPlatformWindow()); if (nativePeer == 0L) return; // Unsupported for a window without a native view (plugin) // Create native dragging destination: fNativeDropTarget = this.createNativeDropTarget(dropTarget, component, peer, nativePeer); if (fNativeDropTarget == 0) { throw new IllegalStateException("CDropTarget.createNativeDropTarget() failed."); } }
Example #8
Source File: XInputMethod.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Returns peer of the given client component. If the given client component * doesn't have peer, peer of the native container of the client is returned. */ protected ComponentPeer getPeer(Component client) { XComponentPeer peer; if (log.isLoggable(PlatformLogger.Level.FINE)) { log.fine("Client is " + client); } peer = (XComponentPeer)XToolkit.targetToPeer(client); while (client != null && peer == null) { client = getParent(client); peer = (XComponentPeer)XToolkit.targetToPeer(client); } if (log.isLoggable(PlatformLogger.Level.FINE)) { log.fine("Peer is {0}, client is {1}", peer, client); } if (peer != null) return peer; return null; }
Example #9
Source File: EventQueue.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private boolean coalescePaintEvent(PaintEvent e) { ComponentPeer sourcePeer = ((Component)e.getSource()).peer; if (sourcePeer != null) { sourcePeer.coalescePaintEvent(e); } EventQueueItem[] cache = ((Component)e.getSource()).eventCache; if (cache == null) { return false; } int index = eventToCacheIndex(e); if (index != -1 && cache[index] != null) { PaintEvent merged = mergePaintEvents(e, (PaintEvent)cache[index].event); if (merged != null) { cache[index].event = merged; return true; } } return false; }
Example #10
Source File: Container.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
private void recursiveHideHeavyweightChildren() { if (!hasHeavyweightDescendants()) { return; } for (int index = 0; index < getComponentCount(); index++) { Component comp = getComponent(index); if (comp.isLightweight()) { if (comp instanceof Container) { ((Container)comp).recursiveHideHeavyweightChildren(); } } else { if (comp.isVisible()) { ComponentPeer peer = comp.getPeer(); if (peer != null) { peer.setVisible(false); } } } } }
Example #11
Source File: CDropTarget.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
private CDropTarget(DropTarget dropTarget, Component component, ComponentPeer peer) { super(); fDropTarget = dropTarget; fComponent = component; fPeer = peer; long nativePeer = CPlatformWindow.getNativeViewPtr(((LWComponentPeer) peer).getPlatformWindow()); if (nativePeer == 0L) return; // Unsupported for a window without a native view (plugin) // Create native dragging destination: fNativeDropTarget = this.createNativeDropTarget(dropTarget, component, peer, nativePeer); if (fNativeDropTarget == 0) { throw new IllegalStateException("CDropTarget.createNativeDropTarget() failed."); } }
Example #12
Source File: CDropTarget.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private CDropTarget(DropTarget dropTarget, Component component, ComponentPeer peer) { super(); fDropTarget = dropTarget; fComponent = component; fPeer = peer; long nativePeer = CPlatformWindow.getNativeViewPtr(((LWComponentPeer) peer).getPlatformWindow()); if (nativePeer == 0L) return; // Unsupported for a window without a native view (plugin) // Create native dragging destination: fNativeDropTarget = this.createNativeDropTarget(dropTarget, component, peer, nativePeer); if (fNativeDropTarget == 0) { throw new IllegalStateException("CDropTarget.createNativeDropTarget() failed."); } }
Example #13
Source File: WPageDialog.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@Override @SuppressWarnings("deprecation") public void addNotify() { synchronized(getTreeLock()) { Container parent = getParent(); if (parent != null && parent.getPeer() == null) { parent.addNotify(); } if (getPeer() == null) { ComponentPeer peer = ((WToolkit)Toolkit.getDefaultToolkit()). createWPageDialog(this); setPeer(peer); } super.addNotify(); } }
Example #14
Source File: Container.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private void recursiveRelocateHeavyweightChildren(Point origin) { for (int index = 0; index < getComponentCount(); index++) { Component comp = getComponent(index); if (comp.isLightweight()) { if (comp instanceof Container && ((Container)comp).hasHeavyweightDescendants()) { final Point newOrigin = new Point(origin); newOrigin.translate(comp.getX(), comp.getY()); ((Container)comp).recursiveRelocateHeavyweightChildren(newOrigin); } } else { ComponentPeer peer = comp.getPeer(); if (peer != null) { peer.setBounds(origin.x + comp.getX(), origin.y + comp.getY(), comp.getWidth(), comp.getHeight(), ComponentPeer.SET_LOCATION); } } } }
Example #15
Source File: XInputMethod.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
protected void setXICFocus(ComponentPeer peer, boolean value, boolean active) { if (peer == null) { return; } xicFocus = ((XComponentPeer)peer).getContentWindow(); setXICFocusNative(((XComponentPeer)peer).getContentWindow(), value, active); }
Example #16
Source File: DropTarget.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Note: this interface is required to permit the safe association * of a DropTarget with a Component in one of two ways, either: * <code> component.setDropTarget(droptarget); </code> * or <code> droptarget.setComponent(component); </code> * <P> * The Component will receive drops only if it is enabled. * @param c The new <code>Component</code> this <code>DropTarget</code> * is to be associated with. */ public synchronized void setComponent(Component c) { if (component == c || component != null && component.equals(c)) return; Component old; ComponentPeer oldPeer = null; if ((old = component) != null) { clearAutoscroll(); component = null; if (componentPeer != null) { oldPeer = componentPeer; removeNotify(componentPeer); } old.setDropTarget(null); } if ((component = c) != null) try { c.setDropTarget(this); } catch (Exception e) { // undo the change if (old != null) { old.setDropTarget(this); addNotify(oldPeer); } } }
Example #17
Source File: XComponentPeer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Lowers this component at the bottom of the above HW peer. If the above parameter * is null then the method places this component at the top of the Z-order. */ public void setZOrder(ComponentPeer above) { long aboveWindow = (above != null) ? ((XComponentPeer)above).getWindow() : 0; XToolkit.awtLock(); try{ XlibWrapper.SetZOrder(XToolkit.getDisplay(), getWindow(), aboveWindow); }finally{ XToolkit.awtUnlock(); } }
Example #18
Source File: WPageDialog.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public void addNotify() { synchronized(getTreeLock()) { Container parent = getParent(); if (parent != null && !parent.isDisplayable()) { parent.addNotify(); } if (!isDisplayable()) { ComponentPeer peer = ((WToolkit)Toolkit.getDefaultToolkit()). createWPageDialog(this); setPeer(peer); } super.addNotify(); } }
Example #19
Source File: XComponentPeer.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Lowers this component at the bottom of the above HW peer. If the above parameter * is null then the method places this component at the top of the Z-order. */ public void setZOrder(ComponentPeer above) { long aboveWindow = (above != null) ? ((XComponentPeer)above).getWindow() : 0; XToolkit.awtLock(); try{ XlibWrapper.SetZOrder(XToolkit.getDisplay(), getWindow(), aboveWindow); }finally{ XToolkit.awtUnlock(); } }
Example #20
Source File: XComponentPeer.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Lowers this component at the bottom of the above HW peer. If the above parameter * is null then the method places this component at the top of the Z-order. */ public void setZOrder(ComponentPeer above) { long aboveWindow = (above != null) ? ((XComponentPeer)above).getWindow() : 0; XToolkit.awtLock(); try{ XlibWrapper.SetZOrder(XToolkit.getDisplay(), getWindow(), aboveWindow); }finally{ XToolkit.awtUnlock(); } }
Example #21
Source File: XInputMethod.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
protected void setXICFocus(ComponentPeer peer, boolean value, boolean active) { if (peer == null) { return; } xicFocus = ((XComponentPeer)peer).getContentWindow(); setXICFocusNative(((XComponentPeer)peer).getContentWindow(), value, active); }
Example #22
Source File: Win32GraphicsEnvironment.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public boolean isFlipStrategyPreferred(ComponentPeer peer) { GraphicsConfiguration gc; if (peer != null && (gc = peer.getGraphicsConfiguration()) != null) { GraphicsDevice gd = gc.getDevice(); if (gd instanceof D3DGraphicsDevice) { return ((D3DGraphicsDevice)gd).isD3DEnabledOnDevice(); } } return false; }
Example #23
Source File: KeyboardFocusManagerPeerImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("deprecation") public static boolean shouldFocusOnClick(Component component) { boolean acceptFocusOnClick = false; // A component is generally allowed to accept focus on click // if its peer is focusable. There're some exceptions though. // CANVAS & SCROLLBAR accept focus on click if (component instanceof Canvas || component instanceof Scrollbar) { acceptFocusOnClick = true; // PANEL, empty only, accepts focus on click } else if (component instanceof Panel) { acceptFocusOnClick = (((Panel)component).getComponentCount() == 0); // Other components } else { ComponentPeer peer = (component != null ? component.getPeer() : null); acceptFocusOnClick = (peer != null ? peer.isFocusable() : false); } return acceptFocusOnClick && AWTAccessor.getComponentAccessor().canBeFocusOwner(component); }
Example #24
Source File: XWindow.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
static XWindow getParentXWindowObject(Component target) { if (target == null) return null; Component temp = target.getParent(); if (temp == null) return null; ComponentPeer peer = temp.getPeer(); if (peer == null) return null; while ((peer != null) && !(peer instanceof XWindow)) { temp = temp.getParent(); peer = temp.getPeer(); } if (peer != null && peer instanceof XWindow) return (XWindow) peer; else return null; }
Example #25
Source File: XGlobalCursorManager.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
protected void setCursor(Component comp, Cursor cursor, boolean useCache) { if (comp == null) { return; } Cursor cur = useCache ? cursor : getCapableCursor(comp); Component nc = null; if (useCache) { synchronized (this) { nc = nativeContainer.get(); } } else { nc = SunToolkit.getHeavyweightComponent(comp); } if (nc != null) { ComponentPeer nc_peer = AWTAccessor.getComponentAccessor().getPeer(nc); if (nc_peer instanceof XComponentPeer) { synchronized (this) { nativeContainer = new WeakReference<Component>(nc); } //6431076. A subcomponents (a XTextArea in particular) //may want to override the cursor over some of their parts. ((XComponentPeer)nc_peer).pSetCursor(cur, false); // in case of grab we do for Swing we need to update keep cursor updated // (we don't need this in case of AWT menus). Window Manager consider // the grabber as a current window and use its cursor. So we need to // change cursor on the grabber too. updateGrabbedCursor(cur); } } }
Example #26
Source File: DropTarget.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Note: this interface is required to permit the safe association * of a DropTarget with a Component in one of two ways, either: * <code> component.setDropTarget(droptarget); </code> * or <code> droptarget.setComponent(component); </code> * <P> * The Component will receive drops only if it is enabled. * @param c The new <code>Component</code> this <code>DropTarget</code> * is to be associated with. */ public synchronized void setComponent(Component c) { if (component == c || component != null && component.equals(c)) return; Component old; ComponentPeer oldPeer = null; if ((old = component) != null) { clearAutoscroll(); component = null; if (componentPeer != null) { oldPeer = componentPeer; removeNotify(componentPeer); } old.setDropTarget(null); } if ((component = c) != null) try { c.setDropTarget(this); } catch (Exception e) { // undo the change if (old != null) { old.setDropTarget(this); addNotify(oldPeer); } } }
Example #27
Source File: XComponentPeer.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Lowers this component at the bottom of the above HW peer. If the above parameter * is null then the method places this component at the top of the Z-order. */ public void setZOrder(ComponentPeer above) { long aboveWindow = (above != null) ? ((XComponentPeer)above).getWindow() : 0; XToolkit.awtLock(); try{ XlibWrapper.SetZOrder(XToolkit.getDisplay(), getWindow(), aboveWindow); }finally{ XToolkit.awtUnlock(); } }
Example #28
Source File: Container.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * @deprecated As of JDK version 1.1, * replaced by <code>getInsets()</code>. */ @Deprecated public Insets insets() { ComponentPeer peer = this.peer; if (peer instanceof ContainerPeer) { ContainerPeer cpeer = (ContainerPeer)peer; return (Insets)cpeer.getInsets().clone(); } return new Insets(0, 0, 0, 0); }
Example #29
Source File: DefaultFocusTraversalPolicy.java From Java8CN with Apache License 2.0 | 5 votes |
/** * Determines whether a Component is an acceptable choice as the new * focus owner. The Component must be visible, displayable, and enabled * to be accepted. If client code has explicitly set the focusability * of the Component by either overriding * <code>Component.isFocusTraversable()</code> or * <code>Component.isFocusable()</code>, or by calling * <code>Component.setFocusable()</code>, then the Component will be * accepted if and only if it is focusable. If, however, the Component is * relying on default focusability, then all Canvases, Labels, Panels, * Scrollbars, ScrollPanes, Windows, and lightweight Components will be * rejected. * * @param aComponent the Component whose fitness as a focus owner is to * be tested * @return <code>true</code> if aComponent meets the above requirements; * <code>false</code> otherwise */ protected boolean accept(Component aComponent) { if (!(aComponent.isVisible() && aComponent.isDisplayable() && aComponent.isEnabled())) { return false; } // Verify that the Component is recursively enabled. Disabling a // heavyweight Container disables its children, whereas disabling // a lightweight Container does not. if (!(aComponent instanceof Window)) { for (Container enableTest = aComponent.getParent(); enableTest != null; enableTest = enableTest.getParent()) { if (!(enableTest.isEnabled() || enableTest.isLightweight())) { return false; } if (enableTest instanceof Window) { break; } } } boolean focusable = aComponent.isFocusable(); if (aComponent.isFocusTraversableOverridden()) { return focusable; } ComponentPeer peer = aComponent.getPeer(); return (peer != null && peer.isFocusable()); }
Example #30
Source File: Win32GraphicsEnvironment.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override public boolean isFlipStrategyPreferred(ComponentPeer peer) { GraphicsConfiguration gc; if (peer != null && (gc = peer.getGraphicsConfiguration()) != null) { GraphicsDevice gd = gc.getDevice(); if (gd instanceof D3DGraphicsDevice) { return ((D3DGraphicsDevice)gd).isD3DEnabledOnDevice(); } } return false; }