javax.swing.event.AncestorListener Java Examples

The following examples show how to use javax.swing.event.AncestorListener. 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: JComponentOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
Source File: JComponentOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 File: ExpandableSupport.java    From consulo with 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 File: HtmlRendererImpl.java    From netbeans with 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 File: FindInQuerySupport.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public AncestorListener getAncestorListener() {
    return ancestorListener;
}
 
Example #6
Source File: WindowUtils.java    From seaglass with 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 File: WindowUtils.java    From seaglass with 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);
}