Java Code Examples for java.awt.event.ComponentListener

The following are top voted examples for showing how to use java.awt.event.ComponentListener. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: iSeleda   File: WindowUtils.java   View source code 6 votes vote down vote up
/**
 * Installs/resets a ComponentListener to resize the
 * given window to minWidth/Height if needed.
 *
 * @param window
 * @param minWidth
 * @param minHeight
 */
public static void setMinimumSizeManager(Window window, int minWidth,
                                         int minHeight) {
    ComponentListener[] listeners = window.getComponentListeners();
    ComponentListener listener = null;
    for (ComponentListener l : listeners) {
        if (l instanceof MinSizeComponentListener) {
            listener = l;
            break;
        }
    }
    if (listener == null) {
        window.addComponentListener(new MinSizeComponentListener(
                window, minWidth, minHeight));
    } else {
        ((MinSizeComponentListener) listener).resetSizes(minWidth,
                minHeight);
    }
}
 
Example 2
Project: sc2gears   File: GuiUtils.java   View source code 6 votes vote down vote up
/**
 * Creates and returns a scroll panel which wraps the specified view component.<br>
 * The returned scroll panel disables vertical scroll bar, and only displays the horizontal scroll bar when the view does not fit
 * into the size of the view port. When the view fits into the view port, the scroll pane will not claim the space of the scroll bar.
 * 
 * @param view               view to wrap in the scroll pane
 * @param parentToRevalidate parent to revalidate when the scroll pane decides to change its size
 * 
 * @return the created self managed scroll pane
 */
public static JScrollPane createSelfManagedScrollPane( final Component view, final JComponent parentToRevalidate ) {
	final JScrollPane scrollPane = new JScrollPane( view );
	
	scrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_NEVER );
	scrollPane.getHorizontalScrollBar().setPreferredSize( new Dimension( 0, 12 ) ); // Only want to restrict the height, width doesn't matter (it takes up whole width)
	scrollPane.getHorizontalScrollBar().setUnitIncrement( 10 );
	
	final ComponentListener scrollPaneComponentListener = new ComponentAdapter() {
		@Override
		public void componentResized( final ComponentEvent event ) {
			scrollPane.setHorizontalScrollBarPolicy( view.getWidth() < scrollPane.getWidth() ? JScrollPane.HORIZONTAL_SCROLLBAR_NEVER : JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS );
			scrollPane.setPreferredSize( null );
			scrollPane.setPreferredSize( new Dimension( 10, scrollPane.getPreferredSize().height ) );
			parentToRevalidate.revalidate();
		}
	};
	scrollPane.addComponentListener( scrollPaneComponentListener );
	
	return scrollPane;
}
 
Example 3
Project: power-matchmaker   File: MungePen.java   View source code 6 votes vote down vote up
/**
 * Removes all listeners associated with the given Component. This is useful when removing to to make sure
 * it does not stick around.
 */
public static void removeAllListeners(Component com) {
	for (FocusListener fl : com.getFocusListeners()) {
		com.removeFocusListener(fl);
	}
	
	for (MouseListener ml : com.getMouseListeners()) {
		com.removeMouseListener(ml);
	}
	
	for (MouseMotionListener mml : com.getMouseMotionListeners()) {
		com.removeMouseMotionListener(mml);
	}
	
	for (KeyListener kl : com.getKeyListeners()) {
		com.removeKeyListener(kl);
	}
	
	for (ComponentListener cl : com.getComponentListeners()) {
		com.removeComponentListener(cl);
	}
}
 
Example 4
Project: aibench-project   File: WindowUtils.java   View source code 6 votes vote down vote up
/**
 * Installs/resets a ComponentListener to resize the
 * given window to minWidth/Height if needed.
 *
 * @param window
 * @param minWidth
 * @param minHeight
 */
public static void setMinimumSizeManager(Window window, int minWidth,
                                         int minHeight) {
    ComponentListener[] listeners = window.getComponentListeners();
    ComponentListener listener = null;
    for (ComponentListener l : listeners) {
        if (l instanceof MinSizeComponentListener) {
            listener = l;
            break;
        }
    }
    if (listener == null) {
        window.addComponentListener(new MinSizeComponentListener(
                window, minWidth, minHeight));
    } else {
        ((MinSizeComponentListener) listener).resetSizes(minWidth,
                                                         minHeight);
    }
}
 
