Flamingo component suite 3.0 – command buttons

December 3rd, 2007

One of the basic building blocks in the Flamingo component suite is the command button component. Extending the existing core push button, it adds significant functionality, such as support for split and menu button modes, resizable icons, flexible dynamic layout, custom popup panels and more. The official documentation has the detailed walkthrough, and here i will give a short overview of some of the main features.

As noted earlier, all Flamingo components are written to look consistent under existing core and third-party look-and-feels. While the screenshots in this post show the command button under the default Ocean look-and-feel, you can use this component under any other look-and-feel that your application is using.

The first screenshot shows a command button under different states. Note how the icon size, the layout and the text presence change – this allows the application and the layout manager to make effective decisions on how to best utilize the available screen estate:

In addition to the usual “action area” (which is the entire button area under the default kind – the same as the core JButton component), the command button can have the “popup area”:

The actual division between the action area and popup area depends on the button kind – in the screenshots below notice the difference in the second row. The Cut button is defined to treat the text as part of the action area, while the Copy button is defined to treat the text as part of the popup area:

There are two ways to configure what happens when the popup area is activated. The first way is the simple one – configure a listener that gets called when a popup menu is about to be shown. The application code doesn’t need to worry about the menu creation, location or lifecycle.

The second, and much more powerful method is to attach a popup panel to the command button. The popup panel allows showing any Swing component / container in a popup window:

As with the simpler core popup menus, the popup panels can be cascaded, dismissed with ESC key or mouse events and are accessible via a global manager (API + registering listeners).

You’re welcome to play with the latest 3.0dev drop of Flamingo and read the detailed documentation.