JToolBar

Client properties:
 

General

The Quaqua Look and Feel supports toolbars with borderless buttons. JButton's and JToggleButton's can be represented using their various styles. In addition, JToggleButton's on JToolBar's support the style toolBarTab. This style is useful, when an application provides multiple views.

The picture and code snippets below shows a variety of styles for JToolBar's and how to achieve them.

Example 1

A floatable JToolBar on the left, containing three JButtons, a JSeparator and three JToggleButtons. All buttons have an icon, but no text. The JSeparator was created using method addSeparator of the JToolBar.

Design Notice: Mac OS X applications usually do not use floatable tool bars, but use floating palette windows instead.

Quaqua Look and Feel - JToolBar
 

JToolBar toolBar = new JToolBar();

toolBar.setFloatable(true);

...

toolBar.addSeparator();

 

JToggleButton videoButton = new JToggleButton();

videoButton.setIcon(anIcon);

videoButton.setText(null);

toolBar.add(videoButton);

Example 2

A non-floatable JToolBar placed on the top, containing three JButtons, a JSeparator and three JToggleButtons. All buttons have text only.

Quaqua Look and Feel - JToolBar
 

JToolBar toolBar = new JToolBar();

...

toolBar.addSeparator();

 

JToggleButton videoButton = new JToggleButton();

videoButton.setIcon(null);

videoButton.setText("Video");

toolBar.add(videoButton);

 

Example 3

A non-floatable JToolBar placed on the top, containing three JButtons, a JSeparator and three JToggleButtons. All buttons have an icon and text placed below the icon. The JToggleButtons use the client property Quaqua.Button.style set to toolBarTab.

Quaqua Look and Feel - JToolBar
 

JToolBar toolBar = new JToolBar();

toolBar.setFloatable(false);

...

toolBar.addSeparator();

 

JToggleButton videoButton = new JToggleButton();

videoButton.setIcon(anIcon);

videoButton.setText("Video");

videoButton.setVerticalTextPosition(SwingConstants.BOTTOM);

videoButton.setHorizontalTextPosition(SwingConstants.CENTER);

videoButton.putClientProperty(

   "Quaqua.Button.style", "toolBarTab"

);

toolBar.add(videoButton);

 

Example 4

A non-floatable JToolBar placed on the top, containing three JButtons, a JSeparator and three JToggleButtons. All buttons have text only, the font is set to Lucida Grande 11 (the AHIG "Small system font"). The JToggleButtons use the client property Quaqua.Button.style to create a "segmented control" look.

Quaqua Look and Feel - JToolBar
 

JToolBar toolBar = new JToolBar();

toolBar.setFloatable(false);

...

toolBar.addSeparator();

 

Font smallSystemFont = new Font("Lucide Grande", Font.PLAIN, 11);

 

JToggleButton videoButton = new JToggleButton();

videoButton.setText("Video");

videoButton.setFont(smallSystemFont);

videoButton.putClientProperty(

   "Quaqua.Button.style", "toggleWest"

);

toolBar.add(videoButton);

 

JToggleButton structButton = new JToggleButton();

structButton.setText("Struct");

structButton.setFont(smallSystemFont);

structButton.putClientProperty(

   "Quaqua.Button.style", "toggleCenter"

);

toolBar.add(structButton);

 

JToggleButton binaryButton = new JToggleButton();

binaryButton.setText("Binary");

binaryButton.setFont(smallSystemFont);

binaryButton.putClientProperty(

   "Quaqua.Button.style", "toggleEast"

);

toolBar.add(binaryButton);