Example 5
Project: S3F   File: MainUI.java   View source code 6 votes vote down vote up
public DockingWindow addView(int order, Configurable obj) {
    Component component = (Component) obj.getData().getProperty(TabProperty.COMPONENT);
    View view = new View(
            (String) obj.getData().getProperty(TabProperty.TITLE),
            (Icon) obj.getData().getProperty(TabProperty.ICON),
            component
    );

    if (component instanceof ComponentListener) {
        view.addComponentListener((ComponentListener) component);
    }

    if (order == 1 && obj instanceof DockingWindowListener) {
        DockingWindowListener dockingWindowListener = (DockingWindowListener) obj;
        view.addListener(dockingWindowListener);
        if (firstTabWindow.getChildWindowCount() == 0) {
            dockingWindowListener.windowShown(view);
        }
    }

    return addView(order, view);
}
 
Example 6
Project: passage   File: Layer.java   View source code 6 votes vote down vote up
/**
 * Fire a component event to the Layer component listeners, with the palette
 * as the component, letting them know if it's visible or not.
 */
public void firePaletteEvent(ComponentEvent event) {
    if (localHackList == null) {
        return;
    }

    palette = (Container) event.getSource();
    int eventType = event.getID();
    for (ComponentListener listener : localHackList) {
        if (eventType == ComponentEvent.COMPONENT_HIDDEN) {
            listener.componentHidden(event);
        } else if (eventType == ComponentEvent.COMPONENT_SHOWN) {
            listener.componentShown(event);
        }
    }

    if (eventType == ComponentEvent.COMPONENT_HIDDEN) {
        palette = null;
    }
}
 
Example 7
Project: passage   File: PaletteHelper.java   View source code 6 votes vote down vote up
/**
 * Get a layer's associated palette as a top-level window
 * 
 * @param gui the Component to place in the window
 * @param cl the listener to associate with the palette
 * @return the frame that the palette is in
 */
public static JFrame getPaletteWindow(Component gui, String windowName,
                                      ComponentListener cl) {

    JScrollPane scrollPane = new JScrollPane(gui, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
    scrollPane.setAlignmentY(Component.TOP_ALIGNMENT);

    // create the palette internal window
    JFrame paletteWindow = new JFrame(windowName);

    paletteWindow.addComponentListener(cl);
    paletteWindow.getContentPane().add(scrollPane);
    //layout all the components
    paletteWindow.pack();
    return paletteWindow;
}
 
Example 8
Project: passage   File: PaletteHelper.java   View source code 6 votes vote down vote up
/**
 * Get a layer's associated palette as a top-level window
 * 
 * @param gui the Component to place in the window
 * @param cl the listener to associate with the palette
 * @return the frame that the palette is in
 */
public static JFrame getNoScrollPaletteWindow(Component gui,
                                              String windowName,
                                              ComponentListener cl) {

    JPanel pane = new JPanel();
    pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
    pane.setAlignmentX(Component.CENTER_ALIGNMENT);
    pane.setAlignmentY(Component.BOTTOM_ALIGNMENT);
    pane.add(gui);
    JFrame paletteWindow = new JFrame(windowName);
    paletteWindow.addComponentListener(cl);
    paletteWindow.getContentPane().add(pane);
    paletteWindow.pack();

    return paletteWindow;
}
 
Example 9
Project: passage   File: WindowSupport.java   View source code 6 votes vote down vote up
/**
 * Sets the content in the JInternalFrame/JDialog.
 */
public void setContent(Component comp) {

    if (content instanceof ComponentListener) {
        removeComponentListener((ComponentListener) content);
    }

    content = comp;
    if (display != null) {
        display.setContent(comp);
    }

    if (content instanceof ComponentListener) {
        addComponentListener((ComponentListener) content);
    }
}
 
Example 10
Project: cn1   File: Component.java   View source code 6 votes vote down vote up
@SuppressWarnings("unchecked")
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
    if (ComponentListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getComponentListeners();
    } else if (FocusListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getFocusListeners();
    } else if (HierarchyBoundsListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyBoundsListeners();
    } else if (HierarchyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyListeners();
    } else if (InputMethodListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getInputMethodListeners();
    } else if (KeyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getKeyListeners();
    } else if (MouseWheelListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseWheelListeners();
    } else if (MouseMotionListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseMotionListeners();
    } else if (MouseListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseListeners();
    } else if (PropertyChangeListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getPropertyChangeListeners();
    }
    return (T[]) Array.newInstance(listenerType, 0);
}
 
