Java Code Examples for javax.swing.event.AncestorListener

The following examples show how to use javax.swing.event.AncestorListener. 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 want to check out the right sidebar which shows the related API usage.
Example 1
/**
 * Maps {@code JComponent.addAncestorListener(AncestorListener)}
 * through queue
 */
public void addAncestorListener(final AncestorListener ancestorListener) {
    runMapping(new MapVoidAction("addAncestorListener") {
        @Override
        public void map() {
            ((JComponent) getSource()).addAncestorListener(ancestorListener);
        }
    });
}
 
Example 2
/**
 * Maps {@code JComponent.removeAncestorListener(AncestorListener)}
 * through queue
 */
public void removeAncestorListener(final AncestorListener ancestorListener) {
    runMapping(new MapVoidAction("removeAncestorListener") {
        @Override
        public void map() {
            ((JComponent) getSource()).removeAncestorListener(ancestorListener);
        }
    });
}
 
Example 3
Source Project: consulo   Source File: ExpandableSupport.java    License: Apache License 2.0 5 votes vote down vote up
public ExpandableSupport(@Nonnull Source source, Function<? super String, String> onShow, Function<? super String, String> onHide) {
  this.source = source;
  this.onShow = onShow != null ? onShow : Function.ID;
  this.onHide = onHide != null ? onHide : Function.ID;
  source.putClientProperty(Expandable.class, this);
  source.addAncestorListener(create(AncestorListener.class, this, "collapse"));
  source.addComponentListener(create(ComponentListener.class, this, "collapse"));
}
 
Example 4
Source Project: netbeans   Source File: HtmlRendererImpl.java    License: Apache License 2.0 4 votes vote down vote up
/** Overridden to do nothing for performance reasons */
public @Override void addAncestorListener(AncestorListener l) {
    if (swingRendering || !cellRenderer) {
        super.addAncestorListener(l);
    }
}
 
Example 5
Source Project: netbeans   Source File: FindInQuerySupport.java    License: Apache License 2.0 4 votes vote down vote up
public AncestorListener getAncestorListener() {
    return ancestorListener;
}
 
Example 6
Source Project: seaglass   Source File: WindowUtils.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Installs a {@link WindowFocusListener} on the given {@link JComponent}'s
 * parent {@link Window}. If the {@code JComponent} doesn't yet have a
 * parent, then the listener will be installed when the component is added
 * to a container.
 *
 * @param component     the component who's parent frame to listen to focus
 *                      changes on.
 * @param focusListener the {@code WindowFocusListener} to notify when focus
 *                      changes.
 */
public static void installWeakWindowFocusListener(JComponent component, WindowFocusListener focusListener) {
    WindowListener   weakFocusListener = createWeakWindowFocusListener(focusListener);
    AncestorListener ancestorListener  = createAncestorListener(component, weakFocusListener);

    component.addAncestorListener(ancestorListener);
}
 
Example 7
Source Project: seaglass   Source File: WindowUtils.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Installs a listener on the given {@link JComponent}'s parent
 * {@link Window} that repaints the given component when the parent window's
 * focused state changes. If the given component does not have a parent at
 * the time this method is called, then an ancestor listener will be
 * installed that installs a window listener when the components parent
 * changes.
 *
 * @param component the {@code JComponent} to add the repaint focus listener
 *                  to.
 */
public static void installJComponentRepainterOnWindowFocusChanged(JComponent component) {
    // TODO check to see if the component already has an ancestor.
    WindowListener   windowListener   = createWeakWindowFocusListener(createRepaintWindowListener(component));
    AncestorListener ancestorListener = createAncestorListener(component, windowListener);

    component.addAncestorListener(ancestorListener);
}