sun.awt.AWTAccessor Java Examples
The following examples show how to use
sun.awt.AWTAccessor.
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: CInputMethod.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private LWComponentPeer<?, ?> getNearestNativePeer(Component comp) { if (comp==null) return null; final ComponentAccessor acc = AWTAccessor.getComponentAccessor(); ComponentPeer peer = acc.getPeer(comp); if (peer==null) return null; while (peer instanceof java.awt.peer.LightweightPeer) { comp = comp.getParent(); if (comp==null) return null; peer = acc.getPeer(comp); if (peer==null) return null; } if (peer instanceof LWComponentPeer) return (LWComponentPeer)peer; return null; }
Example #2
Source File: XWindowPeer.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public void repositionSecurityWarning() { // NOTE: On KWin if the window/border snapping option is enabled, // the Java window may be swinging while it's being moved. // This doesn't make the application unusable though looks quite ugly. // Probobly we need to find some hint to assign to our Security // Warning window in order to exclude it from the snapping option. // We are not currently aware of existance of such a property. if (warningWindow != null) { // We can't use the coordinates stored in the XBaseWindow since // they are zeros for decorated frames. AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor(); int x = compAccessor.getX(target); int y = compAccessor.getY(target); int width = compAccessor.getWidth(target); int height = compAccessor.getHeight(target); warningWindow.reposition(x, y, width, height); } }
Example #3
Source File: TransferHandler.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public void actionPerformed(final ActionEvent e) { final Object src = e.getSource(); final PrivilegedAction<Void> action = new PrivilegedAction<Void>() { public Void run() { actionPerformedImpl(e); return null; } }; final AccessControlContext stack = AccessController.getContext(); final AccessControlContext srcAcc = AWTAccessor.getComponentAccessor().getAccessControlContext((Component)src); final AccessControlContext eventAcc = AWTAccessor.getAWTEventAccessor().getAccessControlContext(e); if (srcAcc == null) { javaSecurityAccess.doIntersectionPrivilege(action, stack, eventAcc); } else { javaSecurityAccess.doIntersectionPrivilege( new PrivilegedAction<Void>() { public Void run() { javaSecurityAccess.doIntersectionPrivilege(action, eventAcc); return null; } }, stack, srcAcc); } }
Example #4
Source File: XWindowPeer.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void recursivelySetIcon(java.util.List<IconInfo> icons) { dumpIcons(winAttr.icons); setIconHints(icons); Window target = (Window)this.target; Window[] children = target.getOwnedWindows(); int cnt = children.length; final ComponentAccessor acc = AWTAccessor.getComponentAccessor(); for (int i = 0; i < cnt; i++) { final ComponentPeer childPeer = acc.getPeer(children[i]); if (childPeer != null && childPeer instanceof XWindowPeer) { if (((XWindowPeer)childPeer).winAttr.iconsInherited) { ((XWindowPeer)childPeer).winAttr.icons = icons; ((XWindowPeer)childPeer).recursivelySetIcon(icons); } } } }
Example #5
Source File: XDialogPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
boolean isFocusedWindowModalBlocker() { Window focusedWindow = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow(); XWindowPeer focusedWindowPeer = null; if (focusedWindow != null) { focusedWindowPeer = (XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(focusedWindow); } else { /* * For the case when a potential blocked window is not yet focused * on the Java level (e.g. it's just been mapped) we're asking for the * focused window on the native level. */ focusedWindowPeer = getNativeFocusedWindowPeer(); } synchronized (getStateLock()) { if (focusedWindowPeer != null && focusedWindowPeer.modalBlocker == target) { return true; } } return super.isFocusedWindowModalBlocker(); }
Example #6
Source File: BasicComboPopup.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Creates the JList used in the popup to display * the items in the combo box model. This method is called when the UI class * is created. * * @return a <code>JList</code> used to display the combo box items */ protected JList createList() { return new JList( comboBox.getModel() ) { public void processMouseEvent(MouseEvent e) { if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) { // Fix for 4234053. Filter out the Control Key from the list. // ie., don't allow CTRL key deselection. Toolkit toolkit = Toolkit.getDefaultToolkit(); MouseEvent newEvent = new MouseEvent( (Component)e.getSource(), e.getID(), e.getWhen(), e.getModifiers() ^ toolkit.getMenuShortcutKeyMask(), e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(newEvent, meAccessor.isCausedByTouchEvent(e)); e = newEvent; } super.processMouseEvent(e); } }; }
Example #7
Source File: XEmbeddingContainer.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
void forwardKeyEvent(long child, KeyEvent e) { byte[] bdata = AWTAccessor.getAWTEventAccessor().getBData(e); long data = Native.toData(bdata); if (data == 0) { return; } XKeyEvent ke = new XKeyEvent(data); ke.set_window(child); XToolkit.awtLock(); try { XlibWrapper.XSendEvent(XToolkit.getDisplay(), child, false, XConstants.NoEventMask, data); } finally { XToolkit.awtUnlock(); } XlibWrapper.unsafe.freeMemory(data); }
Example #8
Source File: BasicComboPopup.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Creates the JList used in the popup to display * the items in the combo box model. This method is called when the UI class * is created. * * @return a <code>JList</code> used to display the combo box items */ protected JList<Object> createList() { return new JList<Object>( comboBox.getModel() ) { public void processMouseEvent(MouseEvent e) { if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) { // Fix for 4234053. Filter out the Control Key from the list. // ie., don't allow CTRL key deselection. Toolkit toolkit = Toolkit.getDefaultToolkit(); MouseEvent newEvent = new MouseEvent( (Component)e.getSource(), e.getID(), e.getWhen(), e.getModifiersEx() ^ toolkit.getMenuShortcutKeyMaskEx(), e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(newEvent, meAccessor.isCausedByTouchEvent(e)); e = newEvent; } super.processMouseEvent(e); } }; }
Example #9
Source File: RepaintManager.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Validate all of the components that have been marked invalid. * @see #addInvalidComponent */ public void validateInvalidComponents() { final java.util.List<Component> ic; synchronized(this) { if (invalidComponents == null) { return; } ic = invalidComponents; invalidComponents = null; } int n = ic.size(); for(int i = 0; i < n; i++) { final Component c = ic.get(i); AccessControlContext stack = AccessController.getContext(); AccessControlContext acc = AWTAccessor.getComponentAccessor().getAccessControlContext(c); javaSecurityAccess.doIntersectionPrivilege( new PrivilegedAction<Void>() { public Void run() { c.validate(); return null; } }, stack, acc); } }
Example #10
Source File: XFileDialogPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * handle the selection event */ void handleSelection(String file) { int index = file.lastIndexOf(java.io.File.separatorChar); if (index == -1) { savedDir = this.dir; savedFile = file; } else { savedDir = file.substring(0, index+1); savedFile = file.substring(index+1); } String[] fileNames = fileList.getSelectedItems(); int filesNumber = (fileNames != null) ? fileNames.length : 0; File[] files = new File[filesNumber]; for (int i = 0; i < filesNumber; i++) { files[i] = new File(savedDir, fileNames[i]); } AWTAccessor.FileDialogAccessor fileDialogAccessor = AWTAccessor.getFileDialogAccessor(); fileDialogAccessor.setDirectory(target, savedDir); fileDialogAccessor.setFile(target, savedFile); fileDialogAccessor.setFiles(target, files); }
Example #11
Source File: XSystemTrayPeer.java From hottub with GNU General Public License v2.0 | 5 votes |
private void firePropertyChange(final String propertyName, final Object oldValue, final Object newValue) { Runnable runnable = new Runnable() { public void run() { AWTAccessor.getSystemTrayAccessor() .firePropertyChange(target, propertyName, oldValue, newValue); } }; invokeOnEachAppContext(runnable); }
Example #12
Source File: Autoscroller.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Starts the timer targeting the passed in component. */ private void start(JComponent c, MouseEvent e) { Point screenLocation = c.getLocationOnScreen(); if (component != c) { _stop(component); } component = c; event = new MouseEvent(component, e.getID(), e.getWhen(), e.getModifiers(), e.getX() + screenLocation.x, e.getY() + screenLocation.y, e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(event, meAccessor.isCausedByTouchEvent(e)); if (timer == null) { timer = new Timer(100, this); } if (!timer.isRunning()) { timer.start(); } }
Example #13
Source File: XPopupMenuPeer.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/************************************************ * * Access to target's fields * ************************************************/ //Fix for 6267144: PIT: Popup menu label is not shown, XToolkit Font getTargetFont() { if (popupMenuTarget == null) { return XWindow.getDefaultFont(); } return AWTAccessor.getMenuComponentAccessor() .getFont_NoClientCode(popupMenuTarget); }
Example #14
Source File: XWindowPeer.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private void updateShape() { // Shape shape = ((Window)target).getShape(); Shape shape = AWTAccessor.getWindowAccessor().getShape((Window)target); if (shape != null) { applyShape(Region.getInstance(shape, null)); } }
Example #15
Source File: XWindowPeer.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public void handleConfigureNotifyEvent(XEvent xev) { assert (SunToolkit.isAWTLockHeldByCurrentThread()); XConfigureEvent xe = xev.get_xconfigure(); if (insLog.isLoggable(PlatformLogger.Level.FINE)) { insLog.fine(xe.toString()); } checkIfOnNewScreen(toGlobal(new Rectangle(scaleDown(xe.get_x()), scaleDown(xe.get_y()), scaleDown(xe.get_width()), scaleDown(xe.get_height())))); Rectangle oldBounds = getBounds(); x = scaleDown(xe.get_x()); y = scaleDown(xe.get_y()); width = scaleDown(xe.get_width()); height = scaleDown(xe.get_height()); if (!getBounds().getSize().equals(oldBounds.getSize())) { AWTAccessor.getComponentAccessor().setSize(target, width, height); postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_RESIZED)); } if (!getBounds().getLocation().equals(oldBounds.getLocation())) { AWTAccessor.getComponentAccessor().setLocation(target, x, y); postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED)); } repositionSecurityWarning(); }
Example #16
Source File: XTextFieldPeer.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Override public void setTransferHandler(TransferHandler newHandler) { TransferHandler oldHandler = (TransferHandler) getClientProperty(AWTAccessor.getClientPropertyKeyAccessor() .getJComponent_TRANSFER_HANDLER()); putClientProperty(AWTAccessor.getClientPropertyKeyAccessor() .getJComponent_TRANSFER_HANDLER(), newHandler); firePropertyChange("transferHandler", oldHandler, newHandler); }
Example #17
Source File: WToolkit.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public void showOrHideTouchKeyboard(Component comp, AWTEvent e) { if (!(comp instanceof TextComponent) && !(comp instanceof JTextComponent)) { return; } if ((e instanceof MouseEvent) && isComponentValidForTouchKeyboard(comp)) { MouseEvent me = (MouseEvent) e; if (me.getID() == MouseEvent.MOUSE_PRESSED) { if (AWTAccessor.getMouseEventAccessor().isCausedByTouchEvent(me)) { compOnTouchDownEvent = new WeakReference<>(comp); } else { compOnMousePressedEvent = new WeakReference<>(comp); } } else if (me.getID() == MouseEvent.MOUSE_RELEASED) { if (AWTAccessor.getMouseEventAccessor().isCausedByTouchEvent(me)) { if (compOnTouchDownEvent.get() == comp) { showTouchKeyboard(true); } compOnTouchDownEvent = NULL_COMPONENT_WR; } else { if (compOnMousePressedEvent.get() == comp) { showTouchKeyboard(false); } compOnMousePressedEvent = NULL_COMPONENT_WR; } } } else if (e instanceof FocusEvent) { FocusEvent fe = (FocusEvent) e; if (fe.getID() == FocusEvent.FOCUS_LOST) { // Hide the touch keyboard, if not a text component gains focus. if (!isComponentValidForTouchKeyboard(fe.getOppositeComponent())) { hideTouchKeyboard(); } } } }
Example #18
Source File: XEmbedChildProxy.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public void addNotify() { synchronized(getTreeLock()) { if (AWTAccessor.getComponentAccessor().getPeer(this) == null) { AWTAccessor.getComponentAccessor(). setPeer(this,((XToolkit)Toolkit.getDefaultToolkit()).createEmbedProxy(this)); } super.addNotify(); } }
Example #19
Source File: XTextFieldPeer.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
XAWTTextField(String text, XComponentPeer xwin, Container parent) { super(text); this.xwin = xwin; setDoubleBuffered(true); setFocusable(false); AWTAccessor.getComponentAccessor().setParent(this,parent); setBackground(xwin.getPeerBackground()); setForeground(xwin.getPeerForeground()); setFont(xwin.getPeerFont()); setCaretPosition(0); addActionListener(this); addNotify(); }
Example #20
Source File: UIManager.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static void initialize() { Properties swingProps = loadSwingProperties(); initializeSystemDefaults(swingProps); initializeDefaultLAF(swingProps); initializeAuxiliaryLAFs(swingProps); initializeInstalledLAFs(swingProps); // Install Swing's PaintEventDispatcher if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) { sun.awt.PaintEventDispatcher.setPaintEventDispatcher( new SwingPaintEventDispatcher()); } // Install a hook that will be invoked if no one consumes the // KeyEvent. If the source isn't a JComponent this will process // key bindings, if the source is a JComponent it implies that // processKeyEvent was already invoked and thus no need to process // the bindings again, unless the Component is disabled, in which // case KeyEvents will no longer be dispatched to it so that we // handle it here. KeyboardFocusManager.getCurrentKeyboardFocusManager(). addKeyEventPostProcessor(new KeyEventPostProcessor() { public boolean postProcessKeyEvent(KeyEvent e) { Component c = e.getComponent(); if ((!(c instanceof JComponent) || (c != null && !c.isEnabled())) && JComponent.KeyboardState.shouldProcess(e) && SwingUtilities.processKeyBindings(e)) { e.consume(); return true; } return false; } }); AWTAccessor.getComponentAccessor(). setRequestFocusController(JComponent.focusController); }
Example #21
Source File: XGlobalCursorManager.java From hottub with GNU General Public License v2.0 | 5 votes |
static void setPData(Cursor c, long pData) { try { AWTAccessor.getCursorAccessor().setPData(c, pData); } catch (Exception e) { e.printStackTrace(); } }
Example #22
Source File: XMenuItemPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns true if item and all its parents are enabled * This function is used to fix * 6184485: Popup menu is not disabled on XToolkit even when calling setEnabled (false) */ boolean isTargetItemEnabled() { if (target == null) { return false; } return AWTAccessor.getMenuItemAccessor().isItemEnabled(target); }
Example #23
Source File: GtkFileDialogPeer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Called exclusively by the native C code. */ private void setFileInternal(String directory, String[] filenames) { AWTAccessor.FileDialogAccessor accessor = AWTAccessor .getFileDialogAccessor(); if (filenames == null) { accessor.setDirectory(fd, null); accessor.setFile(fd, null); accessor.setFiles(fd, null); } else { // Fix 6987233: add the trailing slash if it's absent String with_separator = directory; if (directory != null) { with_separator = directory.endsWith(File.separator) ? directory : (directory + File.separator); } accessor.setDirectory(fd, with_separator); accessor.setFile(fd, filenames[0]); int filesNumber = (filenames != null) ? filenames.length : 0; File[] files = new File[filesNumber]; for (int i = 0; i < filesNumber; i++) { files[i] = new File(directory, filenames[i]); } accessor.setFiles(fd, files); } }
Example #24
Source File: WFileDialogPeer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public void blockWindows(java.util.List<Window> toBlock) { for (Window w : toBlock) { WWindowPeer wp = (WWindowPeer)AWTAccessor.getComponentAccessor().getPeer(w); if (wp != null) { blockWindow(wp); } } }
Example #25
Source File: XTextAreaPeer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Override public void setTransferHandler(TransferHandler newHandler) { TransferHandler oldHandler = (TransferHandler) getClientProperty(AWTAccessor.getClientPropertyKeyAccessor() .getJComponent_TRANSFER_HANDLER()); putClientProperty(AWTAccessor.getClientPropertyKeyAccessor() .getJComponent_TRANSFER_HANDLER(), newHandler); firePropertyChange("transferHandler", oldHandler, newHandler); }
Example #26
Source File: XWindowPeer.java From jdk8u-jdk 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 #27
Source File: XSystemTrayPeer.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private void firePropertyChange(final String propertyName, final Object oldValue, final Object newValue) { Runnable runnable = new Runnable() { public void run() { AWTAccessor.getSystemTrayAccessor() .firePropertyChange(target, propertyName, oldValue, newValue); } }; invokeOnEachAppContext(runnable); }
Example #28
Source File: XWindowPeer.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private void removeFromTransientFors() { // the head of the chain of this window XWindowPeer thisChain = this; // the head of the current chain // nextTransientFor is always not null as this window is in the chain XWindowPeer otherChain = nextTransientFor; // the set of blockers in this chain: if this dialog blocks some other // modal dialogs, their blocked windows should stay in this dialog's chain Set<XWindowPeer> thisChainBlockers = new HashSet<XWindowPeer>(); thisChainBlockers.add(this); // current chain iterator in the order from next to prev XWindowPeer chainToSplit = prevTransientFor; while (chainToSplit != null) { XWindowPeer blocker = (XWindowPeer) AWTAccessor.getComponentAccessor().getPeer(chainToSplit.modalBlocker); if (thisChainBlockers.contains(blocker)) { // add to this dialog's chain setToplevelTransientFor(thisChain, chainToSplit, true, false); thisChain = chainToSplit; thisChainBlockers.add(chainToSplit); } else { // leave in the current chain setToplevelTransientFor(otherChain, chainToSplit, true, false); otherChain = chainToSplit; } chainToSplit = chainToSplit.prevTransientFor; } restoreTransientFor(thisChain); thisChain.prevTransientFor = null; restoreTransientFor(otherChain); otherChain.prevTransientFor = null; nextTransientFor = null; XToolkit.XSync(); }
Example #29
Source File: WTaskbarPeer.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public void setWindowIconBadge(Window window, final Image image) { WWindowPeer wp = AWTAccessor.getComponentAccessor().getPeer(window); if (wp != null) { int[] buffer = imageToArray(image); ShellFolder.invoke(() -> { setOverlayIcon(wp.getHWnd(), buffer, buffer != null ? image.getWidth(null) : 0, buffer != null ? image.getHeight(null) : 0); return null; }); } }
Example #30
Source File: WComponentPeer.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private void postPaintIfNecessary(int x, int y, int w, int h) { if ( !AWTAccessor.getComponentAccessor().getIgnoreRepaint( (Component) target) ) { PaintEvent event = PaintEventDispatcher.getPaintEventDispatcher(). createPaintEvent((Component)target, x, y, w, h); if (event != null) { postEvent(event); } } }