Example 11
Project: cn1   File: Component.java   View source code 6 votes vote down vote up
private void processComponentEventImpl(ComponentEvent e, Collection<ComponentListener> c) {
    for (ComponentListener listener : c) {
        switch (e.getID()) {
            case ComponentEvent.COMPONENT_HIDDEN:
                listener.componentHidden(e);
                break;
            case ComponentEvent.COMPONENT_MOVED:
                listener.componentMoved(e);
                break;
            case ComponentEvent.COMPONENT_RESIZED:
                listener.componentResized(e);
                break;
            case ComponentEvent.COMPONENT_SHOWN:
                listener.componentShown(e);
                break;
        }
    }
}
 
Example 12
Project: freemind_1.0.0_20140624_214725   File: EditNodeTextField.java   View source code 6 votes vote down vote up
private void hideMe() {
	final JComponent parent = (JComponent) textfield.getParent();
	final Rectangle bounds = textfield.getBounds();
	textfield.removeFocusListener(textFieldListener);
	textfield.removeKeyListener((KeyListener) textFieldListener);
	textfield.removeMouseListener((MouseListener) textFieldListener);
	mFocusListener
			.removeComponentListener((ComponentListener) textFieldListener);
	// workaround for java bug
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7075600, see
	// FreeMindStarter
	parent.remove(textfield);
	parent.revalidate();
	parent.repaint(bounds);
	textFieldListener = null;
}
 
Example 13
Project: desktopclient-java   File: ComponentUtils.java   View source code 6 votes vote down vote up
private void showPopupPanel() {
    if (mPopup == null)
        mPopup = new ComponentUtils.ModalPopup(this);

    PopupPanel panel = this.getPanel().orElse(null);
    if (panel == null)
        return;

    mPopup.removeAll();
    panel.onShow();

    for (ComponentListener cl : panel.getComponentListeners())
        panel.removeComponentListener(cl);

    panel.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentHidden(ComponentEvent e) {
            mPopup.close();
        }
    });
    mPopup.add(panel);
    mPopup.showPopup();
}
 
Example 14
Project: freeVM   File: Component.java   View source code 6 votes vote down vote up
@SuppressWarnings("unchecked")
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
    if (ComponentListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getComponentListeners();
    } else if (FocusListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getFocusListeners();
    } else if (HierarchyBoundsListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyBoundsListeners();
    } else if (HierarchyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyListeners();
    } else if (InputMethodListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getInputMethodListeners();
    } else if (KeyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getKeyListeners();
    } else if (MouseWheelListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseWheelListeners();
    } else if (MouseMotionListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseMotionListeners();
    } else if (MouseListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseListeners();
    } else if (PropertyChangeListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getPropertyChangeListeners();
    }
    return (T[]) Array.newInstance(listenerType, 0);
}
 
Example 15
Project: freeVM   File: Component.java   View source code 6 votes vote down vote up
private void processComponentEventImpl(ComponentEvent e, Collection<ComponentListener> c) {
    for (ComponentListener listener : c) {
        switch (e.getID()) {
            case ComponentEvent.COMPONENT_HIDDEN:
                listener.componentHidden(e);
                break;
            case ComponentEvent.COMPONENT_MOVED:
                listener.componentMoved(e);
                break;
            case ComponentEvent.COMPONENT_RESIZED:
                listener.componentResized(e);
                break;
            case ComponentEvent.COMPONENT_SHOWN:
                listener.componentShown(e);
                break;
        }
    }
}
 
