TabbedPane:

- made tabs separator color lighter in dark themes so that it is easier to recognize the tabbed pane
- added top and bottom tab insets to avoid that large tab icons are painted over active tab underline
This commit is contained in:
Karl Tauber
2020-09-24 15:18:45 +02:00
parent d52bf9d318
commit d83c3689d0
8 changed files with 89 additions and 12 deletions

View File

@@ -1,6 +1,16 @@
FlatLaf Change Log
==================
## Unreleased
#### New features and improvements
- TabbedPane: Made tabs separator color lighter in dark themes so that it is
easier to recognize the tabbed pane.
- TabbedPane: Added top and bottom tab insets to avoid that large tab icons are
painted over active tab underline.
## 0.42
#### New features and improvements

View File

@@ -257,7 +257,7 @@ TabbedPane.underlineColor=#4A88C7
TabbedPane.disabledUnderlineColor=#7a7a7a
TabbedPane.hoverColor=#2e3133
TabbedPane.focusColor=#3d4b5c
TabbedPane.contentAreaColor=#323232
TabbedPane.contentAreaColor=#646464
#---- Table ----

View File

@@ -539,7 +539,7 @@ TabbedPane.tabHeight=32
TabbedPane.tabSelectionHeight=3
TabbedPane.contentSeparatorHeight=1
TabbedPane.hasFullBorder=false
TabbedPane.tabInsets=0,12,0,12
TabbedPane.tabInsets=4,12,4,12
TabbedPane.tabAreaInsets=0,0,0,0
TabbedPane.selectedTabPadInsets=0,0,0,0
TabbedPane.tabRunOverlay=0

View File

@@ -445,7 +445,7 @@ JideTabbedPane.foreground #bbbbbb javax.swing.plaf.ColorUIResource [UI]
JideTabbedPane.shadow #3c3f41 javax.swing.plaf.ColorUIResource [UI]
JideTabbedPane.tabAreaBackground #3c3f41 javax.swing.plaf.ColorUIResource [UI]
JideTabbedPane.tabAreaInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
JideTabbedPane.tabInsets 0,12,0,12 javax.swing.plaf.InsetsUIResource [UI]
JideTabbedPane.tabInsets 4,12,4,12 javax.swing.plaf.InsetsUIResource [UI]
JideTabbedPane.tabRunOverlay 0
JideTabbedPaneUI com.formdev.flatlaf.jideoss.ui.FlatJideTabbedPaneUI
@@ -905,7 +905,7 @@ SplitPaneUI com.formdev.flatlaf.ui.FlatSplitPaneUI
#---- TabbedPane ----
TabbedPane.background #3c3f41 javax.swing.plaf.ColorUIResource [UI]
TabbedPane.contentAreaColor #323232 javax.swing.plaf.ColorUIResource [UI]
TabbedPane.contentAreaColor #646464 javax.swing.plaf.ColorUIResource [UI]
TabbedPane.contentOpaque true
TabbedPane.contentSeparatorHeight 1
TabbedPane.darkShadow #7e7e7e javax.swing.plaf.ColorUIResource [UI]
@@ -926,7 +926,7 @@ TabbedPane.selectionFollowsFocus true
TabbedPane.shadow #3c3f41 javax.swing.plaf.ColorUIResource [UI]
TabbedPane.tabAreaInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
TabbedPane.tabHeight 32
TabbedPane.tabInsets 0,12,0,12 javax.swing.plaf.InsetsUIResource [UI]
TabbedPane.tabInsets 4,12,4,12 javax.swing.plaf.InsetsUIResource [UI]
TabbedPane.tabRunOverlay 0
TabbedPane.tabSelectionHeight 3
TabbedPane.tabsOpaque true

View File

@@ -450,7 +450,7 @@ JideTabbedPane.foreground #000000 javax.swing.plaf.ColorUIResource [UI]
JideTabbedPane.shadow #f2f2f2 javax.swing.plaf.ColorUIResource [UI]
JideTabbedPane.tabAreaBackground #f2f2f2 javax.swing.plaf.ColorUIResource [UI]
JideTabbedPane.tabAreaInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
JideTabbedPane.tabInsets 0,12,0,12 javax.swing.plaf.InsetsUIResource [UI]
JideTabbedPane.tabInsets 4,12,4,12 javax.swing.plaf.InsetsUIResource [UI]
JideTabbedPane.tabRunOverlay 0
JideTabbedPaneUI com.formdev.flatlaf.jideoss.ui.FlatJideTabbedPaneUI
@@ -931,7 +931,7 @@ TabbedPane.selectionFollowsFocus true
TabbedPane.shadow #f2f2f2 javax.swing.plaf.ColorUIResource [UI]
TabbedPane.tabAreaInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
TabbedPane.tabHeight 32
TabbedPane.tabInsets 0,12,0,12 javax.swing.plaf.InsetsUIResource [UI]
TabbedPane.tabInsets 4,12,4,12 javax.swing.plaf.InsetsUIResource [UI]
TabbedPane.tabRunOverlay 0
TabbedPane.tabSelectionHeight 3
TabbedPane.tabsOpaque true

View File

