Description |
Client property name for specifying that when a single tabbed pane / all
tabbed panes is layed-out vertically, the tab icons remain unrotated. This
property can be specified on a single tab component, on a
JTabbedPane itself (will hold
for all tab components that don't define this property) or on
UIManager . The value should be
either Boolean.TRUE or
Boolean.FALSE . By default, the
vertically oriented tabs will have the rotated icons. In case the icon
internal layout has horizontal / vertical meaning, using this property
with value Boolean.TRUE will
preserve the icon orientation. Note that this setting is only relevant for
tabs marked with
SubstanceLookAndFeel.TABBED_PANE_VERTICAL_ORIENTATION property.
|
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_ROTATE_ICONS}
* client property.
*
* @author Kirill Grouchnikov
* @see SubstanceLookAndFeel#TABBED_PANE_VERTICAL_ORIENTATION_ROTATE_ICONS
*/
public class TabbedPaneVerticalOrientationRotateIcons extends JFrame {
/**
* Creates the main frame for <code>this</code> sample.
*/
public TabbedPaneVerticalOrientationRotateIcons() {
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);
// mark tabbed pane to have tabs with vertical orientation
jtp.putClientProperty(
SubstanceLookAndFeel.TABBED_PANE_VERTICAL_ORIENTATION,
Boolean.TRUE);
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 isVerticalRotatedIcons = new JCheckBox("Icons rotated");
isVerticalRotatedIcons
.setSelected(Boolean.TRUE
.equals(jtp
.getClientProperty(SubstanceLookAndFeel.TABBED_PANE_VERTICAL_ORIENTATION_ROTATE_ICONS)));
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();
}
});
isVerticalRotatedIcons.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// based on the checkbox selection, mark tabbed pane to have
// icons oriented vertically as well
jtp
.putClientProperty(
SubstanceLookAndFeel.TABBED_PANE_VERTICAL_ORIENTATION_ROTATE_ICONS,
isVerticalRotatedIcons.isSelected() ? Boolean.TRUE
: null);
jtp.revalidate();
jtp.repaint();
}
});
controls.add(isOnLeft);
controls.add(isVerticalRotatedIcons);
this.add(controls, BorderLayout.SOUTH);
this.setSize(400, 200);
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[] args) throws Exception {
UIManager.setLookAndFeel(new SubstanceLookAndFeel());
JFrame.setDefaultLookAndFeelDecorated(true);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new TabbedPaneVerticalOrientationRotateIcons().setVisible(true);
}
});
}
}
The screenshot below shows tabbed pane with left placement,
vertically-oriented tabs and non-rotated icons - this property is not set:
The screenshot below shows tabbed pane with left placement,
vertically-oriented tabs and rotated icons - this property is set to
Boolean.TRUE :
The screenshot below shows tabbed pane with right placement,
vertically-oriented tabs and rotated icons - this property is set to
Boolean.TRUE :
|