Example 16
Project: freeVM   File: Component.java   View source code 6 votes vote down vote up
@SuppressWarnings("unchecked")
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
    if (ComponentListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getComponentListeners();
    } else if (FocusListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getFocusListeners();
    } else if (HierarchyBoundsListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyBoundsListeners();
    } else if (HierarchyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyListeners();
    } else if (InputMethodListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getInputMethodListeners();
    } else if (KeyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getKeyListeners();
    } else if (MouseWheelListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseWheelListeners();
    } else if (MouseMotionListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseMotionListeners();
    } else if (MouseListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseListeners();
    } else if (PropertyChangeListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getPropertyChangeListeners();
    }
    return (T[]) Array.newInstance(listenerType, 0);
}
 
Example 17
Project: freeVM   File: Component.java   View source code 6 votes vote down vote up
private void processComponentEventImpl(ComponentEvent e, Collection<ComponentListener> c) {
    for (ComponentListener listener : c) {
        switch (e.getID()) {
            case ComponentEvent.COMPONENT_HIDDEN:
                listener.componentHidden(e);
                break;
            case ComponentEvent.COMPONENT_MOVED:
                listener.componentMoved(e);
                break;
            case ComponentEvent.COMPONENT_RESIZED:
                listener.componentResized(e);
                break;
            case ComponentEvent.COMPONENT_SHOWN:
                listener.componentShown(e);
                break;
        }
    }
}
 
Example 18
Project: freemind   File: EditNodeTextField.java   View source code 6 votes vote down vote up
private void hideMe() {
	final JComponent parent = (JComponent) textfield.getParent();
	final Rectangle bounds = textfield.getBounds();
	textfield.removeFocusListener(textFieldListener);
	textfield.removeKeyListener((KeyListener) textFieldListener);
	textfield.removeMouseListener((MouseListener) textFieldListener);
	mFocusListener
			.removeComponentListener((ComponentListener) textFieldListener);
	// workaround for java bug
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7075600, see
	// FreeMindStarter
	parent.remove(textfield);
	parent.revalidate();
	parent.repaint(bounds);
	textFieldListener = null;
}
 
Example 19
Project: incubator-netbeans   File: Outline.java   View source code 5 votes vote down vote up
/** Create a component listener to handle size changes if the table model
 * is large-model */
private ComponentListener getComponentListener() {
    if (componentListener == null) {
        componentListener = new SizeManager();
    }
    return componentListener;
}
 
Example 20
Project: incubator-netbeans   File: FontAndColorsPanel.java   View source code 5 votes vote down vote up
@Override
public void removeNotify() {
    super.removeNotify();
    for (ComponentListener l : getComponentListeners()) {
        super.removeComponentListener(l);
    }
}
 
Example 21
Project: etomica   File: DisplayCanvas.java   View source code 5 votes vote down vote up
public void dispose() {
    ComponentListener[] listeners = getComponentListeners();
    for (int i=0; i<listeners.length; i++) {
        removeComponentListener(listeners[i]);
    }
    MouseListener[] mlisteners = getMouseListeners();
    for (int i=0; i<mlisteners.length; i++) {
        removeMouseListener(mlisteners[i]);
    }
    KeyListener[] klisteners = getKeyListeners();
    for (int i=0; i<klisteners.length; i++) {
        removeKeyListener(klisteners[i]);
    }
}
 
Example 22
Project: openjdk-jdk10   File: ComponentOperator.java   View source code 5 votes vote down vote up
/**
 * Maps {@code Component.addComponentListener(ComponentListener)}
 * through queue
 */
public void addComponentListener(final ComponentListener componentListener) {
    runMapping(new MapVoidAction("addComponentListener") {
        @Override
        public void map() {
            getSource().addComponentListener(componentListener);
        }
    });
}
 
Example 23
Project: openjdk-jdk10   File: ComponentOperator.java   View source code 5 votes vote down vote up
/**
 * Maps {@code Component.removeComponentListener(ComponentListener)}
 * through queue
 */
public void removeComponentListener(final ComponentListener componentListener) {
    runMapping(new MapVoidAction("removeComponentListener") {
        @Override
        public void map() {
            getSource().removeComponentListener(componentListener);
        }
    });
}
 
Example 24
Project: openjdk9   File: ComponentOperator.java   View source code 5 votes vote down vote up
/**
 * Maps {@code Component.addComponentListener(ComponentListener)}
 * through queue
 */
public void addComponentListener(final ComponentListener componentListener) {
    runMapping(new MapVoidAction("addComponentListener") {
        @Override
        public void map() {
            getSource().addComponentListener(componentListener);
        }
    });
}
 
