Java Code Examples for java.awt.Component#getTreeLock()
The following examples show how to use
java.awt.Component#getTreeLock() .
These examples are extracted from open source projects.
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 Project: consulo File: VerticalLayout.java License: Apache License 2.0 | 6 votes |
@Override public void addLayoutComponent(String name, Component component) { synchronized (component.getTreeLock()) { if (name == null || TOP.equalsIgnoreCase(name)) { myTop.add(component); } else if (CENTER.equalsIgnoreCase(name)) { myCenter.add(component); } else if (BOTTOM.equalsIgnoreCase(name)) { myBottom.add(component); } else { throw new IllegalArgumentException("unsupported name: " + name); } } }
Example 2
Source Project: visualvm File: CrossBorderLayout.java License: GNU General Public License v2.0 | 6 votes |
public void removeLayoutComponent(Component comp) { synchronized (comp.getTreeLock()) { if (comp == center) { center = null; map.remove(center); } else if (comp == north) { north = null; map.remove(north); } else if (comp == south) { south = null; map.remove(south); } else if (comp == east) { east = null; map.remove(east); } else if (comp == west) { west = null; map.remove(west); } } }
Example 3
Source Project: netbeans File: CrossBorderLayout.java License: Apache License 2.0 | 6 votes |
public void removeLayoutComponent(Component comp) { synchronized (comp.getTreeLock()) { if (comp == center) { center = null; map.remove(center); } else if (comp == north) { north = null; map.remove(north); } else if (comp == south) { south = null; map.remove(south); } else if (comp == east) { east = null; map.remove(east); } else if (comp == west) { west = null; map.remove(west); } } }
Example 4
Source Project: consulo File: HorizontalLayout.java License: Apache License 2.0 | 6 votes |
@Override public void addLayoutComponent(String name, Component component) { synchronized (component.getTreeLock()) { if (name == null || LEFT.equalsIgnoreCase(name)) { myLeft.add(component); } else if (CENTER.equalsIgnoreCase(name)) { myCenter.add(component); } else if (RIGHT.equalsIgnoreCase(name)) { myRight.add(component); } else { throw new IllegalArgumentException("unsupported name: " + name); } } }
Example 5
Source Project: hottub File: InputContext.java License: GNU General Public License v2.0 | 5 votes |
/** * Handles focus lost events for any component that's using * this input context. * These events are generated by AWT when the keyboard focus * moves away from a component. * Besides actual client components, the source components * may also be the composition area or any component in an * input method window. * * @param source the component losing the focus * @isTemporary whether the focus change is temporary */ private void focusLost(Component source, boolean isTemporary) { // see the note on synchronization in focusGained synchronized (source.getTreeLock()) { synchronized (this) { // We need to suppress deactivation if removeNotify has been called earlier. // This is indicated by isInputMethodActive == false. if (isInputMethodActive) { deactivateInputMethod(isTemporary); } awtFocussedComponent = null; if (inputMethod instanceof InputMethodAdapter) { ((InputMethodAdapter) inputMethod).setAWTFocussedComponent(null); } // hides the composition area if currently it is visible InputMethodContext inputContext = ((InputMethodContext)this); if (inputContext.isCompositionAreaVisible()) { inputContext.setCompositionAreaVisible(false); compositionAreaHidden = true; } } } }
Example 6
Source Project: jdk8u-dev-jdk File: InputContext.java License: GNU General Public License v2.0 | 5 votes |
/** * Handles focus lost events for any component that's using * this input context. * These events are generated by AWT when the keyboard focus * moves away from a component. * Besides actual client components, the source components * may also be the composition area or any component in an * input method window. * * @param source the component losing the focus * @isTemporary whether the focus change is temporary */ private void focusLost(Component source, boolean isTemporary) { // see the note on synchronization in focusGained synchronized (source.getTreeLock()) { synchronized (this) { // We need to suppress deactivation if removeNotify has been called earlier. // This is indicated by isInputMethodActive == false. if (isInputMethodActive) { deactivateInputMethod(isTemporary); } awtFocussedComponent = null; if (inputMethod instanceof InputMethodAdapter) { ((InputMethodAdapter) inputMethod).setAWTFocussedComponent(null); } // hides the composition area if currently it is visible InputMethodContext inputContext = ((InputMethodContext)this); if (inputContext.isCompositionAreaVisible()) { inputContext.setCompositionAreaVisible(false); compositionAreaHidden = true; } } } }
Example 7
Source Project: oim-fx File: LineLayout.java License: MIT License | 5 votes |
@Override public void removeLayoutComponent(Component comp) { synchronized (comp.getTreeLock()) { if (middleComponent == comp) { middleComponent = null; } else { startComponents.remove(comp); endComponents.remove(comp); } fillComponents.remove(comp); } }
Example 8
Source Project: Bytecoder File: InputContext.java License: Apache License 2.0 | 5 votes |
/** * Handles focus lost events for any component that's using * this input context. * These events are generated by AWT when the keyboard focus * moves away from a component. * Besides actual client components, the source components * may also be the composition area or any component in an * input method window. * * @param source the component losing the focus * @isTemporary whether the focus change is temporary */ private void focusLost(Component source, boolean isTemporary) { // see the note on synchronization in focusGained synchronized (source.getTreeLock()) { synchronized (this) { // We need to suppress deactivation if removeNotify has been called earlier. // This is indicated by isInputMethodActive == false. if (isInputMethodActive) { deactivateInputMethod(isTemporary); } awtFocussedComponent = null; if (inputMethod instanceof InputMethodAdapter) { ((InputMethodAdapter) inputMethod).setAWTFocussedComponent(null); } // hides the composition area if currently it is visible InputMethodContext inputContext = ((InputMethodContext)this); if (inputContext.isCompositionAreaVisible()) { inputContext.setCompositionAreaVisible(false); compositionAreaHidden = true; } } } }
Example 9
Source Project: openjdk-jdk9 File: InputContext.java License: GNU General Public License v2.0 | 5 votes |
/** * Handles focus lost events for any component that's using * this input context. * These events are generated by AWT when the keyboard focus * moves away from a component. * Besides actual client components, the source components * may also be the composition area or any component in an * input method window. * * @param source the component losing the focus * @isTemporary whether the focus change is temporary */ private void focusLost(Component source, boolean isTemporary) { // see the note on synchronization in focusGained synchronized (source.getTreeLock()) { synchronized (this) { // We need to suppress deactivation if removeNotify has been called earlier. // This is indicated by isInputMethodActive == false. if (isInputMethodActive) { deactivateInputMethod(isTemporary); } awtFocussedComponent = null; if (inputMethod instanceof InputMethodAdapter) { ((InputMethodAdapter) inputMethod).setAWTFocussedComponent(null); } // hides the composition area if currently it is visible InputMethodContext inputContext = ((InputMethodContext)this); if (inputContext.isCompositionAreaVisible()) { inputContext.setCompositionAreaVisible(false); compositionAreaHidden = true; } } } }
Example 10
Source Project: lizzie File: LizzieLayout.java License: GNU General Public License v3.0 | 5 votes |
public void removeLayoutComponent(Component comp) { synchronized (comp.getTreeLock()) { if (comp == north) { north = null; } else if (comp == south) { south = null; } else if (comp == east) { east = null; } else if (comp == west) { west = null; } else if (comp == basicInfoPane) { basicInfoPane = null; } else if (comp == mainBoard) { mainBoard = null; } else if (comp == variationPane) { variationPane = null; } else if (comp == winratePane) { winratePane = null; } else if (comp == subBoard) { subBoard = null; } if (comp == commentPane) { commentPane = null; } else if (comp == consolePane) { consolePane = null; } } }
Example 11
Source Project: workcraft File: MultiBorderLayout.java License: MIT License | 5 votes |
@Override public void removeLayoutComponent(final Component comp) { synchronized (comp.getTreeLock()) { northList.remove(comp); southList.remove(comp); westList.remove(comp); eastList.remove(comp); centerList.remove(comp); } }
Example 12
Source Project: pdfxtk File: BorderLayout.java License: Apache License 2.0 | 5 votes |
public void addLayoutComponent(String name, Component comp) { super.addLayoutComponent(name, comp); synchronized (comp.getTreeLock()) { /* Special case: treat null the same as "Center". */ if (name == null) { name = CENTER; } /* Assign the component to one of the known regions of the layout. */ if (CENTER.equals(name)) center = comp; else if (NORTH.equals(name)) north = comp; else if (SOUTH.equals(name)) south = comp; else if (EAST.equals(name)) east = comp; else if (WEST.equals(name)) west = comp; else if (BEFORE_FIRST_LINE.equals(name)) firstLine = comp; else if (AFTER_LAST_LINE.equals(name)) lastLine = comp; else if (BEFORE_LINE_BEGINS.equals(name)) firstItem = comp; else if (AFTER_LINE_ENDS.equals(name)) lastItem = comp; } }
Example 13
Source Project: openjdk-jdk8u-backup File: InputContext.java License: GNU General Public License v2.0 | 5 votes |
/** * Handles focus lost events for any component that's using * this input context. * These events are generated by AWT when the keyboard focus * moves away from a component. * Besides actual client components, the source components * may also be the composition area or any component in an * input method window. * * @param source the component losing the focus * @isTemporary whether the focus change is temporary */ private void focusLost(Component source, boolean isTemporary) { // see the note on synchronization in focusGained synchronized (source.getTreeLock()) { synchronized (this) { // We need to suppress deactivation if removeNotify has been called earlier. // This is indicated by isInputMethodActive == false. if (isInputMethodActive) { deactivateInputMethod(isTemporary); } awtFocussedComponent = null; if (inputMethod instanceof InputMethodAdapter) { ((InputMethodAdapter) inputMethod).setAWTFocussedComponent(null); } // hides the composition area if currently it is visible InputMethodContext inputContext = ((InputMethodContext)this); if (inputContext.isCompositionAreaVisible()) { inputContext.setCompositionAreaVisible(false); compositionAreaHidden = true; } } } }
Example 14
Source Project: jdk8u_jdk File: InputContext.java License: GNU General Public License v2.0 | 5 votes |
/** * Handles focus lost events for any component that's using * this input context. * These events are generated by AWT when the keyboard focus * moves away from a component. * Besides actual client components, the source components * may also be the composition area or any component in an * input method window. * * @param source the component losing the focus * @isTemporary whether the focus change is temporary */ private void focusLost(Component source, boolean isTemporary) { // see the note on synchronization in focusGained synchronized (source.getTreeLock()) { synchronized (this) { // We need to suppress deactivation if removeNotify has been called earlier. // This is indicated by isInputMethodActive == false. if (isInputMethodActive) { deactivateInputMethod(isTemporary); } awtFocussedComponent = null; if (inputMethod instanceof InputMethodAdapter) { ((InputMethodAdapter) inputMethod).setAWTFocussedComponent(null); } // hides the composition area if currently it is visible InputMethodContext inputContext = ((InputMethodContext)this); if (inputContext.isCompositionAreaVisible()) { inputContext.setCompositionAreaVisible(false); compositionAreaHidden = true; } } } }
Example 15
Source Project: dragonwell8_jdk File: InputContext.java License: GNU General Public License v2.0 | 4 votes |
/** * Handles focus gained events for any component that's using * this input context. * These events are generated by AWT when the keyboard focus * moves to a component. * Besides actual client components, the source components * may also be the composition area or any component in an * input method window. * <p> * When handling the focus event for a client component, this * method checks whether the input context was previously * active for a different client component, and if so, calls * endComposition for the previous client component. * * @param source the component gaining the focus */ private void focusGained(Component source) { /* * NOTE: When a Container is removing its Component which * invokes this.removeNotify(), the Container has the global * Component lock. It is possible to happen that an * application thread is calling this.removeNotify() while an * AWT event queue thread is dispatching a focus event via * this.dispatchEvent(). If an input method uses AWT * components (e.g., IIIMP status window), it causes deadlock, * for example, Component.show()/hide() in this situation * because hide/show tried to obtain the lock. Therefore, * it's necessary to obtain the global Component lock before * activating or deactivating an input method. */ synchronized (source.getTreeLock()) { synchronized (this) { if ("sun.awt.im.CompositionArea".equals(source.getClass().getName())) { // no special handling for this one } else if (getComponentWindow(source) instanceof InputMethodWindow) { // no special handling for this one either } else { if (!source.isDisplayable()) { // Component is being disposed return; } // Focus went to a real client component. // Check whether we're switching between client components // that share an input context. We can't do that earlier // than here because we don't want to end composition // until we really know we're switching to a different component if (inputMethod != null) { if (currentClientComponent != null && currentClientComponent != source) { if (!isInputMethodActive) { activateInputMethod(false); } endComposition(); deactivateInputMethod(false); } } currentClientComponent = source; } awtFocussedComponent = source; if (inputMethod instanceof InputMethodAdapter) { ((InputMethodAdapter) inputMethod).setAWTFocussedComponent(source); } // it's possible that the input method is still active because // we suppressed a deactivate cause by an input method window // coming up if (!isInputMethodActive) { activateInputMethod(true); } // If the client component is an active client with the below-the-spot // input style, then make the composition window undecorated without a title bar. InputMethodContext inputContext = ((InputMethodContext)this); if (!inputContext.isCompositionAreaVisible()) { InputMethodRequests req = source.getInputMethodRequests(); if (req != null && inputContext.useBelowTheSpotInput()) { inputContext.setCompositionAreaUndecorated(true); } else { inputContext.setCompositionAreaUndecorated(false); } } // restores the composition area if it was set to invisible // when focus got lost if (compositionAreaHidden == true) { ((InputMethodContext)this).setCompositionAreaVisible(true); compositionAreaHidden = false; } } } }
Example 16
Source Project: openjdk-jdk9 File: InputContext.java License: GNU General Public License v2.0 | 4 votes |
/** * Handles focus gained events for any component that's using * this input context. * These events are generated by AWT when the keyboard focus * moves to a component. * Besides actual client components, the source components * may also be the composition area or any component in an * input method window. * <p> * When handling the focus event for a client component, this * method checks whether the input context was previously * active for a different client component, and if so, calls * endComposition for the previous client component. * * @param source the component gaining the focus */ private void focusGained(Component source) { /* * NOTE: When a Container is removing its Component which * invokes this.removeNotify(), the Container has the global * Component lock. It is possible to happen that an * application thread is calling this.removeNotify() while an * AWT event queue thread is dispatching a focus event via * this.dispatchEvent(). If an input method uses AWT * components (e.g., IIIMP status window), it causes deadlock, * for example, Component.show()/hide() in this situation * because hide/show tried to obtain the lock. Therefore, * it's necessary to obtain the global Component lock before * activating or deactivating an input method. */ synchronized (source.getTreeLock()) { synchronized (this) { if ("sun.awt.im.CompositionArea".equals(source.getClass().getName())) { // no special handling for this one } else if (getComponentWindow(source) instanceof InputMethodWindow) { // no special handling for this one either } else { if (!source.isDisplayable()) { // Component is being disposed return; } // Focus went to a real client component. // Check whether we're switching between client components // that share an input context. We can't do that earlier // than here because we don't want to end composition // until we really know we're switching to a different component if (inputMethod != null) { if (currentClientComponent != null && currentClientComponent != source) { if (!isInputMethodActive) { activateInputMethod(false); } endComposition(); deactivateInputMethod(false); } } currentClientComponent = source; } awtFocussedComponent = source; if (inputMethod instanceof InputMethodAdapter) { ((InputMethodAdapter) inputMethod).setAWTFocussedComponent(source); } // it's possible that the input method is still active because // we suppressed a deactivate cause by an input method window // coming up if (!isInputMethodActive) { activateInputMethod(true); } // If the client component is an active client with the below-the-spot // input style, then make the composition window undecorated without a title bar. InputMethodContext inputContext = ((InputMethodContext)this); if (!inputContext.isCompositionAreaVisible()) { InputMethodRequests req = source.getInputMethodRequests(); if (req != null && inputContext.useBelowTheSpotInput()) { inputContext.setCompositionAreaUndecorated(true); } else { inputContext.setCompositionAreaUndecorated(false); } } // restores the composition area if it was set to invisible // when focus got lost if (compositionAreaHidden == true) { ((InputMethodContext)this).setCompositionAreaVisible(true); compositionAreaHidden = false; } } } }
Example 17
Source Project: openjdk-8 File: InputContext.java License: GNU General Public License v2.0 | 4 votes |
/** * Handles focus gained events for any component that's using * this input context. * These events are generated by AWT when the keyboard focus * moves to a component. * Besides actual client components, the source components * may also be the composition area or any component in an * input method window. * <p> * When handling the focus event for a client component, this * method checks whether the input context was previously * active for a different client component, and if so, calls * endComposition for the previous client component. * * @param source the component gaining the focus */ private void focusGained(Component source) { /* * NOTE: When a Container is removing its Component which * invokes this.removeNotify(), the Container has the global * Component lock. It is possible to happen that an * application thread is calling this.removeNotify() while an * AWT event queue thread is dispatching a focus event via * this.dispatchEvent(). If an input method uses AWT * components (e.g., IIIMP status window), it causes deadlock, * for example, Component.show()/hide() in this situation * because hide/show tried to obtain the lock. Therefore, * it's necessary to obtain the global Component lock before * activating or deactivating an input method. */ synchronized (source.getTreeLock()) { synchronized (this) { if ("sun.awt.im.CompositionArea".equals(source.getClass().getName())) { // no special handling for this one } else if (getComponentWindow(source) instanceof InputMethodWindow) { // no special handling for this one either } else { if (!source.isDisplayable()) { // Component is being disposed return; } // Focus went to a real client component. // Check whether we're switching between client components // that share an input context. We can't do that earlier // than here because we don't want to end composition // until we really know we're switching to a different component if (inputMethod != null) { if (currentClientComponent != null && currentClientComponent != source) { if (!isInputMethodActive) { activateInputMethod(false); } endComposition(); deactivateInputMethod(false); } } currentClientComponent = source; } awtFocussedComponent = source; if (inputMethod instanceof InputMethodAdapter) { ((InputMethodAdapter) inputMethod).setAWTFocussedComponent(source); } // it's possible that the input method is still active because // we suppressed a deactivate cause by an input method window // coming up if (!isInputMethodActive) { activateInputMethod(true); } // If the client component is an active client with the below-the-spot // input style, then make the composition window undecorated without a title bar. InputMethodContext inputContext = ((InputMethodContext)this); if (!inputContext.isCompositionAreaVisible()) { InputMethodRequests req = source.getInputMethodRequests(); if (req != null && inputContext.useBelowTheSpotInput()) { inputContext.setCompositionAreaUndecorated(true); } else { inputContext.setCompositionAreaUndecorated(false); } } // restores the composition area if it was set to invisible // when focus got lost if (compositionAreaHidden == true) { ((InputMethodContext)this).setCompositionAreaVisible(true); compositionAreaHidden = false; } } } }
Example 18
Source Project: jdk8u-jdk File: InputContext.java License: GNU General Public License v2.0 | 4 votes |
/** * Handles focus gained events for any component that's using * this input context. * These events are generated by AWT when the keyboard focus * moves to a component. * Besides actual client components, the source components * may also be the composition area or any component in an * input method window. * <p> * When handling the focus event for a client component, this * method checks whether the input context was previously * active for a different client component, and if so, calls * endComposition for the previous client component. * * @param source the component gaining the focus */ private void focusGained(Component source) { /* * NOTE: When a Container is removing its Component which * invokes this.removeNotify(), the Container has the global * Component lock. It is possible to happen that an * application thread is calling this.removeNotify() while an * AWT event queue thread is dispatching a focus event via * this.dispatchEvent(). If an input method uses AWT * components (e.g., IIIMP status window), it causes deadlock, * for example, Component.show()/hide() in this situation * because hide/show tried to obtain the lock. Therefore, * it's necessary to obtain the global Component lock before * activating or deactivating an input method. */ synchronized (source.getTreeLock()) { synchronized (this) { if ("sun.awt.im.CompositionArea".equals(source.getClass().getName())) { // no special handling for this one } else if (getComponentWindow(source) instanceof InputMethodWindow) { // no special handling for this one either } else { if (!source.isDisplayable()) { // Component is being disposed return; } // Focus went to a real client component. // Check whether we're switching between client components // that share an input context. We can't do that earlier // than here because we don't want to end composition // until we really know we're switching to a different component if (inputMethod != null) { if (currentClientComponent != null && currentClientComponent != source) { if (!isInputMethodActive) { activateInputMethod(false); } endComposition(); deactivateInputMethod(false); } } currentClientComponent = source; } awtFocussedComponent = source; if (inputMethod instanceof InputMethodAdapter) { ((InputMethodAdapter) inputMethod).setAWTFocussedComponent(source); } // it's possible that the input method is still active because // we suppressed a deactivate cause by an input method window // coming up if (!isInputMethodActive) { activateInputMethod(true); } // If the client component is an active client with the below-the-spot // input style, then make the composition window undecorated without a title bar. InputMethodContext inputContext = ((InputMethodContext)this); if (!inputContext.isCompositionAreaVisible()) { InputMethodRequests req = source.getInputMethodRequests(); if (req != null && inputContext.useBelowTheSpotInput()) { inputContext.setCompositionAreaUndecorated(true); } else { inputContext.setCompositionAreaUndecorated(false); } } // restores the composition area if it was set to invisible // when focus got lost if (compositionAreaHidden == true) { ((InputMethodContext)this).setCompositionAreaVisible(true); compositionAreaHidden = false; } } } }
Example 19
Source Project: WorldPainter File: AKDockLayout.java License: GNU General Public License v3.0 | 2 votes |
@Override public void addLayoutComponent(Component c, Object con) { synchronized (c.getTreeLock()) { if (con != null) { String s = con.toString(); switch (s) { case NORTH: north.add(c); break; case SOUTH: south.add(c); break; case EAST: east.add(c); break; case WEST: west.add(c); break; case CENTER: center = c; break; } c.getParent().validate(); } } }
Example 20
Source Project: filthy-rich-clients File: StackLayout.java License: BSD 3-Clause "New" or "Revised" License | votes |
public void addLayoutComponent(Component comp, Object constraints) { synchronized (comp.getTreeLock()) { if (BOTTOM.equals(constraints)) { components.add(0, comp); } else if (TOP.equals(constraints)) { components.add(comp); } else { components.add(comp); } } }