@@ -438,7 +438,7 @@ JideTabbedPane.foreground #ff0000 javax.swing.plaf.ColorUIResource [UI]
JideTabbedPane.shadow #ccffcc javax.swing.plaf.ColorUIResource [UI]
JideTabbedPane.tabAreaBackground #ccffcc javax.swing.plaf.ColorUIResource [UI]
JideTabbedPane.tabAreaInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
JideTabbedPane.tabInsets 0,12,0,12 javax.swing.plaf.InsetsUIResource [UI]
JideTabbedPane.tabInsets 4,12,4,12 javax.swing.plaf.InsetsUIResource [UI]
JideTabbedPane.tabRunOverlay 0
JideTabbedPaneUI com.formdev.flatlaf.jideoss.ui.FlatJideTabbedPaneUI
@@ -921,7 +921,7 @@ TabbedPane.selectionFollowsFocus true
TabbedPane.shadow #ccffcc javax.swing.plaf.ColorUIResource [UI]
TabbedPane.tabAreaInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
TabbedPane.tabHeight 32
TabbedPane.tabInsets 0,12,0,12 javax.swing.plaf.InsetsUIResource [UI]
TabbedPane.tabInsets 4,12,4,12 javax.swing.plaf.InsetsUIResource [UI]
TabbedPane.tabRunOverlay 0
TabbedPane.tabSelectionHeight 3
TabbedPane.tabSeparatorColor #0000ff javax.swing.plaf.ColorUIResource [UI]

View File

@@ -131,6 +131,27 @@ public class FlatContainerTest
return tab;
}
private void tabIconsChanged() {
boolean showTabIcons = tabIconsCheckBox.isSelected();
setTabIcons( tabbedPane1, showTabIcons );
setTabIcons( tabbedPane2, showTabIcons );
setTabIcons( tabbedPane3, showTabIcons );
setTabIcons( tabbedPane4, showTabIcons );
tabIconSizeSpinner.setEnabled( showTabIcons );
}
private void setTabIcons( JTabbedPane tabbedPane, boolean showTabIcons ) {
Object iconSize = tabIconSizeSpinner.getValue();
Icon icon = showTabIcons
? new ImageIcon( getClass().getResource( "/com/formdev/flatlaf/testing/test" + iconSize + ".png" ) )
: null;
tabbedPane.setIconAt( 0, icon );
tabbedPane.setIconAt( 1, icon );
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JPanel panel9 = new JPanel();
@@ -154,6 +175,8 @@ public class FlatContainerTest
tabScrollCheckBox = new JCheckBox();
showTabSeparatorsCheckBox = new JCheckBox();
hasFullBorderCheckBox = new JCheckBox();
tabIconsCheckBox = new JCheckBox();
tabIconSizeSpinner = new JSpinner();
CellConstraints cc = new CellConstraints();
//======== this ========
@@ -262,7 +285,9 @@ public class FlatContainerTest
"[]" +
"[]" +
"[]" +
"[]",
"[]" +
"[fill]" +
"[fill]",
// rows
"[center]"));
@@ -287,6 +312,17 @@ public class FlatContainerTest
hasFullBorderCheckBox.setText("Show content border");
hasFullBorderCheckBox.addActionListener(e -> hasFullBorderChanged());
panel14.add(hasFullBorderCheckBox, "cell 3 0,alignx left,growx 0");
//---- tabIconsCheckBox ----
tabIconsCheckBox.setText("Tab icons");
tabIconsCheckBox.addActionListener(e -> tabIconsChanged());
panel14.add(tabIconsCheckBox, "cell 4 0");
//---- tabIconSizeSpinner ----
tabIconSizeSpinner.setModel(new SpinnerListModel(new String[] {"16", "24", "32", "48", "64"}));
tabIconSizeSpinner.setEnabled(false);
tabIconSizeSpinner.addChangeListener(e -> tabIconsChanged());
panel14.add(tabIconSizeSpinner, "cell 5 0");
}
panel9.add(panel14, cc.xywh(1, 11, 3, 1));
}
@@ -303,6 +339,8 @@ public class FlatContainerTest
private JCheckBox tabScrollCheckBox;
private JCheckBox showTabSeparatorsCheckBox;
private JCheckBox hasFullBorderCheckBox;
private JCheckBox tabIconsCheckBox;
private JSpinner tabIconSizeSpinner;
// JFormDesigner - End of variables declaration //GEN-END:variables
//---- class Tab1Panel ----------------------------------------------------

View File

@@ -1,4 +1,4 @@
JFDML JFormDesigner: "7.0.2.0.298" Java: "14" encoding: "UTF-8"
JFDML JFormDesigner: "7.0.2.0.298" Java: "15" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
@@ -131,7 +131,7 @@ new FormModel {
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 0,hidemode 3"
"$columnConstraints": "[][][][]"
"$columnConstraints": "[][][][][fill][fill]"
"$rowConstraints": "[center]"
} ) {
name: "panel14"
@@ -178,6 +178,35 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 0,alignx left,growx 0"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "tabIconsCheckBox"
"text": "Tab icons"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabIconsChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 0"
} )
add( new FormComponent( "javax.swing.JSpinner" ) {
name: "tabIconSizeSpinner"
"model": new javax.swing.SpinnerListModel {
list: new java.util.ArrayList {
add( "16" )
add( "24" )
add( "32" )
add( "48" )
add( "64" )
}
}
"enabled": false
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "tabIconsChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 0"
} )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridY": 11
"gridWidth": 3