Example 25
Project: openjdk9   File: ComponentOperator.java   View source code 5 votes vote down vote up
/**
 * Maps {@code Component.removeComponentListener(ComponentListener)}
 * through queue
 */
public void removeComponentListener(final ComponentListener componentListener) {
    runMapping(new MapVoidAction("removeComponentListener") {
        @Override
        public void map() {
            getSource().removeComponentListener(componentListener);
        }
    });
}
 
Example 26
Project: j2se_for_android   File: Component.java   View source code 5 votes vote down vote up
public void fireComponentResizedAdAPI(){
	final ComponentEvent event = new ComponentEvent(this, ComponentEvent.COMPONENT_RESIZED);
	
	final ComponentListener[] listeners = getComponentListeners();
	for (int i = 0; i < listeners.length; i++) {
		listeners[i].componentResized(event);
	}
}
 
Example 27
Project: j2se_for_android   File: Component.java   View source code 5 votes vote down vote up
public void fireComponentMovedAdAPI(){
	final ComponentEvent event = new ComponentEvent(this, ComponentEvent.COMPONENT_MOVED);
	
	final ComponentListener[] listeners = getComponentListeners();
	for (int i = 0; i < listeners.length; i++) {
		listeners[i].componentMoved(event);
	}
}
 
Example 28
Project: j2se_for_android   File: Component.java   View source code 5 votes vote down vote up
public void fireComponentShowAdAPI(){
	final ComponentEvent event = new ComponentEvent(this, ComponentEvent.COMPONENT_SHOWN);
	
	final ComponentListener[] listeners = getComponentListeners();
	for (int i = 0; i < listeners.length; i++) {
		listeners[i].componentShown(event);
	}
}
 
Example 29
Project: j2se_for_android   File: Component.java   View source code 5 votes vote down vote up
public void fireComponentHiddenAdAPI(){
	final ComponentEvent event = new ComponentEvent(this, ComponentEvent.COMPONENT_HIDDEN);
	
	final ComponentListener[] listeners = getComponentListeners();
	for (int i = 0; i < listeners.length; i++) {
		listeners[i].componentHidden(event);
	}
}
 
Example 30
Project: javify   File: Component.java   View source code 5 votes vote down vote up
/**
 * Deserializes this component. This regenerates all serializable listeners
 * which were registered originally.
 *
 * @param s the stream to read from
 * @throws ClassNotFoundException if deserialization fails
 * @throws IOException if the stream fails
 */
private void readObject(ObjectInputStream s)
  throws ClassNotFoundException, IOException
{
  s.defaultReadObject();
  String key = (String) s.readObject();
  while (key != null)
    {
      Object listener = s.readObject();
      if ("componentL".equals(key))
        addComponentListener((ComponentListener) listener);
      else if ("focusL".equals(key))
        addFocusListener((FocusListener) listener);
      else if ("keyL".equals(key))
        addKeyListener((KeyListener) listener);
      else if ("mouseL".equals(key))
        addMouseListener((MouseListener) listener);
      else if ("mouseMotionL".equals(key))
        addMouseMotionListener((MouseMotionListener) listener);
      else if ("inputMethodL".equals(key))
        addInputMethodListener((InputMethodListener) listener);
      else if ("hierarchyL".equals(key))
        addHierarchyListener((HierarchyListener) listener);
      else if ("hierarchyBoundsL".equals(key))
        addHierarchyBoundsListener((HierarchyBoundsListener) listener);
      else if ("mouseWheelL".equals(key))
        addMouseWheelListener((MouseWheelListener) listener);
      key = (String) s.readObject();
    }
}
 
Example 31
Project: javify   File: StandaloneAppletWindow.java   View source code 5 votes vote down vote up
/**
 * This method is called when the component is resized.
 *
 * @param event the <code>ComponentEvent</code> indicating the resize
 */
public void componentResized(ComponentEvent event)
{
  if (applet != null)
    {
      ComponentListener[] l = applet.getComponentListeners();
      for (int i = 0; i < l.length; i++)
        l[i].componentResized(event);
    }
}
 
Example 32
Project: javify   File: StandaloneAppletWindow.java   View source code 5 votes vote down vote up
/**
 * This method is called when the component is moved.
 *
 * @param event the <code>ComponentEvent</code> indicating the move
 */
