Java Code Examples for java.awt.Component#addComponentListener()

The following examples show how to use java.awt.Component#addComponentListener() . 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: AncestorNotifier.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
void addListeners(Component ancestor, boolean addToFirst) {
    Component a;

    firstInvisibleAncestor = null;
    for (a = ancestor;
         firstInvisibleAncestor == null;
         a = a.getParent()) {
        if (addToFirst || a != ancestor) {
            a.addComponentListener(this);

            if (a instanceof JComponent) {
                JComponent jAncestor = (JComponent)a;

                jAncestor.addPropertyChangeListener(this);
            }
        }
        if (!a.isVisible() || a.getParent() == null || a instanceof Window) {
            firstInvisibleAncestor = a;
        }
    }
    if (firstInvisibleAncestor instanceof Window &&
        firstInvisibleAncestor.isVisible()) {
        firstInvisibleAncestor = null;
    }
}
 
Example 2
Source File: AncestorNotifier.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
void addListeners(Component ancestor, boolean addToFirst) {
    Component a;

    firstInvisibleAncestor = null;
    for (a = ancestor;
         firstInvisibleAncestor == null;
         a = a.getParent()) {
        if (addToFirst || a != ancestor) {
            a.addComponentListener(this);

            if (a instanceof JComponent) {
                JComponent jAncestor = (JComponent)a;

                jAncestor.addPropertyChangeListener(this);
            }
        }
        if (!a.isVisible() || a.getParent() == null || a instanceof Window) {
            firstInvisibleAncestor = a;
        }
    }
    if (firstInvisibleAncestor instanceof Window &&
        firstInvisibleAncestor.isVisible()) {
        firstInvisibleAncestor = null;
    }
}
 
Example 3
Source File: AncestorNotifier.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
void addListeners(Component ancestor, boolean addToFirst) {
    Component a;

    firstInvisibleAncestor = null;
    for (a = ancestor;
         firstInvisibleAncestor == null;
         a = a.getParent()) {
        if (addToFirst || a != ancestor) {
            a.addComponentListener(this);

            if (a instanceof JComponent) {
                JComponent jAncestor = (JComponent)a;

                jAncestor.addPropertyChangeListener(this);
            }
        }
        if (!a.isVisible() || a.getParent() == null || a instanceof Window) {
            firstInvisibleAncestor = a;
        }
    }
    if (firstInvisibleAncestor instanceof Window &&
        firstInvisibleAncestor.isVisible()) {
        firstInvisibleAncestor = null;
    }
}
 
Example 4
Source File: AncestorNotifier.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
void addListeners(Component ancestor, boolean addToFirst) {
    Component a;

    firstInvisibleAncestor = null;
    for (a = ancestor;
         firstInvisibleAncestor == null;
         a = a.getParent()) {
        if (addToFirst || a != ancestor) {
            a.addComponentListener(this);

            if (a instanceof JComponent) {
                JComponent jAncestor = (JComponent)a;

                jAncestor.addPropertyChangeListener(this);
            }
        }
        if (!a.isVisible() || a.getParent() == null || a instanceof Window) {
            firstInvisibleAncestor = a;
        }
    }
    if (firstInvisibleAncestor instanceof Window &&
        firstInvisibleAncestor.isVisible()) {
        firstInvisibleAncestor = null;
    }
}
 
Example 5
Source File: AncestorNotifier.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
void addListeners(Component ancestor, boolean addToFirst) {
    Component a;

    firstInvisibleAncestor = null;
    for (a = ancestor;
         firstInvisibleAncestor == null;
         a = a.getParent()) {
        if (addToFirst || a != ancestor) {
            a.addComponentListener(this);

            if (a instanceof JComponent) {
                JComponent jAncestor = (JComponent)a;

                jAncestor.addPropertyChangeListener(this);
            }
        }
        if (!a.isVisible() || a.getParent() == null || a instanceof Window) {
            firstInvisibleAncestor = a;
        }
    }
    if (firstInvisibleAncestor instanceof Window &&
        firstInvisibleAncestor.isVisible()) {
        firstInvisibleAncestor = null;
    }
}
 
Example 6
Source File: ComponentShowingButton.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the component to be shown.
 * @param component the component to be shown.
 * @param parent the container to which the shown component should be added.
 *               This parameter can be null if you add the component yourself.
 */
public void setComponent(Component component) {
    this.component = component;
    if (null != component) {
        component.addComponentListener(new ComponentAdapter() {

            @Override
            public void componentHidden(ComponentEvent e) {
                if (null != unselectButton && isSelected()) {
                    unselectButton.setSelected(true);
                }
            }
            
        });
    }
}
 
