Listener() { addWindowFocusListener(this); // If anything happens to the "parent" window, hide this popup Window parent = (Window)getParent(); parent.addWindowFocusListener(this); parent.addWindowListener(this); parent.addComponentListener(this); }
Listener() { addWindowFocusListener(this); list.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount()==2) { insertSelectedItem(); } } }); list.getInputMap().put( KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "onEnter"); list.getActionMap().put("onEnter", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { insertSelectedItem(); } }); // If anything happens to the "parent" window, hide this popup Window parent = (Window)getParent(); parent.addWindowFocusListener(this); parent.addWindowListener(this); parent.addComponentListener(this); }
/** * Do not call directly as can cause a stack overflow with multiple attacments to the * listener list */ public WindowWatcher(Window w) { w.addComponentListener(this); w.addWindowListener(this); } public void componentShown(ComponentEvent e) {
public void addWindowProviderListener( WindowProviderListener listener ) { if( listener == null ) throw new IllegalArgumentException( "null is not allowed as listener" ); if( listeners.size() == 0 ){ updateVisibility(); if( window != null ){ window.addComponentListener( windowListener ); // updateVisibility(); } } listeners.add( listener ); }
/** * registerListeners, This function registers this class as a listener with the appropriate * components. De-registration is handled in the hide() function. */ private void registerListeners() { // Register this class as a focus listener with the display window. displayWindow.addWindowFocusListener(this); // Register this class as a window movement listener with the top window. topWindow.addComponentListener(this); }
public void addTo(Window w) { w.addComponentListener(this); w.addWindowFocusListener(this); }
public Rectangle getWindowRect(Window window) { window.addComponentListener(this); String rString = (String) getWindowPositions().get(window.getClass().getName()); if (rString == null) { return null; } StringTokenizer tokenizer = new StringTokenizer(rString, ","); int x = Integer.parseInt(tokenizer.nextToken()); int y = Integer.parseInt(tokenizer.nextToken()); int width = Integer.parseInt(tokenizer.nextToken()); int height = Integer.parseInt(tokenizer.nextToken()); return fitWindowBoundsToScreen(new Rectangle(x, y, width, height)); }
/** * Binds this preference object to synchronize its state with a given component, * allowing to specify an initial offset compared to the stored position. */ public void bindSize(final Window window, int initialWidth, int initialHeight) { updateSize(window, initialWidth, initialHeight); window.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { setWidth(window.getWidth()); setHeight(window.getHeight()); } }); }
/** * Called when this component receives a parent. This method is * overridden so we can add a component listener to the parent window * to know when it is maximized/de-maximized. */ @Override public void addNotify() { super.addNotify(); window = (Window)SwingUtilities.getRoot(this); window.addComponentListener(maximizeWindow); }
/** * Creates a new {@link WindowVisibilityMonitor} and attaches it to the given {@code Window}. * * @param target the {@code Window} to attach the new monitor to. */ void attachNewWindowVisibilityMonitor(Window target) { WindowVisibilityMonitor monitor = new WindowVisibilityMonitor(this); target.addWindowListener(monitor); target.addComponentListener(monitor); }
private void learnWindow( Container c ) { if( c != null && c instanceof Window ) { win = (Window) c; win.addWindowListener( winL ); win.addComponentListener( cmpL ); if( EventManager.DEBUG_EVENTS ) { System.err.println( "DynamicAncestorAdapter added WindowListener : "+ win.getClass().getName() ); } if( !listening && win.isShowing() ) startListening(); } }
@Override public void addNotify() { super.addNotify(); Window w = SwingUtilities.getWindowAncestor(this); setSize(getParent().getSize()); w.addComponentListener(listener); w.addWindowListener(listener); Toolkit.getDefaultToolkit().addAWTEventListener(listener, AWTEvent.MOUSE_EVENT_MASK|AWTEvent.MOUSE_MOTION_EVENT_MASK); }
public void addNotify() { super.addNotify(); Window w = SwingUtilities.getWindowAncestor(this); setSize(getParent().getSize()); w.addComponentListener(listener); w.addWindowListener(listener); Toolkit.getDefaultToolkit().addAWTEventListener(listener, AWTEvent.MOUSE_EVENT_MASK|AWTEvent.MOUSE_MOTION_EVENT_MASK); }
private void init(Window window, JComponent leftComponent, JComponent rightComponent) { this.window = window; window.addComponentListener(this); BasicSplitPaneDivider divider = getDividerComponent(); divider.addComponentListener(this); divider.addMouseListener(this); // Set null minimum size for both components so that divider can be moved all the way left/up and right/down Dimension nullDimension = new Dimension(0,0); if(leftComponent!=null) leftComponent.setMinimumSize(nullDimension); if(rightComponent!=null) rightComponent.setMinimumSize(nullDimension); }
/** * Restores the window size, position and state if possible. Tracks the * window size, position and state. * * @param window */ public static void track(Window window) { Preferences prefs = node().node("Windows"); String bounds = prefs.get(window.getName() + ".bounds", null); if (bounds != null) { Rectangle rect = (Rectangle)ConverterRegistry.instance().convert( Rectangle.class, bounds); window.setBounds(rect); } window.addComponentListener(windowDimension); }
Listener() { addWindowFocusListener(this); // If anything happens to the "parent" window, hide this popup Window parent = (Window)getParent(); parent.addWindowFocusListener(this); parent.addWindowListener(this); parent.addComponentListener(this); }
/** * Updates the visibility state and listeners that observe the * visibility state. */ protected void updateVisibility(){ Window current = searchWindow(); if( window != current ){ if( listeners.size() > 0 ){ if( window != null ) window.removeComponentListener( windowListener ); if( current != null ) current.addComponentListener( windowListener ); } window = current; } boolean showing = isShowing(); if( windowShowing != showing ){ windowShowing = showing; fireVisibilityChanged( showing ); } }
/** * Description of the Method * * @param e Description of Parameter */ public void windowActivated(WindowEvent e) { if (ignoreEvents) { // ok the next event will be processed ignoreEvents = false; return; } if (lastActivate != null) { lastActivate.removeComponentListener(this); } attachSnapTo(e.getWindow()); lastActivate = e.getWindow(); lastActivate.addComponentListener(this); }
/** * Sets the shape to apply, this method does nothing if this adapter is not {@link #isEnabled() enabled}. * @param shape the shape to apply or <code>null</code> */ public void setShape( ScreenWindowShape shape ){ if( (isEnabled() || shape == null) && shape != this.shape ){ if( this.shape != null ){ this.shape.setCallback( null ); window.removeComponentListener( callback ); } this.shape = shape; if( this.shape != null ){ this.shape.setCallback( callback ); this.shape.onShown(); window.addComponentListener( callback ); } } }
/** * Sets the shape to apply, this method does nothing if this adapter is not {@link #isEnabled() enabled}. * @param shape the shape to apply or <code>null</code> */ public void setShape( ScreenWindowShape shape ){ if( (isEnabled() || shape == null) && shape != this.shape ){ if( this.shape != null ){ this.shape.setCallback( null ); window.removeComponentListener( callback ); } this.shape = shape; if( this.shape != null ){ this.shape.setCallback( callback ); this.shape.onShown(); window.addComponentListener( callback ); } } }