Java Code Examples for java.awt.event.ComponentEvent#getSource()

The following examples show how to use java.awt.event.ComponentEvent#getSource() . 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: WindowSizeLimiter.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Invoked when the component's size changes.
 *
 * @param e
 *          the event.
 */
public void componentResized( final ComponentEvent e ) {
  if ( e.getSource() == currentSource ) {
    return;
  }

  if ( e.getSource() instanceof Component ) {
    currentSource = e.getSource();
    final Component c = (Component) e.getSource();
    final Dimension d = c.getMaximumSize();
    final Dimension s = c.getSize();
    if ( s.width > d.width ) {
      s.width = d.width;
    }
    if ( s.height > d.height ) {
      s.height = d.height;
    }
    c.setSize( s );
    currentSource = null;
  }

}
 
Example 2
Source File: TextSearchDemo.java    From pumpernickel with MIT License 5 votes vote down vote up
private void updateButtons(ComponentEvent e) {
	if (e.getSource() == safariBar) {
		safariButton.setSelected(safariBar.isVisible());
	} else if (e.getSource() == firefoxBar) {
		firefoxButton.setSelected(firefoxBar.isVisible());
	}
}
 
Example 3
Source File: LuckPopupFactory.java    From littleluck with Apache License 2.0 5 votes vote down vote up
@Override
public void componentShown(ComponentEvent e)
{
    Object obj = e.getSource();
    
    if(obj instanceof JWindow)
    {
        JWindow window = (JWindow) obj;
        
        window.repaint();
    }
}
 
Example 4
Source File: SeaGlassInternalFrameUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
protected ComponentListener createComponentListener() {
    if (UIManager.getBoolean("InternalFrame.useTaskBar")) {
        return new ComponentHandler() {
            public void componentResized(ComponentEvent e) {
                if (frame != null && frame.isMaximum()) {
                    JDesktopPane desktop = (JDesktopPane) e.getSource();
                    for (Component comp : desktop.getComponents()) {
                        if (comp instanceof SeaGlassDesktopPaneUI.TaskBar) {
                            frame.setBounds(0, 0, desktop.getWidth(), desktop.getHeight() - comp.getHeight());
                            frame.revalidate();
                            break;
                        }
                    }
                }

                // Update the new parent bounds for next resize, but don't
                // let the super method touch this frame
                JInternalFrame f = frame;
                frame = null;
                super.componentResized(e);
                frame = f;
            }
        };
    } else {
        return super.createComponentListener();
    }
}
 
Example 5
Source File: ViewportView.java    From SwingBox with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void componentResized(ComponentEvent e)
{
    if ((e.getSource() instanceof JViewport))
    {
        checkSize(((JViewport) e.getSource()).getSize());
    }
}
 
Example 6
Source File: DesktopWindowWatcher.java    From consulo with Apache License 2.0 5 votes vote down vote up
final void dispatchComponentEvent(final ComponentEvent e) {
  final int id = e.getID();
  if (WindowEvent.WINDOW_CLOSED == id || (ComponentEvent.COMPONENT_HIDDEN == id && e.getSource() instanceof Window)) {
    dispatchHiddenOrClosed(TargetAWT.from((Window)e.getSource()));
  }
  // Clear obsolete reference on root frame
  if (WindowEvent.WINDOW_CLOSED == id) {
    final Window window = (Window)e.getSource();

    if (JOptionPane.getRootFrame() == window) {
      JOptionPane.setRootFrame(null);
    }
  }
}
 
Example 7
Source File: ButtonCluster.java    From pumpernickel with MIT License 4 votes vote down vote up
@Override
public void componentHidden(ComponentEvent e) {
	AbstractButton button = (AbstractButton) e.getSource();
	ButtonCluster cluster = ButtonCluster.getCluster(button);
	cluster.updateSegmentPositions();
}
 
Example 8
Source File: ButtonCluster.java    From pumpernickel with MIT License 4 votes vote down vote up
@Override
public void componentShown(ComponentEvent e) {
	AbstractButton button = (AbstractButton) e.getSource();
	ButtonCluster cluster = ButtonCluster.getCluster(button);
	cluster.updateSegmentPositions();
}
 
Example 9
Source File: SeaGlassDesktopPaneUI.java    From seaglass with Apache License 2.0 4 votes vote down vote up
public void componentResized(ComponentEvent e) {
    if (e.getSource() instanceof JDesktopPane) {
        adjustSize();
    }
}
 
Example 10
Source File: SeaGlassDesktopPaneUI.java    From seaglass with Apache License 2.0 4 votes vote down vote up
public void componentShown(ComponentEvent e) {
    if (e.getSource() instanceof JInternalFrame) {
        adjustSize();
    }
}
 
Example 11
Source File: SeaGlassDesktopPaneUI.java    From seaglass with Apache License 2.0 4 votes vote down vote up
public void componentHidden(ComponentEvent e) {
    if (e.getSource() instanceof JInternalFrame) {
        ((JInternalFrame) e.getSource()).getDesktopIcon().setVisible(false);
        revalidate();
    }
}
 
Example 12
Source File: MultiThumbSliderUI.java    From Pixelitor with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void componentResized(ComponentEvent e) {
    calculateGeometry();
    Component c = (Component) e.getSource();
    c.repaint();
}
 
Example 13
Source File: WindowStateAdapter.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void update(@Nullable ComponentEvent event) {
  Object source = event == null ? null : event.getSource();
  if (source instanceof Window) myWindowState.applyFrom((Window)source);
}