Example 7
Source File: AncestorNotifier.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
void addListeners(Component ancestor, boolean addToFirst) {
    Component a;

    firstInvisibleAncestor = null;
    for (a = ancestor;
         firstInvisibleAncestor == null;
         a = a.getParent()) {
        if (addToFirst || a != ancestor) {
            a.addComponentListener(this);

            if (a instanceof JComponent) {
                JComponent jAncestor = (JComponent)a;

                jAncestor.addPropertyChangeListener(this);
            }
        }
        if (!a.isVisible() || a.getParent() == null || a instanceof Window) {
            firstInvisibleAncestor = a;
        }
    }
    if (firstInvisibleAncestor instanceof Window &&
        firstInvisibleAncestor.isVisible()) {
        firstInvisibleAncestor = null;
    }
}
 
Example 8
Source File: AncestorNotifier.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
void addListeners(Component ancestor, boolean addToFirst) {
    Component a;

    firstInvisibleAncestor = null;
    for (a = ancestor;
         firstInvisibleAncestor == null;
         a = a.getParent()) {
        if (addToFirst || a != ancestor) {
            a.addComponentListener(this);

            if (a instanceof JComponent) {
                JComponent jAncestor = (JComponent)a;

                jAncestor.addPropertyChangeListener(this);
            }
        }
        if (!a.isVisible() || a.getParent() == null || a instanceof Window) {
            firstInvisibleAncestor = a;
        }
    }
    if (firstInvisibleAncestor instanceof Window &&
        firstInvisibleAncestor.isVisible()) {
        firstInvisibleAncestor = null;
    }
}
 
Example 9
Source File: AncestorNotifier.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
void addListeners(Component ancestor, boolean addToFirst) {
    Component a;

    firstInvisibleAncestor = null;
    for (a = ancestor;
         firstInvisibleAncestor == null;
         a = a.getParent()) {
        if (addToFirst || a != ancestor) {
            a.addComponentListener(this);

            if (a instanceof JComponent) {
                JComponent jAncestor = (JComponent)a;

                jAncestor.addPropertyChangeListener(this);
            }
        }
        if (!a.isVisible() || a.getParent() == null || a instanceof Window) {
            firstInvisibleAncestor = a;
        }
    }
    if (firstInvisibleAncestor instanceof Window &&
        firstInvisibleAncestor.isVisible()) {
        firstInvisibleAncestor = null;
    }
}
 
Example 10
Source File: AncestorNotifier.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
void addListeners(Component ancestor, boolean addToFirst) {
    Component a;

    firstInvisibleAncestor = null;
    for (a = ancestor;
         firstInvisibleAncestor == null;
         a = a.getParent()) {
        if (addToFirst || a != ancestor) {
            a.addComponentListener(this);

            if (a instanceof JComponent) {
                JComponent jAncestor = (JComponent)a;

                jAncestor.addPropertyChangeListener(this);
            }
        }
        if (!a.isVisible() || a.getParent() == null || a instanceof Window) {
            firstInvisibleAncestor = a;
        }
    }
    if (firstInvisibleAncestor instanceof Window &&
        firstInvisibleAncestor.isVisible()) {
        firstInvisibleAncestor = null;
    }
}
 
Example 11
Source File: AncestorNotifier.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
void addListeners(Component ancestor, boolean addToFirst) {
    Component a;

    firstInvisibleAncestor = null;
    for (a = ancestor;
         firstInvisibleAncestor == null;
         a = a.getParent()) {
        if (addToFirst || a != ancestor) {
            a.addComponentListener(this);

            if (a instanceof JComponent) {
                JComponent jAncestor = (JComponent)a;

                jAncestor.addPropertyChangeListener(this);
            }
        }
        if (!a.isVisible() || a.getParent() == null || a instanceof Window) {
            firstInvisibleAncestor = a;
        }
    }
    if (firstInvisibleAncestor instanceof Window &&
        firstInvisibleAncestor.isVisible()) {
        firstInvisibleAncestor = null;
    }
}
 
Example 12
Source File: AncestorNotifier.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
void addListeners(Component ancestor, boolean addToFirst) {
    Component a;

    firstInvisibleAncestor = null;
    for (a = ancestor;
         firstInvisibleAncestor == null;
         a = a.getParent()) {
        if (addToFirst || a != ancestor) {
            a.addComponentListener(this);

            if (a instanceof JComponent) {
                JComponent jAncestor = (JComponent)a;

                jAncestor.addPropertyChangeListener(this);
            }
        }
        if (!a.isVisible() || a.getParent() == null || a instanceof Window) {
            firstInvisibleAncestor = a;
        }
    }
    if (firstInvisibleAncestor instanceof Window &&
        firstInvisibleAncestor.isVisible()) {
        firstInvisibleAncestor = null;
    }
}
 
