@Override
public Component getPreview ( final WebLookAndFeelDemo owner )
{
// Popup
final WebPopup popup = new WebPopup ();
popup.setMargin ( 20 );
popup.add ( new WebImage ( loadIcon ( "move.png" ) ) );
// Popup move mouse adapter
ComponentMoveAdapter.install ( popup, popup );
// Popup invoker button
final WebButton showPopup = new WebButton ( "Show simple popup" );
// Popup style chooser
final WebComboBox popupStyle = new WebComboBox ( PopupStyle.values () );
popupStyle.setSelectedItem ( PopupManager.getDefaultPopupStyle () );
popupStyle.setRenderer ( new WebComboBoxCellRenderer ()
{
@Override
public Component getListCellRendererComponent ( final JList list, final Object value, final int index, final boolean isSelected,
final boolean cellHasFocus )
{
return super.getListCellRendererComponent ( list, "Style: " + value, index, isSelected, cellHasFocus );
}
} );
popupStyle.addActionListener ( new ActionListener ()
{
@Override
public void actionPerformed ( final ActionEvent e )
{
popup.setPopupStyle ( ( PopupStyle ) popupStyle.getSelectedItem () );
popup.packPopup ();
}
} );
// Popup show/hide action
showPopup.addActionListener ( new ActionListener ()
{
@Override
public void actionPerformed ( final ActionEvent e )
{
if ( popup.isShowing () )
{
popup.hidePopup ();
}
else
{
popup.showAsPopupMenu ( showPopup );
}
}
} );
return new GroupPanel ( 4, showPopup, popupStyle );