public void componentMoved(ComponentEvent event)
{
  if (applet != null)
    {
      ComponentListener[] l = applet.getComponentListeners();
      for (int i = 0; i < l.length; i++)
        l[i].componentMoved(event);
    }
}
 
Example 33
Project: javify   File: StandaloneAppletWindow.java   View source code 5 votes vote down vote up
/**
 * This method is called when the component is made visible.
 *
 * @param event the <code>ComponentEvent</code> indicating the visibility
 */
public void componentShown(ComponentEvent event)
{
  if (applet != null)
    {
      ComponentListener[] l = applet.getComponentListeners();
      for (int i = 0; i < l.length; i++)
        l[i].componentShown(event);
    }
}
 
Example 34
Project: javify   File: StandaloneAppletWindow.java   View source code 5 votes vote down vote up
/**
 * This method is called when the component is hidden.
 *
 * @param event the <code>ComponentEvent</code> indicating the visibility
 */
public void componentHidden(ComponentEvent event)
{
  if (applet != null)
    {
      ComponentListener[] l = applet.getComponentListeners();
      for (int i = 0; i < l.length; i++)
        l[i].componentHidden(event);
    }
}
 
Example 35
Project: javify   File: PluginAppletWindow.java   View source code 5 votes vote down vote up
/**
 * This method is called when the component is resized.
 *
 * @param event the <code>ComponentEvent</code> indicating the resize
 */
public void componentResized(ComponentEvent event)
{
  if (applet != null)
    {
      ComponentListener[] l = applet.getComponentListeners();
      for (int i = 0; i < l.length; i++)
        l[i].componentResized(event);
    }
}
 
Example 36
Project: javify   File: PluginAppletWindow.java   View source code 5 votes vote down vote up
/**
 * This method is called when the component is moved.
 *
 * @param event the <code>ComponentEvent</code> indicating the move
 */
public void componentMoved(ComponentEvent event)
{
  if (applet != null)
    {
      ComponentListener[] l = applet.getComponentListeners();
      for (int i = 0; i < l.length; i++)
        l[i].componentMoved(event);
    }
}
 
Example 37
Project: javify   File: PluginAppletWindow.java   View source code 5 votes vote down vote up
/**
 * This method is called when the component is made visible.
 *
 * @param event the <code>ComponentEvent</code> indicating the visibility
 */
public void componentShown(ComponentEvent event)
{
  if (applet != null)
    {
      ComponentListener[] l = applet.getComponentListeners();
      for (int i = 0; i < l.length; i++)
        l[i].componentShown(event);
    }
}
 
Example 38
Project: javify   File: PluginAppletWindow.java   View source code 5 votes vote down vote up
/**
 * This method is called when the component is hidden.
 *
 * @param event the <code>ComponentEvent</code> indicating the visibility
 */
public void componentHidden(ComponentEvent event)
{
  if (applet != null)
    {
      ComponentListener[] l = applet.getComponentListeners();
      for (int i = 0; i < l.length; i++)
        l[i].componentHidden(event);
    }
}
 
Example 39
Project: intellij-ce-playground   File: FrameState.java   View source code 5 votes vote down vote up
private static FrameState findFrameState(@NotNull Component component) {
  for (ComponentListener listener : component.getComponentListeners()) {
    if (listener instanceof FrameState) {
      return (FrameState)listener;
    }
  }
  return null;
}
 
Example 40
Project: sqlpower-library   File: PopupListenerHandler.java   View source code 5 votes vote down vote up
/**
* Returns true if the {@link Popup} this class handles is visible. Since
* there is no available method in the {@link Popup} class to check whether
* it is visible, it checks if listeners are attached to the owning frame or
* glass pane instead.
*/
  public boolean isPopupVisible() {
  	ComponentListener[] componentListeners = owningFrame.getComponentListeners();
  	if (Arrays.asList(componentListeners).contains(resizeListener)) {
  		return true;
  	}
  	
  	MouseListener[] mouseListeners = glassPane.getMouseListeners();
  	if (Arrays.asList(mouseListeners).contains(clickListener)) {
  		return true;
  	}
  	
  	return false;
  	
  }