Example 13
Source File: SwingDialog.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void addNotify() {
    super.addNotify();
    final Component parent = SwingUtilities.getRoot(this);
    componentListener = new ComponentAdapter() {
        @Override
        public void componentMoved(ComponentEvent e) {
            hidePopUps();
            processComponentEvent(new ComponentEvent(JFXPanelEx.this, ComponentEvent.COMPONENT_MOVED));
        }

        @Override
        public void componentResized(ComponentEvent e) {
            hidePopUps();
            processComponentEvent(new ComponentEvent(JFXPanelEx.this, ComponentEvent.COMPONENT_RESIZED));
            processComponentEvent(new ComponentEvent(JFXPanelEx.this, ComponentEvent.COMPONENT_MOVED)); //is important!!!
        }
    };
    parent.addComponentListener(componentListener);
}
 
Example 14
Source File: AncestorNotifier.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
void addListeners(Component ancestor, boolean addToFirst) {
    Component a;

    firstInvisibleAncestor = null;
    for (a = ancestor;
         firstInvisibleAncestor == null;
         a = a.getParent()) {
        if (addToFirst || a != ancestor) {
            a.addComponentListener(this);

            if (a instanceof JComponent) {
                JComponent jAncestor = (JComponent)a;

                jAncestor.addPropertyChangeListener(this);
            }
        }
        if (!a.isVisible() || a.getParent() == null || a instanceof Window) {
            firstInvisibleAncestor = a;
        }
    }
    if (firstInvisibleAncestor instanceof Window &&
        firstInvisibleAncestor.isVisible()) {
        firstInvisibleAncestor = null;
    }
}
 
Example 15
Source File: DesktopScrollPane.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
private void onComponentAdded(ContainerEvent event) {
    Component addedComponent = event.getChild();
    if (addedComponent instanceof JInternalFrame)
    {
        addedComponent.addComponentListener(componentListener);
        resizeDesktop();
    }
}
 
Example 16
Source File: UIUtil.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void initTwoColumnTableVisualProperties(Component component, JTable table) {
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    table.setIntercellSpacing(new Dimension(0, 0));
    table.getParent().setBackground(table.getBackground());
    updateColumnWidths(table);
    component.addComponentListener(new TableColumnSizeComponentAdapter(table));
}
 
Example 17
Source File: JExtendedSplitPane.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void registerListeners(Component component) {
    if (splitPaneComponentListener != null) {
        component.addComponentListener(splitPaneComponentListener);
    }

    if (splitPaneActionListener != null) {
        if (component instanceof JTitledPanel) {
            ((JTitledPanel) component).addActionListener(splitPaneActionListener);
        }

        //else if (component instanceof JExtendedSplitPane) ((JTitledPanel)component).addActionListener(splitPaneActionListener);
    }
}
 
Example 18
Source File: AccountSection.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@Override
public Component getComponent() {
   Component c = new AccountViewBuilder(controller).build();
   c.addComponentListener(new ComponentAdapter() {

      /* (non-Javadoc)
       * @see java.awt.event.ComponentAdapter#componentShown(java.awt.event.ComponentEvent)
       */
      @Override
      public void componentShown(ComponentEvent e) {
         controller.refreshAccount();
      }
   });
   return c;
}
 
Example 19
Source File: GOSwingEventConverter.java    From settlers-remake with MIT License 5 votes vote down vote up
void privateRegisterComponentListenerToParentWindowOf(Component component, Component childComponent) {
	if (component == null) {
		return;
	} else if (component instanceof Window) {
		updateScaleFactor(component);
		component.addComponentListener(this);
		childComponent.removeComponentListener(this);
	} else {
		privateRegisterComponentListenerToParentWindowOf(component.getParent(), childComponent);
	}
}
 
Example 20
Source File: JPersistentSplitPane.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
public JPersistentSplitPane(int newOrientation,
        Component newLeftComponent,
        Component newRightComponent,
        ConfigurationItem<Double> config) {
    super(newOrientation, newLeftComponent, newRightComponent);
    initialize(config);
    newLeftComponent.addComponentListener(childComponentListener);
    newRightComponent.addComponentListener(childComponentListener);
}