mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-08 06:50:56 +03:00
TabbedPane: support horizontal alignment of tab title and icon
This commit is contained in:
@@ -937,6 +937,7 @@ TabbedPane.selectedTabPadInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI
|
||||
TabbedPane.selectionFollowsFocus true
|
||||
TabbedPane.shadow #3c3f41 javax.swing.plaf.ColorUIResource [UI]
|
||||
TabbedPane.showTabSeparators false
|
||||
TabbedPane.tabAlignment center
|
||||
TabbedPane.tabAreaAlignment leading
|
||||
TabbedPane.tabAreaInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
|
||||
TabbedPane.tabHeight 32
|
||||
|
||||
@@ -942,6 +942,7 @@ TabbedPane.selectedTabPadInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI
|
||||
TabbedPane.selectionFollowsFocus true
|
||||
TabbedPane.shadow #f2f2f2 javax.swing.plaf.ColorUIResource [UI]
|
||||
TabbedPane.showTabSeparators false
|
||||
TabbedPane.tabAlignment center
|
||||
TabbedPane.tabAreaAlignment leading
|
||||
TabbedPane.tabAreaInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
|
||||
TabbedPane.tabHeight 32
|
||||
|
||||
@@ -932,6 +932,7 @@ TabbedPane.selectedTabPadInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI
|
||||
TabbedPane.selectionFollowsFocus true
|
||||
TabbedPane.shadow #ccffcc javax.swing.plaf.ColorUIResource [UI]
|
||||
TabbedPane.showTabSeparators false
|
||||
TabbedPane.tabAlignment center
|
||||
TabbedPane.tabAreaAlignment leading
|
||||
TabbedPane.tabAreaInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
|
||||
TabbedPane.tabHeight 32
|
||||
|
||||
@@ -276,6 +276,17 @@ public class FlatContainerTest
|
||||
putTabbedPanesClientProperty( TABBED_PANE_TAB_AREA_ALIGNMENT, value );
|
||||
}
|
||||
|
||||
private void tabAlignmentChanged() {
|
||||
String value = (String) tabAlignmentField.getSelectedItem();
|
||||
Integer tabAlignment = null;
|
||||
switch( value ) {
|
||||
case "center": tabAlignment = SwingConstants.CENTER; break;
|
||||
case "leading": tabAlignment = SwingConstants.LEADING; break;
|
||||
case "trailing": tabAlignment = SwingConstants.TRAILING; break;
|
||||
}
|
||||
putTabbedPanesClientProperty( TABBED_PANE_TAB_ALIGNMENT, tabAlignment );
|
||||
}
|
||||
|
||||
private void tabWidthModeChanged() {
|
||||
String value = (String) tabWidthModeField.getSelectedItem();
|
||||
if( "default".equals( value ) )
|
||||
@@ -416,6 +427,7 @@ public class FlatContainerTest
|
||||
iconPlacementField = new JComboBox<>();
|
||||
JLabel tabAreaAlignmentLabel = new JLabel();
|
||||
tabAreaAlignmentField = new JComboBox<>();
|
||||
tabAlignmentField = new JComboBox<>();
|
||||
JLabel tabWidthModeLabel = new JLabel();
|
||||
tabWidthModeField = new JComboBox<>();
|
||||
tabsClosableCheckBox = new JCheckBox();
|
||||
@@ -637,7 +649,7 @@ public class FlatContainerTest
|
||||
tabbedPaneControlPanel.add(iconPlacementField, "cell 2 2");
|
||||
|
||||
//---- tabAreaAlignmentLabel ----
|
||||
tabAreaAlignmentLabel.setText("Tab area alignment:");
|
||||
tabAreaAlignmentLabel.setText("Tab area/title alignment:");
|
||||
tabbedPaneControlPanel.add(tabAreaAlignmentLabel, "cell 0 3");
|
||||
|
||||
//---- tabAreaAlignmentField ----
|
||||
@@ -651,6 +663,16 @@ public class FlatContainerTest
|
||||
tabAreaAlignmentField.addActionListener(e -> tabAreaAlignmentChanged());
|
||||
tabbedPaneControlPanel.add(tabAreaAlignmentField, "cell 1 3");
|
||||
|
||||
//---- tabAlignmentField ----
|
||||
tabAlignmentField.setModel(new DefaultComboBoxModel<>(new String[] {
|
||||
"default",
|
||||
"leading",
|
||||
"trailing",
|
||||
"center"
|
||||
}));
|
||||
tabAlignmentField.addActionListener(e -> tabAlignmentChanged());
|
||||
tabbedPaneControlPanel.add(tabAlignmentField, "cell 1 3");
|
||||
|
||||
//---- tabWidthModeLabel ----
|
||||
tabWidthModeLabel.setText("Tab width mode:");
|
||||
tabbedPaneControlPanel.add(tabWidthModeLabel, "cell 2 3");
|
||||
@@ -760,6 +782,7 @@ public class FlatContainerTest
|
||||
private JSpinner tabIconSizeSpinner;
|
||||
private JComboBox<String> iconPlacementField;
|
||||
private JComboBox<String> tabAreaAlignmentField;
|
||||
private JComboBox<String> tabAlignmentField;
|
||||
private JComboBox<String> tabWidthModeField;
|
||||
private JCheckBox tabsClosableCheckBox;
|
||||
private JCheckBox customBorderCheckBox;
|
||||
|
||||
@@ -300,7 +300,7 @@ new FormModel {
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "tabAreaAlignmentLabel"
|
||||
"text": "Tab area alignment:"
|
||||
"text": "Tab area/title alignment:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 3"
|
||||
} )
|
||||
@@ -322,6 +322,23 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 3"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JComboBox" ) {
|
||||
name: "tabAlignmentField"
|
||||
"model": new javax.swing.DefaultComboBoxModel {
|
||||
selectedItem: "default"
|
||||
addElement( "default" )
|
||||
addElement( "leading" )
|
||||
addElement( "trailing" )
|
||||
addElement( "center" )
|
||||
}
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
"JavaCodeGenerator.typeParameters": "String"
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabAlignmentChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 3"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "tabWidthModeLabel"
|
||||
"text": "Tab width mode:"
|
||||
|
||||
Reference in New Issue
Block a user