mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
TabbedPane: support separators between tabs (TabbedPane.showTabSeparators)
This commit is contained in:
@@ -9,7 +9,9 @@ FlatLaf Change Log
|
|||||||
- changed style to rounded rectangle
|
- changed style to rounded rectangle
|
||||||
- fixed painting issues on low values
|
- fixed painting issues on low values
|
||||||
- ProgressBar: Support configure of arc with `ProgressBar.arc`.
|
- ProgressBar: Support configure of arc with `ProgressBar.arc`.
|
||||||
- TabbedPane: Support background color for selected tabs.
|
- TabbedPane: Support background color for selected tabs
|
||||||
|
(`TabbedPane.selectedBackground`) and separators between tabs
|
||||||
|
(`TabbedPane.showTabSeparators`).
|
||||||
- CheckBox: changed `CheckBox.arc` from radius to diameter to be consistent with
|
- CheckBox: changed `CheckBox.arc` from radius to diameter to be consistent with
|
||||||
`Button.arc` and `Component.arc`
|
`Button.arc` and `Component.arc`
|
||||||
- Button: Enabled `Button.defaultButtonFollowsFocus` on Windows, which allows
|
- Button: Enabled `Button.defaultButtonFollowsFocus` on Windows, which allows
|
||||||
|
|||||||
@@ -64,6 +64,14 @@ public interface FlatClientProperties
|
|||||||
*/
|
*/
|
||||||
String SCROLL_BAR_SHOW_BUTTONS = "JScrollBar.showButtons";
|
String SCROLL_BAR_SHOW_BUTTONS = "JScrollBar.showButtons";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies whether separators are shown between tabs.
|
||||||
|
* <p>
|
||||||
|
* <strong>Component</strong> {@link javax.swing.JTabbedPane}<br>
|
||||||
|
* <strong>Value type</strong> {@link java.lang.Boolean}
|
||||||
|
*/
|
||||||
|
String TABBED_PANE_SHOW_TAB_SEPARATORS = "JTabbedPane.showTabSeparators";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies whether a full border is painted around a tabbed pane.
|
* Specifies whether a full border is painted around a tabbed pane.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -78,4 +86,13 @@ public interface FlatClientProperties
|
|||||||
static boolean clientPropertyEquals( JComponent c, String key, Object value ) {
|
static boolean clientPropertyEquals( JComponent c, String key, Object value ) {
|
||||||
return Objects.equals( c.getClientProperty( key ), value );
|
return Objects.equals( c.getClientProperty( key ), value );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether a client property of a component is a boolean and returns its value.
|
||||||
|
* If the client property is not set, or not a boolean, defaultValue is returned.
|
||||||
|
*/
|
||||||
|
static boolean clientPropertyBoolean( JComponent c, String key, boolean defaultValue ) {
|
||||||
|
Object value = c.getClientProperty( key );
|
||||||
|
return (value instanceof Boolean) ? (boolean) value : defaultValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import javax.swing.plaf.UIResource;
|
|||||||
import javax.swing.plaf.basic.BasicTabbedPaneUI;
|
import javax.swing.plaf.basic.BasicTabbedPaneUI;
|
||||||
import javax.swing.text.View;
|
import javax.swing.text.View;
|
||||||
import com.formdev.flatlaf.FlatLaf;
|
import com.formdev.flatlaf.FlatLaf;
|
||||||
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the Flat LaF UI delegate for {@link javax.swing.JTabbedPane}.
|
* Provides the Flat LaF UI delegate for {@link javax.swing.JTabbedPane}.
|
||||||
@@ -59,6 +60,7 @@ import com.formdev.flatlaf.FlatLaf;
|
|||||||
* @uiDefault TabbedPane.disabledUnderlineColor Color
|
* @uiDefault TabbedPane.disabledUnderlineColor Color
|
||||||
* @uiDefault TabbedPane.hoverColor Color
|
* @uiDefault TabbedPane.hoverColor Color
|
||||||
* @uiDefault TabbedPane.focusColor Color
|
* @uiDefault TabbedPane.focusColor Color
|
||||||
|
* @uiDefault TabbedPane.tabSeparatorColor Color optional; defaults to TabbedPane.contentAreaColor
|
||||||
* @uiDefault TabbedPane.contentAreaColor Color
|
* @uiDefault TabbedPane.contentAreaColor Color
|
||||||
* @uiDefault TabbedPane.textIconGap int
|
* @uiDefault TabbedPane.textIconGap int
|
||||||
* @uiDefault TabbedPane.tabInsets Insets
|
* @uiDefault TabbedPane.tabInsets Insets
|
||||||
@@ -66,6 +68,7 @@ import com.formdev.flatlaf.FlatLaf;
|
|||||||
* @uiDefault TabbedPane.tabHeight int
|
* @uiDefault TabbedPane.tabHeight int
|
||||||
* @uiDefault TabbedPane.tabSelectionHeight int
|
* @uiDefault TabbedPane.tabSelectionHeight int
|
||||||
* @uiDefault TabbedPane.contentSeparatorHeight int
|
* @uiDefault TabbedPane.contentSeparatorHeight int
|
||||||
|
* @uiDefault TabbedPane.showTabSeparators boolean
|
||||||
* @uiDefault TabbedPane.hasFullBorder boolean
|
* @uiDefault TabbedPane.hasFullBorder boolean
|
||||||
*
|
*
|
||||||
* @author Karl Tauber
|
* @author Karl Tauber
|
||||||
@@ -80,11 +83,13 @@ public class FlatTabbedPaneUI
|
|||||||
protected Color disabledUnderlineColor;
|
protected Color disabledUnderlineColor;
|
||||||
protected Color hoverColor;
|
protected Color hoverColor;
|
||||||
protected Color focusColor;
|
protected Color focusColor;
|
||||||
|
protected Color tabSeparatorColor;
|
||||||
protected Color contentAreaColor;
|
protected Color contentAreaColor;
|
||||||
|
|
||||||
protected int tabHeight;
|
protected int tabHeight;
|
||||||
protected int tabSelectionHeight;
|
protected int tabSelectionHeight;
|
||||||
protected int contentSeparatorHeight;
|
protected int contentSeparatorHeight;
|
||||||
|
protected boolean showTabSeparators;
|
||||||
protected boolean hasFullBorder;
|
protected boolean hasFullBorder;
|
||||||
protected boolean tabsOverlapBorder;
|
protected boolean tabsOverlapBorder;
|
||||||
|
|
||||||
@@ -103,11 +108,13 @@ public class FlatTabbedPaneUI
|
|||||||
disabledUnderlineColor = UIManager.getColor( "TabbedPane.disabledUnderlineColor" );
|
disabledUnderlineColor = UIManager.getColor( "TabbedPane.disabledUnderlineColor" );
|
||||||
hoverColor = UIManager.getColor( "TabbedPane.hoverColor" );
|
hoverColor = UIManager.getColor( "TabbedPane.hoverColor" );
|
||||||
focusColor = UIManager.getColor( "TabbedPane.focusColor" );
|
focusColor = UIManager.getColor( "TabbedPane.focusColor" );
|
||||||
|
tabSeparatorColor = UIManager.getColor( "TabbedPane.tabSeparatorColor" );
|
||||||
contentAreaColor = UIManager.getColor( "TabbedPane.contentAreaColor" );
|
contentAreaColor = UIManager.getColor( "TabbedPane.contentAreaColor" );
|
||||||
|
|
||||||
tabHeight = UIManager.getInt( "TabbedPane.tabHeight" );
|
tabHeight = UIManager.getInt( "TabbedPane.tabHeight" );
|
||||||
tabSelectionHeight = UIManager.getInt( "TabbedPane.tabSelectionHeight" );
|
tabSelectionHeight = UIManager.getInt( "TabbedPane.tabSelectionHeight" );
|
||||||
contentSeparatorHeight = UIManager.getInt( "TabbedPane.contentSeparatorHeight" );
|
contentSeparatorHeight = UIManager.getInt( "TabbedPane.contentSeparatorHeight" );
|
||||||
|
showTabSeparators = UIManager.getBoolean( "TabbedPane.showTabSeparators" );
|
||||||
hasFullBorder = UIManager.getBoolean( "TabbedPane.hasFullBorder" );
|
hasFullBorder = UIManager.getBoolean( "TabbedPane.hasFullBorder" );
|
||||||
tabsOverlapBorder = UIManager.getBoolean( "TabbedPane.tabsOverlapBorder" );
|
tabsOverlapBorder = UIManager.getBoolean( "TabbedPane.tabsOverlapBorder" );
|
||||||
|
|
||||||
@@ -133,6 +140,7 @@ public class FlatTabbedPaneUI
|
|||||||
disabledUnderlineColor = null;
|
disabledUnderlineColor = null;
|
||||||
hoverColor = null;
|
hoverColor = null;
|
||||||
focusColor = null;
|
focusColor = null;
|
||||||
|
tabSeparatorColor = null;
|
||||||
contentAreaColor = null;
|
contentAreaColor = null;
|
||||||
|
|
||||||
MigLayoutVisualPadding.uninstall( tabPane );
|
MigLayoutVisualPadding.uninstall( tabPane );
|
||||||
@@ -145,9 +153,12 @@ public class FlatTabbedPaneUI
|
|||||||
public void propertyChange( PropertyChangeEvent e ) {
|
public void propertyChange( PropertyChangeEvent e ) {
|
||||||
super.propertyChange( e );
|
super.propertyChange( e );
|
||||||
|
|
||||||
if( TABBED_PANE_HAS_FULL_BORDER.equals( e.getPropertyName() ) ) {
|
switch( e.getPropertyName() ) {
|
||||||
tabPane.revalidate();
|
case TABBED_PANE_SHOW_TAB_SEPARATORS:
|
||||||
tabPane.repaint();
|
case TABBED_PANE_HAS_FULL_BORDER:
|
||||||
|
tabPane.revalidate();
|
||||||
|
tabPane.repaint();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -201,7 +212,7 @@ public class FlatTabbedPaneUI
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Insets getContentBorderInsets( int tabPlacement ) {
|
protected Insets getContentBorderInsets( int tabPlacement ) {
|
||||||
boolean hasFullBorder = this.hasFullBorder || clientPropertyEquals( tabPane, TABBED_PANE_HAS_FULL_BORDER, true );
|
boolean hasFullBorder = clientPropertyBoolean( tabPane, TABBED_PANE_HAS_FULL_BORDER, this.hasFullBorder );
|
||||||
int sh = scale( contentSeparatorHeight );
|
int sh = scale( contentSeparatorHeight );
|
||||||
Insets insets = hasFullBorder ? new Insets( sh, sh, sh, sh ) : new Insets( sh, 0, 0, 0 );
|
Insets insets = hasFullBorder ? new Insets( sh, sh, sh, sh ) : new Insets( sh, 0, 0, 0 );
|
||||||
|
|
||||||
@@ -276,6 +287,26 @@ public class FlatTabbedPaneUI
|
|||||||
protected void paintTabBorder( Graphics g, int tabPlacement, int tabIndex,
|
protected void paintTabBorder( Graphics g, int tabPlacement, int tabIndex,
|
||||||
int x, int y, int w, int h, boolean isSelected )
|
int x, int y, int w, int h, boolean isSelected )
|
||||||
{
|
{
|
||||||
|
// paint tab separators
|
||||||
|
if( clientPropertyBoolean( tabPane, TABBED_PANE_SHOW_TAB_SEPARATORS, showTabSeparators ) &&
|
||||||
|
!isLastInRun( tabIndex ) )
|
||||||
|
{
|
||||||
|
float sepWidth = UIScale.scale( 1f );
|
||||||
|
float offset = UIScale.scale( 5f );
|
||||||
|
|
||||||
|
g.setColor( (tabSeparatorColor != null) ? tabSeparatorColor : contentAreaColor );
|
||||||
|
if( tabPlacement == LEFT || tabPlacement == RIGHT ) {
|
||||||
|
// paint tab separator at bottom side
|
||||||
|
((Graphics2D)g).fill( new Rectangle2D.Float( x + offset, y + h - sepWidth, w - (offset * 2), sepWidth ) );
|
||||||
|
} else if( tabPane.getComponentOrientation().isLeftToRight() ) {
|
||||||
|
// paint tab separator at right side
|
||||||
|
((Graphics2D)g).fill( new Rectangle2D.Float( x + w - sepWidth, y + offset, sepWidth, h - (offset * 2) ) );
|
||||||
|
} else {
|
||||||
|
// paint tab separator at left side
|
||||||
|
((Graphics2D)g).fill( new Rectangle2D.Float( x, y + offset, sepWidth, h - (offset * 2) ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( isSelected )
|
if( isSelected )
|
||||||
paintTabSelection( g, tabPlacement, x, y, w, h );
|
paintTabSelection( g, tabPlacement, x, y, w, h );
|
||||||
}
|
}
|
||||||
@@ -385,7 +416,7 @@ public class FlatTabbedPaneUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// compute insets for separator or full border
|
// compute insets for separator or full border
|
||||||
boolean hasFullBorder = this.hasFullBorder || clientPropertyEquals( tabPane, TABBED_PANE_HAS_FULL_BORDER, true );
|
boolean hasFullBorder = clientPropertyBoolean( tabPane, TABBED_PANE_HAS_FULL_BORDER, this.hasFullBorder );
|
||||||
int sh = scale( contentSeparatorHeight * 100 ); // multiply by 100 because rotateInsets() does not use floats
|
int sh = scale( contentSeparatorHeight * 100 ); // multiply by 100 because rotateInsets() does not use floats
|
||||||
Insets ci = new Insets( 0, 0, 0, 0 );
|
Insets ci = new Insets( 0, 0, 0, 0 );
|
||||||
rotateInsets( hasFullBorder ? new Insets( sh, sh, sh, sh ) : new Insets( sh, 0, 0, 0 ), ci, tabPlacement );
|
rotateInsets( hasFullBorder ? new Insets( sh, sh, sh, sh ) : new Insets( sh, 0, 0, 0 ), ci, tabPlacement );
|
||||||
@@ -420,6 +451,11 @@ public class FlatTabbedPaneUI
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isLastInRun( int tabIndex ) {
|
||||||
|
int run = getRunForTab( tabPane.getTabCount(), tabIndex );
|
||||||
|
return lastTabInRun( tabPane.getTabCount(), run ) == tabIndex;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isScrollTabLayout() {
|
private boolean isScrollTabLayout() {
|
||||||
return tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT;
|
return tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
package com.formdev.flatlaf.demo;
|
package com.formdev.flatlaf.demo;
|
||||||
|
|
||||||
import static com.formdev.flatlaf.FlatClientProperties.TABBED_PANE_HAS_FULL_BORDER;
|
import static com.formdev.flatlaf.FlatClientProperties.TABBED_PANE_HAS_FULL_BORDER;
|
||||||
|
import static com.formdev.flatlaf.FlatClientProperties.TABBED_PANE_SHOW_TAB_SEPARATORS;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.border.*;
|
import javax.swing.border.*;
|
||||||
@@ -29,6 +30,14 @@ class TabsPanel
|
|||||||
tabbedPane4.setTabLayoutPolicy( tabLayoutPolicy );
|
tabbedPane4.setTabLayoutPolicy( tabLayoutPolicy );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showTabSeparatorsChanged() {
|
||||||
|
Boolean showTabSeparators = showTabSeparatorsCheckBox.isSelected() ? true : null;
|
||||||
|
tabbedPane1.putClientProperty( TABBED_PANE_SHOW_TAB_SEPARATORS, showTabSeparators );
|
||||||
|
tabbedPane2.putClientProperty( TABBED_PANE_SHOW_TAB_SEPARATORS, showTabSeparators );
|
||||||
|
tabbedPane3.putClientProperty( TABBED_PANE_SHOW_TAB_SEPARATORS, showTabSeparators );
|
||||||
|
tabbedPane4.putClientProperty( TABBED_PANE_SHOW_TAB_SEPARATORS, showTabSeparators );
|
||||||
|
}
|
||||||
|
|
||||||
private void hasFullBorderChanged() {
|
private void hasFullBorderChanged() {
|
||||||
Boolean hasFullBorder = hasFullBorderCheckBox.isSelected() ? true : null;
|
Boolean hasFullBorder = hasFullBorderCheckBox.isSelected() ? true : null;
|
||||||
tabbedPane1.putClientProperty( TABBED_PANE_HAS_FULL_BORDER, hasFullBorder );
|
tabbedPane1.putClientProperty( TABBED_PANE_HAS_FULL_BORDER, hasFullBorder );
|
||||||
@@ -96,6 +105,7 @@ class TabsPanel
|
|||||||
JPanel panel14 = new JPanel();
|
JPanel panel14 = new JPanel();
|
||||||
moreTabsCheckBox = new JCheckBox();
|
moreTabsCheckBox = new JCheckBox();
|
||||||
tabScrollCheckBox = new JCheckBox();
|
tabScrollCheckBox = new JCheckBox();
|
||||||
|
showTabSeparatorsCheckBox = new JCheckBox();
|
||||||
hasFullBorderCheckBox = new JCheckBox();
|
hasFullBorderCheckBox = new JCheckBox();
|
||||||
CellConstraints cc = new CellConstraints();
|
CellConstraints cc = new CellConstraints();
|
||||||
|
|
||||||
@@ -285,6 +295,7 @@ class TabsPanel
|
|||||||
// columns
|
// columns
|
||||||
"[]" +
|
"[]" +
|
||||||
"[]" +
|
"[]" +
|
||||||
|
"[]" +
|
||||||
"[]",
|
"[]",
|
||||||
// rows
|
// rows
|
||||||
"[center]"));
|
"[center]"));
|
||||||
@@ -301,11 +312,16 @@ class TabsPanel
|
|||||||
tabScrollCheckBox.addActionListener(e -> tabScrollChanged());
|
tabScrollCheckBox.addActionListener(e -> tabScrollChanged());
|
||||||
panel14.add(tabScrollCheckBox, "cell 1 0,alignx left,growx 0");
|
panel14.add(tabScrollCheckBox, "cell 1 0,alignx left,growx 0");
|
||||||
|
|
||||||
|
//---- showTabSeparatorsCheckBox ----
|
||||||
|
showTabSeparatorsCheckBox.setText("JTabbedPane.showTabSeparators");
|
||||||
|
showTabSeparatorsCheckBox.addActionListener(e -> showTabSeparatorsChanged());
|
||||||
|
panel14.add(showTabSeparatorsCheckBox, "cell 2 0");
|
||||||
|
|
||||||
//---- hasFullBorderCheckBox ----
|
//---- hasFullBorderCheckBox ----
|
||||||
hasFullBorderCheckBox.setText("JTabbedPane.hasFullBorder");
|
hasFullBorderCheckBox.setText("JTabbedPane.hasFullBorder");
|
||||||
hasFullBorderCheckBox.setMnemonic('F');
|
hasFullBorderCheckBox.setMnemonic('F');
|
||||||
hasFullBorderCheckBox.addActionListener(e -> hasFullBorderChanged());
|
hasFullBorderCheckBox.addActionListener(e -> hasFullBorderChanged());
|
||||||
panel14.add(hasFullBorderCheckBox, "cell 2 0,alignx left,growx 0");
|
panel14.add(hasFullBorderCheckBox, "cell 3 0,alignx left,growx 0");
|
||||||
}
|
}
|
||||||
panel9.add(panel14, cc.xywh(1, 11, 3, 1));
|
panel9.add(panel14, cc.xywh(1, 11, 3, 1));
|
||||||
}
|
}
|
||||||
@@ -320,6 +336,7 @@ class TabsPanel
|
|||||||
private JTabbedPane tabbedPane4;
|
private JTabbedPane tabbedPane4;
|
||||||
private JCheckBox moreTabsCheckBox;
|
private JCheckBox moreTabsCheckBox;
|
||||||
private JCheckBox tabScrollCheckBox;
|
private JCheckBox tabScrollCheckBox;
|
||||||
|
private JCheckBox showTabSeparatorsCheckBox;
|
||||||
private JCheckBox hasFullBorderCheckBox;
|
private JCheckBox hasFullBorderCheckBox;
|
||||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ new FormModel {
|
|||||||
} )
|
} )
|
||||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||||
"$layoutConstraints": "insets 0,hidemode 3"
|
"$layoutConstraints": "insets 0,hidemode 3"
|
||||||
"$columnConstraints": "[][][]"
|
"$columnConstraints": "[][][][]"
|
||||||
"$rowConstraints": "[center]"
|
"$rowConstraints": "[center]"
|
||||||
} ) {
|
} ) {
|
||||||
name: "panel14"
|
name: "panel14"
|
||||||
@@ -225,6 +225,16 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 0,alignx left,growx 0"
|
"value": "cell 1 0,alignx left,growx 0"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||||
|
name: "showTabSeparatorsCheckBox"
|
||||||
|
"text": "JTabbedPane.showTabSeparators"
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showTabSeparatorsChanged", false ) )
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 2 0"
|
||||||
|
} )
|
||||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||||
name: "hasFullBorderCheckBox"
|
name: "hasFullBorderCheckBox"
|
||||||
"text": "JTabbedPane.hasFullBorder"
|
"text": "JTabbedPane.hasFullBorder"
|
||||||
@@ -234,7 +244,7 @@ new FormModel {
|
|||||||
}
|
}
|
||||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "hasFullBorderChanged", false ) )
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "hasFullBorderChanged", false ) )
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 2 0,alignx left,growx 0"
|
"value": "cell 3 0,alignx left,growx 0"
|
||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
|
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
|
||||||
"gridY": 11
|
"gridY": 11
|
||||||
@@ -245,7 +255,7 @@ new FormModel {
|
|||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( null ) {
|
}, new FormLayoutConstraints( null ) {
|
||||||
"location": new java.awt.Point( 0, 0 )
|
"location": new java.awt.Point( 0, 0 )
|
||||||
"size": new java.awt.Dimension( 500, 515 )
|
"size": new java.awt.Dimension( 610, 515 )
|
||||||
} )
|
} )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
package com.formdev.flatlaf.jideoss.ui;
|
package com.formdev.flatlaf.jideoss.ui;
|
||||||
|
|
||||||
import static com.formdev.flatlaf.FlatClientProperties.TABBED_PANE_HAS_FULL_BORDER;
|
import static com.formdev.flatlaf.FlatClientProperties.TABBED_PANE_HAS_FULL_BORDER;
|
||||||
import static com.formdev.flatlaf.FlatClientProperties.clientPropertyEquals;
|
import static com.formdev.flatlaf.FlatClientProperties.clientPropertyBoolean;
|
||||||
import static com.formdev.flatlaf.util.UIScale.scale;
|
import static com.formdev.flatlaf.util.UIScale.scale;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
@@ -181,7 +181,7 @@ public class FlatJideTabbedPaneUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Insets getContentBorderInsets0( int tabPlacement ) {
|
private Insets getContentBorderInsets0( int tabPlacement ) {
|
||||||
boolean hasFullBorder = this.hasFullBorder || clientPropertyEquals( _tabPane, TABBED_PANE_HAS_FULL_BORDER, true );
|
boolean hasFullBorder = clientPropertyBoolean( _tabPane, TABBED_PANE_HAS_FULL_BORDER, this.hasFullBorder );
|
||||||
int sh = scale( contentSeparatorHeight );
|
int sh = scale( contentSeparatorHeight );
|
||||||
Insets insets = hasFullBorder ? new Insets( sh, sh, sh, sh ) : new Insets( sh, 0, 0, 0 );
|
Insets insets = hasFullBorder ? new Insets( sh, sh, sh, sh ) : new Insets( sh, 0, 0, 0 );
|
||||||
|
|
||||||
@@ -339,7 +339,7 @@ public class FlatJideTabbedPaneUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// compute insets for separator or full border
|
// compute insets for separator or full border
|
||||||
boolean hasFullBorder = this.hasFullBorder || clientPropertyEquals( _tabPane, TABBED_PANE_HAS_FULL_BORDER, true );
|
boolean hasFullBorder = clientPropertyBoolean( _tabPane, TABBED_PANE_HAS_FULL_BORDER, this.hasFullBorder );
|
||||||
int sh = scale( contentSeparatorHeight * 100 ); // multiply by 100 because rotateInsets() does not use floats
|
int sh = scale( contentSeparatorHeight * 100 ); // multiply by 100 because rotateInsets() does not use floats
|
||||||
Insets ci = new Insets( 0, 0, 0, 0 );
|
Insets ci = new Insets( 0, 0, 0, 0 );
|
||||||
rotateInsets( hasFullBorder ? new Insets( sh, sh, sh, sh ) : new Insets( sh, 0, 0, 0 ), ci, tabPlacement );
|
rotateInsets( hasFullBorder ? new Insets( sh, sh, sh, sh ) : new Insets( sh, 0, 0, 0 ), ci, tabPlacement );
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
package com.formdev.flatlaf.testing;
|
package com.formdev.flatlaf.testing;
|
||||||
|
|
||||||
import static com.formdev.flatlaf.FlatClientProperties.TABBED_PANE_HAS_FULL_BORDER;
|
import static com.formdev.flatlaf.FlatClientProperties.TABBED_PANE_HAS_FULL_BORDER;
|
||||||
|
import static com.formdev.flatlaf.FlatClientProperties.TABBED_PANE_SHOW_TAB_SEPARATORS;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.border.*;
|
import javax.swing.border.*;
|
||||||
@@ -36,6 +37,14 @@ public class FlatContainerTest
|
|||||||
tabbedPane4.setTabLayoutPolicy( tabLayoutPolicy );
|
tabbedPane4.setTabLayoutPolicy( tabLayoutPolicy );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showTabSeparatorsChanged() {
|
||||||
|
Boolean showTabSeparators = showTabSeparatorsCheckBox.isSelected() ? true : null;
|
||||||
|
tabbedPane1.putClientProperty( TABBED_PANE_SHOW_TAB_SEPARATORS, showTabSeparators );
|
||||||
|
tabbedPane2.putClientProperty( TABBED_PANE_SHOW_TAB_SEPARATORS, showTabSeparators );
|
||||||
|
tabbedPane3.putClientProperty( TABBED_PANE_SHOW_TAB_SEPARATORS, showTabSeparators );
|
||||||
|
tabbedPane4.putClientProperty( TABBED_PANE_SHOW_TAB_SEPARATORS, showTabSeparators );
|
||||||
|
}
|
||||||
|
|
||||||
private void hasFullBorderChanged() {
|
private void hasFullBorderChanged() {
|
||||||
Boolean hasFullBorder = hasFullBorderCheckBox.isSelected() ? true : null;
|
Boolean hasFullBorder = hasFullBorderCheckBox.isSelected() ? true : null;
|
||||||
tabbedPane1.putClientProperty( TABBED_PANE_HAS_FULL_BORDER, hasFullBorder );
|
tabbedPane1.putClientProperty( TABBED_PANE_HAS_FULL_BORDER, hasFullBorder );
|
||||||
@@ -100,6 +109,7 @@ public class FlatContainerTest
|
|||||||
JPanel panel14 = new JPanel();
|
JPanel panel14 = new JPanel();
|
||||||
moreTabsCheckBox = new JCheckBox();
|
moreTabsCheckBox = new JCheckBox();
|
||||||
tabScrollCheckBox = new JCheckBox();
|
tabScrollCheckBox = new JCheckBox();
|
||||||
|
showTabSeparatorsCheckBox = new JCheckBox();
|
||||||
hasFullBorderCheckBox = new JCheckBox();
|
hasFullBorderCheckBox = new JCheckBox();
|
||||||
CellConstraints cc = new CellConstraints();
|
CellConstraints cc = new CellConstraints();
|
||||||
|
|
||||||
@@ -291,6 +301,7 @@ public class FlatContainerTest
|
|||||||
// columns
|
// columns
|
||||||
"[]" +
|
"[]" +
|
||||||
"[]" +
|
"[]" +
|
||||||
|
"[]" +
|
||||||
"[]",
|
"[]",
|
||||||
// rows
|
// rows
|
||||||
"[center]"));
|
"[center]"));
|
||||||
@@ -307,11 +318,16 @@ public class FlatContainerTest
|
|||||||
tabScrollCheckBox.addActionListener(e -> tabScrollChanged());
|
tabScrollCheckBox.addActionListener(e -> tabScrollChanged());
|
||||||
panel14.add(tabScrollCheckBox, "cell 1 0,alignx left,growx 0");
|
panel14.add(tabScrollCheckBox, "cell 1 0,alignx left,growx 0");
|
||||||
|
|
||||||
|
//---- showTabSeparatorsCheckBox ----
|
||||||
|
showTabSeparatorsCheckBox.setText("JTabbedPane.showTabSeparators");
|
||||||
|
showTabSeparatorsCheckBox.addActionListener(e -> showTabSeparatorsChanged());
|
||||||
|
panel14.add(showTabSeparatorsCheckBox, "cell 2 0");
|
||||||
|
|
||||||
//---- hasFullBorderCheckBox ----
|
//---- hasFullBorderCheckBox ----
|
||||||
hasFullBorderCheckBox.setText("JTabbedPane.hasFullBorder");
|
hasFullBorderCheckBox.setText("JTabbedPane.hasFullBorder");
|
||||||
hasFullBorderCheckBox.setMnemonic('F');
|
hasFullBorderCheckBox.setMnemonic('F');
|
||||||
hasFullBorderCheckBox.addActionListener(e -> hasFullBorderChanged());
|
hasFullBorderCheckBox.addActionListener(e -> hasFullBorderChanged());
|
||||||
panel14.add(hasFullBorderCheckBox, "cell 2 0,alignx left,growx 0");
|
panel14.add(hasFullBorderCheckBox, "cell 3 0,alignx left,growx 0");
|
||||||
}
|
}
|
||||||
panel9.add(panel14, cc.xywh(1, 11, 3, 1));
|
panel9.add(panel14, cc.xywh(1, 11, 3, 1));
|
||||||
}
|
}
|
||||||
@@ -326,6 +342,7 @@ public class FlatContainerTest
|
|||||||
private JTabbedPane tabbedPane4;
|
private JTabbedPane tabbedPane4;
|
||||||
private JCheckBox moreTabsCheckBox;
|
private JCheckBox moreTabsCheckBox;
|
||||||
private JCheckBox tabScrollCheckBox;
|
private JCheckBox tabScrollCheckBox;
|
||||||
|
private JCheckBox showTabSeparatorsCheckBox;
|
||||||
private JCheckBox hasFullBorderCheckBox;
|
private JCheckBox hasFullBorderCheckBox;
|
||||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ new FormModel {
|
|||||||
} )
|
} )
|
||||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||||
"$layoutConstraints": "insets 0,hidemode 3"
|
"$layoutConstraints": "insets 0,hidemode 3"
|
||||||
"$columnConstraints": "[][][]"
|
"$columnConstraints": "[][][][]"
|
||||||
"$rowConstraints": "[center]"
|
"$rowConstraints": "[center]"
|
||||||
} ) {
|
} ) {
|
||||||
name: "panel14"
|
name: "panel14"
|
||||||
@@ -227,6 +227,16 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 0,alignx left,growx 0"
|
"value": "cell 1 0,alignx left,growx 0"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||||
|
name: "showTabSeparatorsCheckBox"
|
||||||
|
"text": "JTabbedPane.showTabSeparators"
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showTabSeparatorsChanged", false ) )
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 2 0"
|
||||||
|
} )
|
||||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||||
name: "hasFullBorderCheckBox"
|
name: "hasFullBorderCheckBox"
|
||||||
"text": "JTabbedPane.hasFullBorder"
|
"text": "JTabbedPane.hasFullBorder"
|
||||||
@@ -236,7 +246,7 @@ new FormModel {
|
|||||||
}
|
}
|
||||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "hasFullBorderChanged", false ) )
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "hasFullBorderChanged", false ) )
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 2 0,alignx left,growx 0"
|
"value": "cell 3 0,alignx left,growx 0"
|
||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
|
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
|
||||||
"gridY": 11
|
"gridY": 11
|
||||||
@@ -247,7 +257,7 @@ new FormModel {
|
|||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( null ) {
|
}, new FormLayoutConstraints( null ) {
|
||||||
"location": new java.awt.Point( 0, 0 )
|
"location": new java.awt.Point( 0, 0 )
|
||||||
"size": new java.awt.Dimension( 500, 515 )
|
"size": new java.awt.Dimension( 625, 515 )
|
||||||
} )
|
} )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,6 +235,7 @@ TabbedPane.underlineColor=#4A88C7
|
|||||||
TabbedPane.disabledUnderlineColor=#7a7a7a
|
TabbedPane.disabledUnderlineColor=#7a7a7a
|
||||||
TabbedPane.hoverColor=#eeeeee
|
TabbedPane.hoverColor=#eeeeee
|
||||||
TabbedPane.focusColor=#dddddd
|
TabbedPane.focusColor=#dddddd
|
||||||
|
TabbedPane.tabSeparatorColor=#00f
|
||||||
TabbedPane.contentAreaColor=#bbbbbb
|
TabbedPane.contentAreaColor=#bbbbbb
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user