mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 06:57:13 -06:00
TabbedPane: support adding custom components to left and right sides of tabs area if "more tabs" button is used (issue #40)
This commit is contained in:
@@ -248,6 +248,28 @@ public class FlatContainerTest
|
||||
tabbedPane1.setForegroundAt( 1, enabled ? Color.red : null );
|
||||
}
|
||||
|
||||
private void leadingComponentChanged() {
|
||||
leadingTrailingComponentChanged( leadingComponentCheckBox.isSelected(), TABBED_PANE_LEADING_COMPONENT, "Leading", 4 );
|
||||
}
|
||||
|
||||
private void trailingComponentChanged() {
|
||||
leadingTrailingComponentChanged( trailingComponentCheckBox.isSelected(), TABBED_PANE_TRAILING_COMPONENT, "Trailing", 12 );
|
||||
}
|
||||
|
||||
private void leadingTrailingComponentChanged( boolean enabled, String key, String text, int gap ) {
|
||||
JTabbedPane[] tabbedPanes = new JTabbedPane[] { tabbedPane1, tabbedPane2, tabbedPane3, tabbedPane4 };
|
||||
for( JTabbedPane tabbedPane : tabbedPanes ) {
|
||||
JComponent c = null;
|
||||
if( enabled ) {
|
||||
c = new JLabel( text );
|
||||
c.setOpaque( true );
|
||||
c.setBackground( Color.cyan );
|
||||
c.setBorder( new EmptyBorder( gap, gap, gap, gap ) );
|
||||
}
|
||||
tabbedPane.putClientProperty( key, c );
|
||||
}
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
||||
JPanel panel9 = new JPanel();
|
||||
@@ -282,6 +304,8 @@ public class FlatContainerTest
|
||||
JLabel hiddenTabsNavigationLabel = new JLabel();
|
||||
hiddenTabsNavigationField = new JComboBox<>();
|
||||
tabBackForegroundCheckBox = new JCheckBox();
|
||||
leadingComponentCheckBox = new JCheckBox();
|
||||
trailingComponentCheckBox = new JCheckBox();
|
||||
CellConstraints cc = new CellConstraints();
|
||||
|
||||
//======== this ========
|
||||
@@ -395,6 +419,7 @@ public class FlatContainerTest
|
||||
// rows
|
||||
"[center]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]"));
|
||||
|
||||
//---- moreTabsCheckBox ----
|
||||
@@ -483,6 +508,16 @@ public class FlatContainerTest
|
||||
tabBackForegroundCheckBox.setText("Tab back/foreground");
|
||||
tabBackForegroundCheckBox.addActionListener(e -> tabBackForegroundChanged());
|
||||
panel14.add(tabBackForegroundCheckBox, "cell 4 2");
|
||||
|
||||
//---- leadingComponentCheckBox ----
|
||||
leadingComponentCheckBox.setText("Leading");
|
||||
leadingComponentCheckBox.addActionListener(e -> leadingComponentChanged());
|
||||
panel14.add(leadingComponentCheckBox, "cell 0 3");
|
||||
|
||||
//---- trailingComponentCheckBox ----
|
||||
trailingComponentCheckBox.setText("Trailing");
|
||||
trailingComponentCheckBox.addActionListener(e -> trailingComponentChanged());
|
||||
panel14.add(trailingComponentCheckBox, "cell 1 3");
|
||||
}
|
||||
panel9.add(panel14, cc.xywh(1, 11, 3, 1));
|
||||
}
|
||||
@@ -508,6 +543,8 @@ public class FlatContainerTest
|
||||
private JComboBox<String> tabPlacementField;
|
||||
private JComboBox<String> hiddenTabsNavigationField;
|
||||
private JCheckBox tabBackForegroundCheckBox;
|
||||
private JCheckBox leadingComponentCheckBox;
|
||||
private JCheckBox trailingComponentCheckBox;
|
||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||
|
||||
//---- class Tab1Panel ----------------------------------------------------
|
||||
|
||||
@@ -132,7 +132,7 @@ new FormModel {
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$layoutConstraints": "insets 0,hidemode 3"
|
||||
"$columnConstraints": "[][fill][][][fill]"
|
||||
"$rowConstraints": "[center][][]"
|
||||
"$rowConstraints": "[center][][][]"
|
||||
} ) {
|
||||
name: "panel14"
|
||||
"opaque": false
|
||||
@@ -307,6 +307,26 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 4 2"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "leadingComponentCheckBox"
|
||||
"text": "Leading"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "leadingComponentChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 3"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "trailingComponentCheckBox"
|
||||
"text": "Trailing"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "trailingComponentChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 3"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
|
||||
"gridY": 11
|
||||
"gridWidth": 3
|
||||
|
||||
Reference in New Issue
Block a user