This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

JVx swing UI / VisionX Button with popup menu

We didn't have support for Buttons with popup menus in JVx because standard Swing doesn't support this feature out-of-the box. But such a component would be very useful for some UIs.

We didn't change our UI definition but we started with support in Swing. Our JVxButton now has support for showing a popup menu. It could be like this one:

DropDown

DropDown

We've added some buttons to VisionX, because it reduces the amount of buttons :)

VisionX with new buttons

VisionX with new buttons

It's easy to use the new feature in your Swing application and also in your JVx application (for Swing UIs):

UIPopupMenu pmDocumentation = new UIPopupMenu();
pmDocumentation.setTranslation(getLauncher().getTranslation());
       
pmDocumentation.add(miHelp);
pmDocumentation.add(miSpecification);
       
((JVxButton)butDocumentation.getResource()).setPopupMenu((JPopupMenu)pmDocumentation.getResource());
       
//because we add the resource
pmDocumentation.addNotify();

There are some things to know:

  • Set the translation because the resource is added and the UIPopupMenu doesn't have a parent.
  • Call addNotify to enable translation (same problem because of missing parent)
  • You should check if the resource of the button is an instance of JVxButton to be UI technology independent

If you work with above code, you'll have all JVx features like simple event handling or translation.

Leave a Reply

Spam protection by WP Captcha-Free