tags:

views:

32

answers:

1

I tried PropertyChangeListener with property set to "width", "Width", "size" and "Size".

PropertyChangeListener widthChangeListener = new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {

                //code

        }
    };

    streamsComboBox.addPropertyChangeListener("width", widthChangeListener);
    projectsComboBox.addPropertyChangeListener("width", widthChangeListener);
    vobsComboBox.addPropertyChangeListener("width", widthChangeListener);

Nothing works - the handler method is never fired.
What should I do to handle JComboBox's size change? Where does the property name come from anyway?

+3  A: 

Try adding a ComponentListener, for example:

combo.addComponentListener( new ComponentAdapter()
{
  public void componentResized( ComponentEvent e )
  {
    Component component = (Component)e.getSource();
    System.out.println( "Resized: " + component.getSize() );
  }
});
Ash