Substance client properties

View all API methods.

View all client properties.


Client property name

SubstanceLookAndFeel.TABBED_PANE_VERTICAL_ORIENTATION

Description

Client property name for specifying that a single tabbed pane / all tabbed panes should have vertical layout (rotated tabs) on SwingConstants.LEFT and SwingConstants.RIGHT tab placements. This property can be specified either on a single JTabbedPane or on UIManager. The value should be either Boolean.TRUE or Boolean.FALSE. By default, the tab orientation on all placements is horizontal.


See also


Sample code

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import org.jvnet.substance.SubstanceLookAndFeel;

import test.Check;

/**
 * Test application that shows the use of the
 {@link SubstanceLookAndFeel#TABBED_PANE_VERTICAL_ORIENTATION} client
 * property.
 
 @author Kirill Grouchnikov
 @see SubstanceLookAndFeel#TABBED_PANE_VERTICAL_ORIENTATION
 */
public class TabbedPaneVerticalOrientation extends JFrame {
  /**
   * Creates the main frame for <code>this</code> sample.
   */
  public TabbedPaneVerticalOrientation() {
    super("Tabbed pane vertical orientation");

    this.setLayout(new BorderLayout());

    // create tabbed pane with a few tabs
    final JTabbedPane jtp = new JTabbedPane();
    jtp.addTab("First", Check.getIcon("flag_mexico")new JPanel());
    jtp.addTab("Second", Check.getIcon("flag_sweden")new JPanel());
    jtp.addTab("Third", Check.getIcon("flag_hong_kong")new JPanel());
    // set tab placement to left   
    jtp.setTabPlacement(JTabbedPane.LEFT);

    this.add(jtp, BorderLayout.CENTER);

    JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    final JCheckBox isOnLeft = new JCheckBox("Is on left");
    isOnLeft.setSelected(jtp.getTabPlacement() == JTabbedPane.LEFT);
    final JCheckBox isVertical = new JCheckBox("Is vertical");
    isVertical
        .setSelected(Boolean.TRUE
            .equals(jtp
                .getClientProperty(SubstanceLookAndFeel.TABBED_PANE_VERTICAL_ORIENTATION)));
    isOnLeft.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        // based on the checkbox selection, set tab placement to
        // left or right
        jtp.setTabPlacement(isOnLeft.isSelected() ? JTabbedPane.LEFT
            : JTabbedPane.RIGHT);
        jtp.revalidate();
        jtp.repaint();
      }
    });
    isVertical.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        // based on the checkbox selection, set tabbed pane to vertical
        // orientation
        jtp.putClientProperty(
            SubstanceLookAndFeel.TABBED_PANE_VERTICAL_ORIENTATION,
            isVertical.isSelected() ? Boolean.TRUE : null);
        jtp.revalidate();
        jtp.repaint();
      }
    });

    controls.add(isOnLeft);
    controls.add(isVertical);
    this.add(controls, BorderLayout.SOUTH);

    this.setSize(400200);
    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }

  /**
   * The main method for <code>this</code> sample. The arguments are
   * ignored.
   
   @param args
   *            Ignored.
   @throws Exception
   *             If some exception occured. Note that there is no special
   *             treatment of exception conditions in <code>this</code>
   *             sample code.
   */
  public static void main(String[] argsthrows Exception {
    UIManager.setLookAndFeel(new SubstanceLookAndFeel());
    JFrame.setDefaultLookAndFeelDecorated(true);
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        new TabbedPaneVerticalOrientation().setVisible(true);
      }
    });
  }
}

The screenshot below shows tabbed pane with left placement and horizontally-oriented tabs - this property is not set:

The screenshot below shows tabbed pane with left placement and vertically-oriented tabs - this property is set to Boolean.TRUE:

The screenshot below shows tabbed pane with right placement and vertically-oriented tabs - this property is set to Boolean.TRUE: