mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 06:27:13 -06:00
TabbedPane: support horizontal alignment of tab title and icon
This commit is contained in:
@@ -53,10 +53,15 @@ class TabsPanel
|
||||
initTabIconPlacement( iconLeadingTabbedPane, SwingConstants.LEADING );
|
||||
initTabIconPlacement( iconTrailingTabbedPane, SwingConstants.TRAILING );
|
||||
|
||||
initTabAreaAlignment( alignLeadingTabbedPane, TABBED_PANE_TAB_AREA_ALIGN_LEADING );
|
||||
initTabAreaAlignment( alignCenterTabbedPane, TABBED_PANE_TAB_AREA_ALIGN_CENTER );
|
||||
initTabAreaAlignment( alignTrailingTabbedPane, TABBED_PANE_TAB_AREA_ALIGN_TRAILING );
|
||||
initTabAreaAlignment( alignFillTabbedPane, TABBED_PANE_TAB_AREA_ALIGN_FILL );
|
||||
initTabAreaAlignment( alignLeadingTabbedPane, TABBED_PANE_ALIGN_LEADING );
|
||||
initTabAreaAlignment( alignCenterTabbedPane, TABBED_PANE_ALIGN_CENTER );
|
||||
initTabAreaAlignment( alignTrailingTabbedPane, TABBED_PANE_ALIGN_TRAILING );
|
||||
initTabAreaAlignment( alignFillTabbedPane, TABBED_PANE_ALIGN_FILL );
|
||||
|
||||
initTabAlignment( tabAlignLeadingTabbedPane, SwingConstants.LEADING );
|
||||
initTabAlignment( tabAlignCenterTabbedPane, SwingConstants.CENTER );
|
||||
initTabAlignment( tabAlignTrailingTabbedPane, SwingConstants.TRAILING );
|
||||
initTabAlignment( tabAlignVerticalTabbedPane, SwingConstants.TRAILING );
|
||||
|
||||
initTabWidthMode( widthPreferredTabbedPane, TABBED_PANE_TAB_WIDTH_MODE_PREFERRED );
|
||||
initTabWidthMode( widthEqualTabbedPane, TABBED_PANE_TAB_WIDTH_MODE_EQUAL );
|
||||
@@ -223,7 +228,7 @@ class TabsPanel
|
||||
int iconSize = topOrBottom ? 24 : 16;
|
||||
tabbedPane.putClientProperty( TABBED_PANE_TAB_ICON_PLACEMENT, iconPlacement );
|
||||
if( topOrBottom ) {
|
||||
tabbedPane.putClientProperty( TABBED_PANE_TAB_AREA_ALIGNMENT, TABBED_PANE_TAB_AREA_ALIGN_FILL );
|
||||
tabbedPane.putClientProperty( TABBED_PANE_TAB_AREA_ALIGNMENT, TABBED_PANE_ALIGN_FILL );
|
||||
tabbedPane.putClientProperty( TABBED_PANE_TAB_WIDTH_MODE, TABBED_PANE_TAB_WIDTH_MODE_EQUAL );
|
||||
}
|
||||
tabbedPane.addTab( "Search", new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/search.svg", iconSize, iconSize ), null );
|
||||
@@ -238,6 +243,18 @@ class TabsPanel
|
||||
tabbedPane.addTab( "Recents", null );
|
||||
}
|
||||
|
||||
private void initTabAlignment( JTabbedPane tabbedPane, int tabAlignment ) {
|
||||
boolean vertical = (tabbedPane.getTabPlacement() == JTabbedPane.LEFT || tabbedPane.getTabPlacement() == JTabbedPane.RIGHT);
|
||||
tabbedPane.putClientProperty( TABBED_PANE_TAB_ALIGNMENT, tabAlignment );
|
||||
if( !vertical )
|
||||
tabbedPane.putClientProperty( TABBED_PANE_MINIMUM_TAB_WIDTH, 80 );
|
||||
tabbedPane.addTab( "A", null );
|
||||
if( vertical ) {
|
||||
tabbedPane.addTab( "Search", null );
|
||||
tabbedPane.addTab( "Recents", null );
|
||||
}
|
||||
}
|
||||
|
||||
private void initTabWidthMode( JTabbedPane tabbedPane, String tabWidthMode ) {
|
||||
tabbedPane.putClientProperty( TABBED_PANE_TAB_WIDTH_MODE, tabWidthMode );
|
||||
if( tabWidthMode.equals( TABBED_PANE_TAB_WIDTH_MODE_COMPACT ) ) {
|
||||
@@ -337,6 +354,14 @@ class TabsPanel
|
||||
JLabel minMaxTabWidthLabel = new JLabel();
|
||||
minimumTabWidthTabbedPane = new JTabbedPane();
|
||||
maximumTabWidthTabbedPane = new JTabbedPane();
|
||||
JLabel tabAlignmentLabel = new JLabel();
|
||||
panel5 = new JPanel();
|
||||
JLabel tabAlignmentNoteLabel = new JLabel();
|
||||
JLabel tabAlignmentNoteLabel2 = new JLabel();
|
||||
tabAlignLeadingTabbedPane = new JTabbedPane();
|
||||
tabAlignVerticalTabbedPane = new JTabbedPane();
|
||||
tabAlignCenterTabbedPane = new JTabbedPane();
|
||||
tabAlignTrailingTabbedPane = new JTabbedPane();
|
||||
JPanel panel4 = new JPanel();
|
||||
showTabSeparatorsCheckBox = new JCheckBox();
|
||||
|
||||
@@ -681,6 +706,8 @@ class TabsPanel
|
||||
"[]para" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]para" +
|
||||
"[]0" +
|
||||
"[]"));
|
||||
|
||||
//---- tabWidthModeLabel ----
|
||||
@@ -731,6 +758,67 @@ class TabsPanel
|
||||
maximumTabWidthTabbedPane.setName("maximumTabWidthTabbedPane");
|
||||
}
|
||||
panel3.add(maximumTabWidthTabbedPane, "cell 0 7");
|
||||
|
||||
//---- tabAlignmentLabel ----
|
||||
tabAlignmentLabel.setText("Tab title alignment");
|
||||
tabAlignmentLabel.setFont(tabAlignmentLabel.getFont().deriveFont(tabAlignmentLabel.getFont().getSize() + 4f));
|
||||
tabAlignmentLabel.setName("tabAlignmentLabel");
|
||||
panel3.add(tabAlignmentLabel, "cell 0 8");
|
||||
|
||||
//======== panel5 ========
|
||||
{
|
||||
panel5.setName("panel5");
|
||||
panel5.setLayout(new MigLayout(
|
||||
"insets 0,hidemode 3",
|
||||
// columns
|
||||
"[grow,fill]para" +
|
||||
"[fill]",
|
||||
// rows
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]"));
|
||||
|
||||
//---- tabAlignmentNoteLabel ----
|
||||
tabAlignmentNoteLabel.setText("(leading/center/trailing)");
|
||||
tabAlignmentNoteLabel.setEnabled(false);
|
||||
tabAlignmentNoteLabel.setFont(tabAlignmentNoteLabel.getFont().deriveFont(tabAlignmentNoteLabel.getFont().getSize() - 2f));
|
||||
tabAlignmentNoteLabel.setName("tabAlignmentNoteLabel");
|
||||
panel5.add(tabAlignmentNoteLabel, "cell 0 0");
|
||||
|
||||
//---- tabAlignmentNoteLabel2 ----
|
||||
tabAlignmentNoteLabel2.setText("(trailing)");
|
||||
tabAlignmentNoteLabel2.setEnabled(false);
|
||||
tabAlignmentNoteLabel2.setFont(tabAlignmentNoteLabel2.getFont().deriveFont(tabAlignmentNoteLabel2.getFont().getSize() - 2f));
|
||||
tabAlignmentNoteLabel2.setName("tabAlignmentNoteLabel2");
|
||||
panel5.add(tabAlignmentNoteLabel2, "cell 1 0,alignx right,growx 0");
|
||||
|
||||
//======== tabAlignLeadingTabbedPane ========
|
||||
{
|
||||
tabAlignLeadingTabbedPane.setName("tabAlignLeadingTabbedPane");
|
||||
}
|
||||
panel5.add(tabAlignLeadingTabbedPane, "cell 0 1");
|
||||
|
||||
//======== tabAlignVerticalTabbedPane ========
|
||||
{
|
||||
tabAlignVerticalTabbedPane.setTabPlacement(SwingConstants.LEFT);
|
||||
tabAlignVerticalTabbedPane.setName("tabAlignVerticalTabbedPane");
|
||||
}
|
||||
panel5.add(tabAlignVerticalTabbedPane, "cell 1 1 1 3,growy");
|
||||
|
||||
//======== tabAlignCenterTabbedPane ========
|
||||
{
|
||||
tabAlignCenterTabbedPane.setName("tabAlignCenterTabbedPane");
|
||||
}
|
||||
panel5.add(tabAlignCenterTabbedPane, "cell 0 2");
|
||||
|
||||
//======== tabAlignTrailingTabbedPane ========
|
||||
{
|
||||
tabAlignTrailingTabbedPane.setName("tabAlignTrailingTabbedPane");
|
||||
}
|
||||
panel5.add(tabAlignTrailingTabbedPane, "cell 0 3");
|
||||
}
|
||||
panel3.add(panel5, "cell 0 9");
|
||||
}
|
||||
add(panel3, "cell 2 0");
|
||||
|
||||
@@ -759,16 +847,16 @@ class TabsPanel
|
||||
tabPlacementButtonGroup.add(leftPlacementButton);
|
||||
tabPlacementButtonGroup.add(rightPlacementButton);
|
||||
|
||||
//---- buttonGroup2 ----
|
||||
ButtonGroup buttonGroup2 = new ButtonGroup();
|
||||
buttonGroup2.add(scrollTabLayoutButton);
|
||||
buttonGroup2.add(wrapTabLayoutButton);
|
||||
//---- tabLayoutButtonGroup ----
|
||||
ButtonGroup tabLayoutButtonGroup = new ButtonGroup();
|
||||
tabLayoutButtonGroup.add(scrollTabLayoutButton);
|
||||
tabLayoutButtonGroup.add(wrapTabLayoutButton);
|
||||
|
||||
//---- buttonGroup1 ----
|
||||
ButtonGroup buttonGroup1 = new ButtonGroup();
|
||||
buttonGroup1.add(squareCloseButton);
|
||||
buttonGroup1.add(circleCloseButton);
|
||||
buttonGroup1.add(redCrossCloseButton);
|
||||
//---- closableTabsButtonGroup ----
|
||||
ButtonGroup closableTabsButtonGroup = new ButtonGroup();
|
||||
closableTabsButtonGroup.add(squareCloseButton);
|
||||
closableTabsButtonGroup.add(circleCloseButton);
|
||||
closableTabsButtonGroup.add(redCrossCloseButton);
|
||||
// JFormDesigner - End of component initialization //GEN-END:initComponents
|
||||
}
|
||||
|
||||
@@ -810,6 +898,11 @@ class TabsPanel
|
||||
private JTabbedPane widthCompactTabbedPane;
|
||||
private JTabbedPane minimumTabWidthTabbedPane;
|
||||
private JTabbedPane maximumTabWidthTabbedPane;
|
||||
private JPanel panel5;
|
||||
private JTabbedPane tabAlignLeadingTabbedPane;
|
||||
private JTabbedPane tabAlignVerticalTabbedPane;
|
||||
private JTabbedPane tabAlignCenterTabbedPane;
|
||||
private JTabbedPane tabAlignTrailingTabbedPane;
|
||||
private JCheckBox showTabSeparatorsCheckBox;
|
||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ new FormModel {
|
||||
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||
name: "scrollTabLayoutButton"
|
||||
"text": "scroll"
|
||||
"$buttonGroup": new FormReference( "buttonGroup2" )
|
||||
"$buttonGroup": new FormReference( "tabLayoutButtonGroup" )
|
||||
"font": &SwingDerivedFont2 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false )
|
||||
"selected": true
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabLayoutChanged", false ) )
|
||||
@@ -110,7 +110,7 @@ new FormModel {
|
||||
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||
name: "wrapTabLayoutButton"
|
||||
"text": "wrap"
|
||||
"$buttonGroup": new FormReference( "buttonGroup2" )
|
||||
"$buttonGroup": new FormReference( "tabLayoutButtonGroup" )
|
||||
"font": #SwingDerivedFont2
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabLayoutChanged", false ) )
|
||||
} )
|
||||
@@ -161,7 +161,7 @@ new FormModel {
|
||||
name: "squareCloseButton"
|
||||
"text": "square"
|
||||
"font": &SwingDerivedFont4 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false )
|
||||
"$buttonGroup": new FormReference( "buttonGroup1" )
|
||||
"$buttonGroup": new FormReference( "closableTabsButtonGroup" )
|
||||
"selected": true
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "closeButtonStyleChanged", false ) )
|
||||
} )
|
||||
@@ -169,14 +169,14 @@ new FormModel {
|
||||
name: "circleCloseButton"
|
||||
"text": "circle"
|
||||
"font": #SwingDerivedFont4
|
||||
"$buttonGroup": new FormReference( "buttonGroup1" )
|
||||
"$buttonGroup": new FormReference( "closableTabsButtonGroup" )
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "closeButtonStyleChanged", false ) )
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||
name: "redCrossCloseButton"
|
||||
"text": "red cross"
|
||||
"font": #SwingDerivedFont4
|
||||
"$buttonGroup": new FormReference( "buttonGroup1" )
|
||||
"$buttonGroup": new FormReference( "closableTabsButtonGroup" )
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "closeButtonStyleChanged", false ) )
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
@@ -290,7 +290,7 @@ new FormModel {
|
||||
name: "tabAreaAlignmentNoteLabel"
|
||||
"text": "(leading/center/trailing/fill)"
|
||||
"enabled": false
|
||||
"font": new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false )
|
||||
"font": &SwingDerivedFont7 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false )
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": true
|
||||
}
|
||||
@@ -323,7 +323,7 @@ new FormModel {
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$layoutConstraints": "insets 0,hidemode 3"
|
||||
"$columnConstraints": "[grow,fill]"
|
||||
"$rowConstraints": "[]0[][][][]para[][][]"
|
||||
"$rowConstraints": "[]0[][][][]para[][][]para[]0[]"
|
||||
} ) {
|
||||
name: "panel3"
|
||||
auxiliary() {
|
||||
@@ -385,6 +385,68 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 7"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "tabAlignmentLabel"
|
||||
"text": "Tab title alignment"
|
||||
"font": #SwingDerivedFont6
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": true
|
||||
}
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 8"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[grow,fill]para[fill]"
|
||||
"$rowConstraints": "[][][][]"
|
||||
"$layoutConstraints": "insets 0,hidemode 3"
|
||||
} ) {
|
||||
name: "panel5"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "tabAlignmentNoteLabel"
|
||||
"text": "(leading/center/trailing)"
|
||||
"enabled": false
|
||||
"font": #SwingDerivedFont7
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": true
|
||||
}
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "tabAlignmentNoteLabel2"
|
||||
"text": "(trailing)"
|
||||
"enabled": false
|
||||
"font": #SwingDerivedFont7
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": true
|
||||
}
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 0,alignx right,growx 0"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
|
||||
name: "tabAlignLeadingTabbedPane"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 1"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
|
||||
name: "tabAlignVerticalTabbedPane"
|
||||
"tabPlacement": 2
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 1 1 3,growy"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
|
||||
name: "tabAlignCenterTabbedPane"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 2"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
|
||||
name: "tabAlignTrailingTabbedPane"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 3"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 9"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 0"
|
||||
} )
|
||||
@@ -412,22 +474,22 @@ new FormModel {
|
||||
} )
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 0, 0 )
|
||||
"size": new java.awt.Dimension( 925, 825 )
|
||||
"size": new java.awt.Dimension( 1075, 860 )
|
||||
} )
|
||||
add( new FormNonVisual( "javax.swing.ButtonGroup" ) {
|
||||
name: "tabPlacementButtonGroup"
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 10, 1240 )
|
||||
"location": new java.awt.Point( 5, 915 )
|
||||
} )
|
||||
add( new FormNonVisual( "javax.swing.ButtonGroup" ) {
|
||||
name: "buttonGroup1"
|
||||
name: "closableTabsButtonGroup"
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 0, 1292 )
|
||||
"location": new java.awt.Point( 5, 970 )
|
||||
} )
|
||||
add( new FormNonVisual( "javax.swing.ButtonGroup" ) {
|
||||
name: "buttonGroup2"
|
||||
name: "tabLayoutButtonGroup"
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 0, 1344 )
|
||||
"location": new java.awt.Point( 5, 1020 )
|
||||
} )
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user