List of usage examples for java.awt Component addComponentListener
public synchronized void addComponentListener(ComponentListener l)
From source file:Main.java
private static void addComponentListeners(Component c, Object... objs) { if (c == null) return;/*from w ww . j a v a 2 s . c o m*/ ComponentListener componentListener = search(objs, ComponentListener.class); FocusListener focusListener = search(objs, FocusListener.class); HierarchyBoundsListener hierarchyBoundsListener = search(objs, HierarchyBoundsListener.class); HierarchyListener hierarchyListener = search(objs, HierarchyListener.class); InputMethodListener inputMethodListener = search(objs, InputMethodListener.class); KeyListener keyListener = search(objs, KeyListener.class); MouseListener mouseListener = search(objs, MouseListener.class); MouseMotionListener mouseMotionListener = search(objs, MouseMotionListener.class); MouseWheelListener mouseWheelListener = search(objs, MouseWheelListener.class); if (componentListener != null) c.addComponentListener(componentListener); if (focusListener != null) c.addFocusListener(focusListener); if (hierarchyBoundsListener != null) c.addHierarchyBoundsListener(hierarchyBoundsListener); if (hierarchyListener != null) c.addHierarchyListener(hierarchyListener); if (inputMethodListener != null) c.addInputMethodListener(inputMethodListener); if (keyListener != null) c.addKeyListener(keyListener); if (mouseListener != null) c.addMouseListener(mouseListener); if (mouseMotionListener != null) c.addMouseMotionListener(mouseMotionListener); if (mouseWheelListener != null) c.addMouseWheelListener(mouseWheelListener); }
From source file:org.monkeys.gui.PopupWindow.java
public PopupWindow(final Frame parent, final Component base) { super(parent); if (null == base) { throw new NullArgumentException("component"); }//from w w w . ja va 2 s . c om this.addWindowFocusListener(new WindowAdapter() { @Override public void windowLostFocus(WindowEvent e) { hidePopup(); } }); base.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { hidePopup(); } @Override public void componentMoved(ComponentEvent e) { hidePopup(); } @Override public void componentHidden(ComponentEvent e) { hidePopup(); } }); base.addHierarchyListener(new HierarchyListener() { @Override public void hierarchyChanged(HierarchyEvent e) { hidePopup(); } }); }
From source file:com.mac.tarchan.desktop.event.EventQuery.java
/** * ???????// w w w .jav a 2s. co m * * @param target ? * @param action ????????????? * @param property ???????????? * @return ?? * @see ComponentListener#componentShown(java.awt.event.ComponentEvent) */ public EventQuery show(Object target, String action, String property) { ComponentListener componentShown = EventHandler.create(ComponentListener.class, target, action, property, "componentShown"); for (Component child : list) { child.addComponentListener(componentShown); } return this; }
From source file:com.mac.tarchan.desktop.event.EventQuery.java
/** * ?????????/* ww w . j a va2 s. c o m*/ * * @param target ? * @param action ????????????? * @param property ???????????? * @return ?? * @see ComponentListener#componentHidden(java.awt.event.ComponentEvent) */ public EventQuery hide(Object target, String action, String property) { ComponentListener componentHidden = EventHandler.create(ComponentListener.class, target, action, property, "componentHidden"); for (Component child : list) { child.addComponentListener(componentHidden); } return this; }
From source file:com.mac.tarchan.desktop.event.EventQuery.java
/** * ?????????/*from w w w . j a v a2s.c om*/ * * @param target ? * @param action ????????????? * @param property ???????????? * @return ?? * @see ComponentListener#componentResized(java.awt.event.ComponentEvent) */ public EventQuery resize(Object target, String action, String property) { ComponentListener componentResized = EventHandler.create(ComponentListener.class, target, action, property, "componentResized"); for (Component child : list) { child.addComponentListener(componentResized); } return this; }
From source file:com.mac.tarchan.desktop.event.EventQuery.java
/** * ????????/* w w w . jav a2 s . co m*/ * * @param target ? * @param action ????????????? * @param property ???????????? * @return ?? * @see ComponentListener#componentMoved(java.awt.event.ComponentEvent) */ public EventQuery move(Object target, String action, String property) { ComponentListener componentMoved = EventHandler.create(ComponentListener.class, target, action, property, "componentMoved"); for (Component child : list) { child.addComponentListener(componentMoved); } return this; }
From source file:self.philbrown.javaQuery.$.java
/** * Registers common component changes/*www . j a va 2 s .c o m*/ * @param function receives an instance of javaQuery with the changed view selected, as well as the * following arguments: * <ol> * <li>{@link changeEvent} to define the type of event that was triggered * <li>The associated event * </ol> * @return * @see changeEvent */ public $ change(final Function function) { for (final Component component : views) { component.addInputMethodListener(new InputMethodListener() { @Override public void caretPositionChanged(InputMethodEvent event) { function.invoke($.with(component), ChangeEvent.INPUT_CARET_POSITION_CHANGED, event); } @Override public void inputMethodTextChanged(InputMethodEvent event) { function.invoke($.with(component), ChangeEvent.INPUT_METHOD_TEXT_CHANGED, event); } }); component.addHierarchyBoundsListener(new HierarchyBoundsListener() { @Override public void ancestorMoved(HierarchyEvent event) { function.invoke($.with(component), ChangeEvent.HIERARCHY_ANCESTOR_MOVED, event); } @Override public void ancestorResized(HierarchyEvent event) { function.invoke($.with(component), ChangeEvent.HIERARCHY_ANCENSTOR_RESIZED, event); } }); component.addHierarchyListener(new HierarchyListener() { @Override public void hierarchyChanged(HierarchyEvent event) { function.invoke($.with(component), ChangeEvent.HIERARCHY_CHANGED, event); } }); component.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { function.invoke($.with(component), ChangeEvent.PROPERTY_CHANGED, event); } }); component.addComponentListener(new ComponentListener() { @Override public void componentHidden(ComponentEvent event) { function.invoke($.with(component), ChangeEvent.COMPONENT_HIDDEN, event); } @Override public void componentMoved(ComponentEvent event) { function.invoke($.with(component), ChangeEvent.COMPONENT_MOVED, event); } @Override public void componentResized(ComponentEvent event) { function.invoke($.with(component), ChangeEvent.COMPONENT_RESIZED, event); } @Override public void componentShown(ComponentEvent event) { function.invoke($.with(component), ChangeEvent.COMPONENT_SHOWN, event); } }); if (component instanceof Container) { ((Container) component).addContainerListener(new ContainerListener() { @Override public void componentAdded(ContainerEvent event) { function.invoke($.with(component), ChangeEvent.COMPONENT_ADDED, event); } @Override public void componentRemoved(ContainerEvent event) { function.invoke($.with(component), ChangeEvent.COMPONENT_REMOVED, event); } }); } } return this; }