public class MenuTest
{
public static void main ( final String[] args )
{
SwingTest.run ( new Runnable ()
{
@Override
public void run ()
{
final WebPopupMenu menu = new WebPopupMenu ();
menu.setPopupMenuWay ( PopupMenuWay.belowEnd );
menu.add ( new WebMenuItem ( "Item" ) );
final WebButton button = new WebButton ( "Show menu" );
button.addActionListener ( new ActionListener ()
{
@Override
public void actionPerformed ( final ActionEvent e )
{
// menu.setPopupMenuWay ( PopupMenuWay.belowEnd );
menu.show ( button, -button.getWidth () / 2, button.getHeight () );
}
} );
TestFrame.show ( button );
}
} );
}
}
If the commented line of code is uncommented - menu will always be displayed correctly.
This technically isn't a bug because originaly I intended PopupMenuWay (probably should be renamed in future to something better as well) to be a one-time use setting. And that is how it basically works in current version.
Although this is surely not convenient and, realistically, you would rarely need to change this setting in actual use cases. So it is worth preserving it over multiple displays of the same popup menu.
Originally reported by @husker-dev via email.
Here is a code example displaying the issue:
If the commented line of code is uncommented - menu will always be displayed correctly.
This technically isn't a bug because originaly I intended
PopupMenuWay
(probably should be renamed in future to something better as well) to be a one-time use setting. And that is how it basically works in current version.Although this is surely not convenient and, realistically, you would rarely need to change this setting in actual use cases. So it is worth preserving it over multiple displays of the same popup menu.