Spicing up your JTabbedPane
Posted by kirillcool on October 27, 2005 at 5:20 AM EDT
My previous entry showed the way to provide visual indication of frames with changed content. Based on the suggestions from the comments, this behaviour has been also added to JTabbedPane. Application should set SubstanceLookAndFeel.WINDOW_MODIFIED client property on the tabbed pane's Component (if it's JComponent). The value that corresponds to unsaved state is Boolean.TRUE. See 67-second AVI movie (1.2 MB) illustrating the technique.
Pulsating loop on JTabbedPane - red theme (animation start):
![]()
![]()
![]()
Close button on active tab in JTabbedPane - mouse not over close button (includes mouse pointer):





- On JTabbedPane tab component itself (if it's JComponent). If the property is specified here and it's either Boolean.TRUE or Boolean.FALSE, its value is taken.
- On JTabbedPane itself. If the property is specified here and it's either Boolean.TRUE or Boolean.FALSE, its value is taken and is relevant for all tabs in this JTabbedPane that weren't found in the previous step.
- As global setting in UIManager. If the property is specified here and it's either Boolean.TRUE or Boolean.FALSE, its value is taken and is relevant for all tabs in all JTabbedPanes that weren't found in the previous two steps.
JTabbedPane pane = new JTabbedPane(); JPanel component = new JPanel(); component.putClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY, Boolean.TRUE); pane.addTab(component); JPanel component2 = new JPanel(); // Will not have close button unless the tabbed pane itself specifies // Boolean.TRUE as value for its client property or UIManager.put is // called on this property with Boolean.TRUE pane.addTab(component2);Once again - the behaviour is not disruptive. If you don't specify this property anywhere, you will not have close buttons on your tabs. This will allow Java 6.0 applications that set custom tab header components to continue working correctly.
As always, you can run a Web Start demo or download the latest Substance 2.1 development drop from here.
Related Topics >>
Blog Links >>
- Login or register to post comments
- Printer-friendly version
- kirillcool's blog
- 4897 reads





