Demo: "SplitPane & Tabs" tab improved

This commit is contained in:
Karl Tauber
2020-09-03 15:09:28 +02:00
parent 600f812f45
commit a2ac24ac74
6 changed files with 422 additions and 524 deletions

View File

@@ -1,6 +1,14 @@
FlatLaf Change Log
==================
## Unreleased
#### New features and improvements
- Demo: Improved "SplitPane & Tabs" and "Data Components" tabs.
## 0.41
#### New features and improvements

View File

@@ -1,5 +1,17 @@
/*
* Created by JFormDesigner on Tue Aug 27 21:47:02 CEST 2019
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.demo;
@@ -20,6 +32,8 @@ class TabsPanel
{
TabsPanel() {
initComponents();
addInitialTabs( tabbedPane1, tabbedPane2, tabbedPane3, tabbedPane4 );
}
private void tabScrollChanged() {
@@ -28,8 +42,20 @@ class TabsPanel
tabbedPane2.setTabLayoutPolicy( tabLayoutPolicy );
tabbedPane3.setTabLayoutPolicy( tabLayoutPolicy );
tabbedPane4.setTabLayoutPolicy( tabLayoutPolicy );
if( !autoMoreTabs && tabScrollCheckBox.isSelected() && !moreTabsCheckBox.isSelected() ) {
moreTabsCheckBox.setSelected( true );
moreTabsChanged();
autoMoreTabs = true;
} else if( autoMoreTabs && !tabScrollCheckBox.isSelected() && moreTabsCheckBox.isSelected() ) {
moreTabsCheckBox.setSelected( false );
moreTabsChanged();
autoMoreTabs = false;
}
}
private boolean autoMoreTabs;
private void showTabSeparatorsChanged() {
Boolean showTabSeparators = showTabSeparatorsCheckBox.isSelected() ? true : null;
tabbedPane1.putClientProperty( TABBED_PANE_SHOW_TAB_SEPARATORS, showTabSeparators );
@@ -52,15 +78,17 @@ class TabsPanel
addRemoveMoreTabs( tabbedPane2, moreTabs );
addRemoveMoreTabs( tabbedPane3, moreTabs );
addRemoveMoreTabs( tabbedPane4, moreTabs );
autoMoreTabs = false;
}
private void addRemoveMoreTabs( JTabbedPane tabbedPane, boolean add ) {
if( add ) {
tabbedPane.addTab( "Tab 4", new JLabel( "tab 4" ) );
tabbedPane.addTab( "Tab 5", new JLabel( "tab 5" ) );
tabbedPane.addTab( "Tab 6", new JLabel( "tab 6" ) );
tabbedPane.addTab( "Tab 7", new JLabel( "tab 7" ) );
tabbedPane.addTab( "Tab 8", new JLabel( "tab 8" ) );
addTab( tabbedPane, "Tab 4", "tab content 4" );
addTab( tabbedPane, "Tab 5", "tab content 5" );
addTab( tabbedPane, "Tab 6", "tab content 6" );
addTab( tabbedPane, "Tab 7", "tab content 7" );
addTab( tabbedPane, "Tab 8", "tab content 8" );
} else {
int tabCount = tabbedPane.getTabCount();
if( tabCount > 3 ) {
@@ -70,6 +98,39 @@ class TabsPanel
}
}
private void addInitialTabs( JTabbedPane... tabbedPanes ) {
for( JTabbedPane tabbedPane : tabbedPanes ) {
String placement = "unknown";
switch( tabbedPane.getTabPlacement() ) {
case JTabbedPane.TOP: placement = "TOP"; break;
case JTabbedPane.BOTTOM: placement = "BOTTOM"; break;
case JTabbedPane.LEFT: placement = "LEFT"; break;
case JTabbedPane.RIGHT: placement = "RIGHT"; break;
}
addTab( tabbedPane, "Tab 1", "<html><center>" + placement + "<br>tab placement</center></html>" );
JComponent tab2 = createTab( "tab content 2" );
tab2.setBorder( new LineBorder( Color.magenta ) );
tabbedPane.addTab( "Second Tab", tab2 );
addTab( tabbedPane, "Disabled", "tab content 3" );
tabbedPane.setEnabledAt( 2, false );
}
}
private void addTab( JTabbedPane tabbedPane, String title, String text ) {
tabbedPane.addTab( title, createTab( text ) );
}
private JComponent createTab( String text ) {
JLabel label = new JLabel( text );
label.setHorizontalAlignment( SwingConstants.CENTER );
JPanel tab = new JPanel( new BorderLayout() );
tab.add( label, BorderLayout.CENTER );
return tab;
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JPanel panel9 = new JPanel();
@@ -77,31 +138,19 @@ class TabsPanel
JSplitPane splitPane3 = new JSplitPane();
JSplitPane splitPane1 = new JSplitPane();
JPanel panel10 = new JPanel();
JLabel label1 = new JLabel();
JPanel panel11 = new JPanel();
JLabel label2 = new JLabel();
JSplitPane splitPane2 = new JSplitPane();
JPanel panel12 = new JPanel();
JLabel label3 = new JLabel();
JPanel panel13 = new JPanel();
JLabel label4 = new JLabel();
JLabel tabbedPaneLabel = new JLabel();
tabbedPane1 = new JTabbedPane();
JPanel panel1 = new JPanel();
JLabel label1 = new JLabel();
JPanel panel2 = new JPanel();
JLabel label2 = new JLabel();
tabbedPane3 = new JTabbedPane();
JPanel panel5 = new JPanel();
JLabel label5 = new JLabel();
JPanel panel6 = new JPanel();
JLabel label6 = new JLabel();
tabbedPane2 = new JTabbedPane();
JPanel panel3 = new JPanel();
JLabel label3 = new JLabel();
JPanel panel4 = new JPanel();
JLabel label4 = new JLabel();
tabbedPane4 = new JTabbedPane();
JPanel panel7 = new JPanel();
JLabel label7 = new JLabel();
JPanel panel8 = new JPanel();
JLabel label8 = new JLabel();
JPanel panel14 = new JPanel();
moreTabsCheckBox = new JCheckBox();
tabScrollCheckBox = new JCheckBox();
@@ -121,7 +170,7 @@ class TabsPanel
{
panel9.setLayout(new FormLayout(
"70dlu:grow, $ugap, 70dlu:grow",
"default, $lgap, fill:70dlu, $pgap, pref, $lgap, 2*(fill:70dlu:grow, $ugap), pref"));
"default, $lgap, fill:70dlu, $pgap, pref, $lgap, 2*(fill:80dlu:grow, $ugap), pref"));
//---- splitPaneLabel ----
splitPaneLabel.setText("JSplitPane:");
@@ -134,19 +183,30 @@ class TabsPanel
//======== splitPane1 ========
{
splitPane1.setResizeWeight(0.5);
splitPane1.setOneTouchExpandable(true);
//======== panel10 ========
{
panel10.setBackground(Color.orange);
panel10.setLayout(new FlowLayout());
panel10.setBackground(new Color(217, 163, 67));
panel10.setLayout(new BorderLayout());
//---- label1 ----
label1.setText("LEFT");
label1.setHorizontalAlignment(SwingConstants.CENTER);
label1.setForeground(Color.white);
panel10.add(label1, BorderLayout.CENTER);
}
splitPane1.setLeftComponent(panel10);
//======== panel11 ========
{
panel11.setBackground(Color.magenta);
panel11.setLayout(new FlowLayout());
panel11.setBackground(new Color(98, 181, 67));
panel11.setLayout(new BorderLayout());
//---- label2 ----
label2.setText("RIGHT");
label2.setHorizontalAlignment(SwingConstants.CENTER);
label2.setForeground(Color.white);
panel11.add(label2, BorderLayout.CENTER);
}
splitPane1.setRightComponent(panel11);
}
@@ -156,19 +216,30 @@ class TabsPanel
{
splitPane2.setOrientation(JSplitPane.VERTICAL_SPLIT);
splitPane2.setResizeWeight(0.5);
splitPane2.setOneTouchExpandable(true);
//======== panel12 ========
{
panel12.setBackground(Color.orange);
panel12.setLayout(new FlowLayout());
panel12.setBackground(new Color(242, 101, 34));
panel12.setLayout(new BorderLayout());
//---- label3 ----
label3.setText("TOP");
label3.setHorizontalAlignment(SwingConstants.CENTER);
label3.setForeground(Color.white);
panel12.add(label3, BorderLayout.CENTER);
}
splitPane2.setTopComponent(panel12);
//======== panel13 ========
{
panel13.setBackground(Color.magenta);
panel13.setLayout(new FlowLayout());
panel13.setBackground(new Color(64, 182, 224));
panel13.setLayout(new BorderLayout());
//---- label4 ----
label4.setText("BOTTOM");
label4.setHorizontalAlignment(SwingConstants.CENTER);
label4.setForeground(Color.white);
panel13.add(label4, BorderLayout.CENTER);
}
splitPane2.setBottomComponent(panel13);
}
@@ -179,112 +250,23 @@ class TabsPanel
//---- tabbedPaneLabel ----
tabbedPaneLabel.setText("JTabbedPane:");
panel9.add(tabbedPaneLabel, cc.xy(1, 5));
//======== tabbedPane1 ========
{
//======== panel1 ========
{
panel1.setLayout(new FlowLayout());
//---- label1 ----
label1.setText("TOP");
panel1.add(label1);
}
tabbedPane1.addTab("Tab 1", panel1);
//======== panel2 ========
{
panel2.setBorder(new LineBorder(Color.magenta));
panel2.setLayout(new FlowLayout());
}
tabbedPane1.addTab("Tab 2", panel2);
//---- label2 ----
label2.setText("text");
tabbedPane1.addTab("Tab 3", label2);
}
panel9.add(tabbedPane1, cc.xy(1, 7));
//======== tabbedPane3 ========
{
tabbedPane3.setTabPlacement(SwingConstants.LEFT);
//======== panel5 ========
{
panel5.setLayout(new FlowLayout());
//---- label5 ----
label5.setText("LEFT");
panel5.add(label5);
}
tabbedPane3.addTab("Tab 1", panel5);
//======== panel6 ========
{
panel6.setBorder(new LineBorder(Color.magenta));
panel6.setLayout(new FlowLayout());
}
tabbedPane3.addTab("Tab 2", panel6);
//---- label6 ----
label6.setText("text");
tabbedPane3.addTab("Tab 3", label6);
}
panel9.add(tabbedPane3, cc.xy(3, 7));
//======== tabbedPane2 ========
{
tabbedPane2.setTabPlacement(SwingConstants.BOTTOM);
//======== panel3 ========
{
panel3.setLayout(new FlowLayout());
//---- label3 ----
label3.setText("BOTTOM");
panel3.add(label3);
}
tabbedPane2.addTab("Tab 1", panel3);
//======== panel4 ========
{
panel4.setBorder(new LineBorder(Color.magenta));
panel4.setLayout(new FlowLayout());
}
tabbedPane2.addTab("Tab 2", panel4);
tabbedPane2.setEnabledAt(1, false);
//---- label4 ----
label4.setText("text");
tabbedPane2.addTab("Tab 3", label4);
}
panel9.add(tabbedPane2, cc.xy(1, 9));
//======== tabbedPane4 ========
{
tabbedPane4.setTabPlacement(SwingConstants.RIGHT);
//======== panel7 ========
{
panel7.setLayout(new FlowLayout());
//---- label7 ----
label7.setText("RIGHT");
panel7.add(label7);
}
tabbedPane4.addTab("Tab 1", panel7);
//======== panel8 ========
{
panel8.setBorder(new LineBorder(Color.magenta));
panel8.setLayout(new FlowLayout());
}
tabbedPane4.addTab("Tab 2", panel8);
//---- label8 ----
label8.setText("text");
tabbedPane4.addTab("Tab 3", label8);
}
panel9.add(tabbedPane4, cc.xy(3, 9));
@@ -318,8 +300,7 @@ class TabsPanel
panel14.add(showTabSeparatorsCheckBox, "cell 2 0");
//---- hasFullBorderCheckBox ----
hasFullBorderCheckBox.setText("Show full border");
hasFullBorderCheckBox.setMnemonic('F');
hasFullBorderCheckBox.setText("Show content border");
hasFullBorderCheckBox.addActionListener(e -> hasFullBorderChanged());
panel14.add(hasFullBorderCheckBox, "cell 3 0,alignx left,growx 0");
}

View File

@@ -14,7 +14,7 @@ new FormModel {
name: "this"
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class com.jgoodies.forms.layout.FormLayout ) {
"$columnSpecs": "70dlu:grow, unrelgap, 70dlu:grow"
"$rowSpecs": "default, linegap, fill:70dlu, pargap, pref, linegap, fill:70dlu:grow, unrelgap, fill:70dlu:grow, unrelgap, pref"
"$rowSpecs": "default, linegap, fill:70dlu, pargap, pref, linegap, fill:80dlu:grow, unrelgap, fill:80dlu:grow, unrelgap, pref"
} ) {
name: "panel9"
add( new FormComponent( "javax.swing.JLabel" ) {
@@ -27,16 +27,31 @@ new FormModel {
add( new FormContainer( "javax.swing.JSplitPane", new FormLayoutManager( class javax.swing.JSplitPane ) ) {
name: "splitPane1"
"resizeWeight": 0.5
"oneTouchExpandable": true
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) {
name: "panel10"
"background": sfield java.awt.Color orange
"background": new java.awt.Color( 217, 163, 67, 255 )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label1"
"text": "LEFT"
"horizontalAlignment": 0
"foreground": sfield java.awt.Color white
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "Center"
} )
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "left"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) {
name: "panel11"
"background": sfield java.awt.Color magenta
"background": new java.awt.Color( 98, 181, 67, 255 )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label2"
"text": "RIGHT"
"horizontalAlignment": 0
"foreground": sfield java.awt.Color white
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "Center"
} )
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "right"
} )
@@ -47,16 +62,31 @@ new FormModel {
name: "splitPane2"
"orientation": 0
"resizeWeight": 0.5
"oneTouchExpandable": true
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) {
name: "panel12"
"background": sfield java.awt.Color orange
"background": new java.awt.Color( 242, 101, 34, 255 )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label3"
"text": "TOP"
"horizontalAlignment": 0
"foreground": sfield java.awt.Color white
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "Center"
} )
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "left"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) {
name: "panel13"
"background": sfield java.awt.Color magenta
"background": new java.awt.Color( 64, 182, 224, 255 )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label4"
"text": "BOTTOM"
"horizontalAlignment": 0
"foreground": sfield java.awt.Color white
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "Center"
} )
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "right"
} )
@@ -79,27 +109,6 @@ new FormModel {
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel1"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label1"
"text": "TOP"
} )
}, new FormLayoutConstraints( null ) {
"title": "Tab 1"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel2"
"border": &LineBorder0 new javax.swing.border.LineBorder( sfield java.awt.Color magenta, 1, false )
}, new FormLayoutConstraints( null ) {
"title": "Tab 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label2"
"text": "text"
}, new FormLayoutConstraints( null ) {
"title": "Tab 3"
} )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridX": 1
"gridY": 7
@@ -110,27 +119,6 @@ new FormModel {
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel5"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label5"
"text": "LEFT"
} )
}, new FormLayoutConstraints( null ) {
"title": "Tab 1"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel6"
"border": #LineBorder0
}, new FormLayoutConstraints( null ) {
"title": "Tab 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label6"
"text": "text"
}, new FormLayoutConstraints( null ) {
"title": "Tab 3"
} )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridX": 3
"gridY": 7
@@ -141,28 +129,6 @@ new FormModel {
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel3"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label3"
"text": "BOTTOM"
} )
}, new FormLayoutConstraints( null ) {
"title": "Tab 1"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel4"
"border": #LineBorder0
}, new FormLayoutConstraints( null ) {
"title": "Tab 2"
"enabled": false
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label4"
"text": "text"
}, new FormLayoutConstraints( null ) {
"title": "Tab 3"
} )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridY": 9
} )
@@ -172,27 +138,6 @@ new FormModel {
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel7"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label7"
"text": "RIGHT"
} )
}, new FormLayoutConstraints( null ) {
"title": "Tab 1"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel8"
"border": #LineBorder0
}, new FormLayoutConstraints( null ) {
"title": "Tab 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label8"
"text": "text"
}, new FormLayoutConstraints( null ) {
"title": "Tab 3"
} )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridX": 3
"gridY": 9
@@ -237,8 +182,7 @@ new FormModel {
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "hasFullBorderCheckBox"
"text": "Show full border"
"mnemonic": 70
"text": "Show content border"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
@@ -255,7 +199,7 @@ new FormModel {
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 610, 515 )
"size": new java.awt.Dimension( 625, 515 )
} )
}
}

View File

@@ -1,5 +1,17 @@
/*
* Created by JFormDesigner on Tue Aug 27 21:47:02 CEST 2019
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.testing;
@@ -27,6 +39,8 @@ public class FlatContainerTest
public FlatContainerTest() {
initComponents();
addInitialTabs( tabbedPane1, tabbedPane2, tabbedPane3, tabbedPane4 );
}
private void tabScrollChanged() {
@@ -35,8 +49,20 @@ public class FlatContainerTest
tabbedPane2.setTabLayoutPolicy( tabLayoutPolicy );
tabbedPane3.setTabLayoutPolicy( tabLayoutPolicy );
tabbedPane4.setTabLayoutPolicy( tabLayoutPolicy );
if( !autoMoreTabs && tabScrollCheckBox.isSelected() && !moreTabsCheckBox.isSelected() ) {
moreTabsCheckBox.setSelected( true );
moreTabsChanged();
autoMoreTabs = true;
} else if( autoMoreTabs && !tabScrollCheckBox.isSelected() && moreTabsCheckBox.isSelected() ) {
moreTabsCheckBox.setSelected( false );
moreTabsChanged();
autoMoreTabs = false;
}
}
private boolean autoMoreTabs;
private void showTabSeparatorsChanged() {
Boolean showTabSeparators = showTabSeparatorsCheckBox.isSelected() ? true : null;
tabbedPane1.putClientProperty( TABBED_PANE_SHOW_TAB_SEPARATORS, showTabSeparators );
@@ -59,61 +85,70 @@ public class FlatContainerTest
addRemoveMoreTabs( tabbedPane2, moreTabs );
addRemoveMoreTabs( tabbedPane3, moreTabs );
addRemoveMoreTabs( tabbedPane4, moreTabs );
autoMoreTabs = false;
}
private void addRemoveMoreTabs( JTabbedPane tabbedPane, boolean add ) {
if( add ) {
tabbedPane.addTab( "Tab 4", new JLabel( "tab 4" ) );
tabbedPane.addTab( "Tab 5", new JLabel( "tab 5" ) );
addTab( tabbedPane, "Tab 4", "tab content 4" );
addTab( tabbedPane, "Tab 5", "tab content 5" );
addTab( tabbedPane, "Tab 6", "tab content 6" );
addTab( tabbedPane, "Tab 7", "tab content 7" );
addTab( tabbedPane, "Tab 8", "tab content 8" );
} else {
int tabCount = tabbedPane.getTabCount();
if( tabCount > 3 ) {
for( int i = 0; i < 2; i++ )
for( int i = 0; i < 5; i++ )
tabbedPane.removeTabAt( tabbedPane.getTabCount() - 1 );
}
}
}
private void addInitialTabs( JTabbedPane... tabbedPanes ) {
for( JTabbedPane tabbedPane : tabbedPanes ) {
tabbedPane.addTab( "Tab 1", new Panel1() );
JComponent tab2 = new Panel2();
tab2.setBorder( new LineBorder( Color.magenta ) );
tabbedPane.addTab( "Second Tab", tab2 );
addTab( tabbedPane, "Disabled", "tab content 3" );
tabbedPane.setEnabledAt( 2, false );
}
}
private void addTab( JTabbedPane tabbedPane, String title, String text ) {
tabbedPane.addTab( title, createTab( text ) );
}
private JComponent createTab( String text ) {
JLabel label = new JLabel( text );
label.setHorizontalAlignment( SwingConstants.CENTER );
JPanel tab = new JPanel( new BorderLayout() );
tab.add( label, BorderLayout.CENTER );
return tab;
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JPanel panel9 = new JPanel();
JLabel splitPaneLabel = new JLabel();
JSplitPane splitPane3 = new JSplitPane();
JSplitPane splitPane1 = new JSplitPane();
JPanel panel10 = new JPanel();
JTextField textField2 = new JTextField();
JButton button1 = new JButton();
JPanel panel11 = new JPanel();
JTextField textField3 = new JTextField();
JButton button2 = new JButton();
FlatContainerTest.Panel1 panel15 = new FlatContainerTest.Panel1();
FlatContainerTest.Panel2 panel21 = new FlatContainerTest.Panel2();
JSplitPane splitPane2 = new JSplitPane();
JPanel panel12 = new JPanel();
JLabel label3 = new JLabel();
JPanel panel13 = new JPanel();
JLabel label4 = new JLabel();
JLabel tabbedPaneLabel = new JLabel();
tabbedPane1 = new JTabbedPane();
JPanel panel1 = new JPanel();
JLabel label1 = new JLabel();
JTextField textField4 = new JTextField();
JButton button3 = new JButton();
JPanel panel2 = new JPanel();
JTextField textField5 = new JTextField();
JButton button4 = new JButton();
JLabel label2 = new JLabel();
tabbedPane3 = new JTabbedPane();
JPanel panel5 = new JPanel();
JLabel label5 = new JLabel();
JPanel panel6 = new JPanel();
JLabel label6 = new JLabel();
tabbedPane2 = new JTabbedPane();
JPanel panel3 = new JPanel();
JLabel label3 = new JLabel();
JPanel panel4 = new JPanel();
JLabel label4 = new JLabel();
tabbedPane4 = new JTabbedPane();
JPanel panel7 = new JPanel();
JLabel label7 = new JLabel();
JPanel panel8 = new JPanel();
JLabel label8 = new JLabel();
JPanel panel14 = new JPanel();
moreTabsCheckBox = new JCheckBox();
tabScrollCheckBox = new JCheckBox();
@@ -134,7 +169,7 @@ public class FlatContainerTest
panel9.setOpaque(false);
panel9.setLayout(new FormLayout(
"70dlu:grow, $ugap, 70dlu:grow",
"default, $lgap, fill:70dlu, $pgap, pref, $lgap, 2*(fill:70dlu:grow, $ugap), pref"));
"default, $lgap, fill:70dlu, $pgap, pref, $lgap, 2*(fill:80dlu:grow, $ugap), pref"));
//---- splitPaneLabel ----
splitPaneLabel.setText("JSplitPane:");
@@ -149,35 +184,13 @@ public class FlatContainerTest
splitPane1.setResizeWeight(0.5);
splitPane1.setOneTouchExpandable(true);
//======== panel10 ========
{
panel10.setBackground(Color.orange);
panel10.setLayout(new FlowLayout());
//---- panel15 ----
panel15.setBackground(new Color(217, 163, 67));
splitPane1.setLeftComponent(panel15);
//---- textField2 ----
textField2.setText("some text");
panel10.add(textField2);
//---- button1 ----
button1.setText("...");
panel10.add(button1);
}
splitPane1.setLeftComponent(panel10);
//======== panel11 ========
{
panel11.setBackground(Color.magenta);
panel11.setLayout(new FlowLayout());
//---- textField3 ----
textField3.setText("some text");
panel11.add(textField3);
//---- button2 ----
button2.setText("...");
panel11.add(button2);
}
splitPane1.setRightComponent(panel11);
//---- panel21 ----
panel21.setBackground(new Color(98, 181, 67));
splitPane1.setRightComponent(panel21);
}
splitPane3.setLeftComponent(splitPane1);
@@ -189,15 +202,27 @@ public class FlatContainerTest
//======== panel12 ========
{
panel12.setBackground(Color.orange);
panel12.setLayout(new FlowLayout());
panel12.setBackground(new Color(242, 101, 34));
panel12.setLayout(new BorderLayout());
//---- label3 ----
label3.setText("TOP");
label3.setHorizontalAlignment(SwingConstants.CENTER);
label3.setForeground(Color.white);
panel12.add(label3, BorderLayout.CENTER);
}
splitPane2.setTopComponent(panel12);
//======== panel13 ========
{
panel13.setBackground(Color.magenta);
panel13.setLayout(new FlowLayout());
panel13.setBackground(new Color(64, 182, 224));
panel13.setLayout(new BorderLayout());
//---- label4 ----
label4.setText("BOTTOM");
label4.setHorizontalAlignment(SwingConstants.CENTER);
label4.setForeground(Color.white);
panel13.add(label4, BorderLayout.CENTER);
}
splitPane2.setBottomComponent(panel13);
}
@@ -208,128 +233,23 @@ public class FlatContainerTest
//---- tabbedPaneLabel ----
tabbedPaneLabel.setText("JTabbedPane:");
panel9.add(tabbedPaneLabel, cc.xy(1, 5));
//======== tabbedPane1 ========
{
//======== panel1 ========
{
panel1.setLayout(new FlowLayout());
//---- label1 ----
label1.setText("TOP");
panel1.add(label1);
//---- textField4 ----
textField4.setText("some text");
panel1.add(textField4);
//---- button3 ----
button3.setText("...");
panel1.add(button3);
}
tabbedPane1.addTab("Tab 1", panel1);
//======== panel2 ========
{
panel2.setBorder(new LineBorder(Color.magenta));
panel2.setLayout(new FlowLayout());
//---- textField5 ----
textField5.setText("some text");
panel2.add(textField5);
//---- button4 ----
button4.setText("...");
panel2.add(button4);
}
tabbedPane1.addTab("Tab 2", panel2);
//---- label2 ----
label2.setText("text");
tabbedPane1.addTab("Tab 3", label2);
}
panel9.add(tabbedPane1, cc.xy(1, 7));
//======== tabbedPane3 ========
{
tabbedPane3.setTabPlacement(SwingConstants.LEFT);
//======== panel5 ========
{
panel5.setLayout(new FlowLayout());
//---- label5 ----
label5.setText("LEFT");
panel5.add(label5);
}
tabbedPane3.addTab("Tab 1", panel5);
//======== panel6 ========
{
panel6.setBorder(new LineBorder(Color.magenta));
panel6.setLayout(new FlowLayout());
}
tabbedPane3.addTab("Tab 2", panel6);
//---- label6 ----
label6.setText("text");
tabbedPane3.addTab("Tab 3", label6);
}
panel9.add(tabbedPane3, cc.xy(3, 7));
//======== tabbedPane2 ========
{
tabbedPane2.setTabPlacement(SwingConstants.BOTTOM);
//======== panel3 ========
{
panel3.setLayout(new FlowLayout());
//---- label3 ----
label3.setText("BOTTOM");
panel3.add(label3);
}
tabbedPane2.addTab("Tab 1", panel3);
//======== panel4 ========
{
panel4.setBorder(new LineBorder(Color.magenta));
panel4.setLayout(new FlowLayout());
}
tabbedPane2.addTab("Tab 2", panel4);
tabbedPane2.setEnabledAt(1, false);
//---- label4 ----
label4.setText("text");
tabbedPane2.addTab("Tab 3", label4);
}
panel9.add(tabbedPane2, cc.xy(1, 9));
//======== tabbedPane4 ========
{
tabbedPane4.setTabPlacement(SwingConstants.RIGHT);
//======== panel7 ========
{
panel7.setLayout(new FlowLayout());
//---- label7 ----
label7.setText("RIGHT");
panel7.add(label7);
}
tabbedPane4.addTab("Tab 1", panel7);
//======== panel8 ========
{
panel8.setBorder(new LineBorder(Color.magenta));
panel8.setLayout(new FlowLayout());
}
tabbedPane4.addTab("Tab 2", panel8);
//---- label8 ----
label8.setText("text");
tabbedPane4.addTab("Tab 3", label8);
}
panel9.add(tabbedPane4, cc.xy(3, 9));
@@ -364,8 +284,7 @@ public class FlatContainerTest
panel14.add(showTabSeparatorsCheckBox, "cell 2 0");
//---- hasFullBorderCheckBox ----
hasFullBorderCheckBox.setText("Show full border");
hasFullBorderCheckBox.setMnemonic('F');
hasFullBorderCheckBox.setText("Show content border");
hasFullBorderCheckBox.addActionListener(e -> hasFullBorderChanged());
panel14.add(hasFullBorderCheckBox, "cell 3 0,alignx left,growx 0");
}
@@ -385,4 +304,84 @@ public class FlatContainerTest
private JCheckBox showTabSeparatorsCheckBox;
private JCheckBox hasFullBorderCheckBox;
// JFormDesigner - End of variables declaration //GEN-END:variables
//---- class Tab1Panel ----------------------------------------------------
private static class Panel1
extends JPanel
{
private Panel1() {
initComponents();
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JLabel label1 = new JLabel();
JTextField textField4 = new JTextField();
JButton button3 = new JButton();
//======== this ========
setLayout(new MigLayout(
"hidemode 3,align center center",
// columns
"[fill]" +
"[fill]" +
"[fill]",
// rows
"[fill]"));
//---- label1 ----
label1.setText("text");
add(label1, "cell 0 0");
//---- textField4 ----
textField4.setText("some text");
add(textField4, "cell 1 0");
//---- button3 ----
button3.setText("...");
add(button3, "cell 2 0");
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
// JFormDesigner - End of variables declaration //GEN-END:variables
}
//---- class Tab2Panel ----------------------------------------------------
private static class Panel2
extends JPanel
{
private Panel2() {
initComponents();
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JTextField textField5 = new JTextField();
JButton button4 = new JButton();
//======== this ========
setLayout(new MigLayout(
"insets 0,hidemode 3,align center center",
// columns
"[fill]" +
"[fill]",
// rows
"[fill]"));
//---- textField5 ----
textField5.setText("more text");
add(textField5, "cell 0 0");
//---- button4 ----
button4.setText("...");
add(button4, "cell 1 0");
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
// JFormDesigner - End of variables declaration //GEN-END:variables
}
}

View File

@@ -14,7 +14,7 @@ new FormModel {
name: "this"
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class com.jgoodies.forms.layout.FormLayout ) {
"$columnSpecs": "70dlu:grow, unrelgap, 70dlu:grow"
"$rowSpecs": "default, linegap, fill:70dlu, pargap, pref, linegap, fill:70dlu:grow, unrelgap, fill:70dlu:grow, unrelgap, pref"
"$rowSpecs": "default, linegap, fill:70dlu, pargap, pref, linegap, fill:80dlu:grow, unrelgap, fill:80dlu:grow, unrelgap, pref"
} ) {
name: "panel9"
"opaque": false
@@ -29,31 +29,15 @@ new FormModel {
name: "splitPane1"
"resizeWeight": 0.5
"oneTouchExpandable": true
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel10"
"background": sfield java.awt.Color orange
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField2"
"text": "some text"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button1"
"text": "..."
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatContainerTest$Panel1" ) {
name: "panel15"
"background": new java.awt.Color( 217, 163, 67, 255 )
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "left"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel11"
"background": sfield java.awt.Color magenta
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField3"
"text": "some text"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button2"
"text": "..."
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatContainerTest$Panel2" ) {
name: "panel21"
"background": new java.awt.Color( 98, 181, 67, 255 )
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "right"
} )
@@ -65,15 +49,31 @@ new FormModel {
"orientation": 0
"resizeWeight": 0.5
"oneTouchExpandable": true
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) {
name: "panel12"
"background": sfield java.awt.Color orange
"background": new java.awt.Color( 242, 101, 34, 255 )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label3"
"text": "TOP"
"horizontalAlignment": 0
"foreground": sfield java.awt.Color white
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "Center"
} )
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "left"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) {
name: "panel13"
"background": sfield java.awt.Color magenta
"background": new java.awt.Color( 64, 182, 224, 255 )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label4"
"text": "BOTTOM"
"horizontalAlignment": 0
"foreground": sfield java.awt.Color white
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "Center"
} )
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "right"
} )
@@ -96,43 +96,6 @@ new FormModel {
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel1"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label1"
"text": "TOP"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField4"
"text": "some text"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button3"
"text": "..."
} )
}, new FormLayoutConstraints( null ) {
"title": "Tab 1"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel2"
"border": &LineBorder0 new javax.swing.border.LineBorder( sfield java.awt.Color magenta, 1, false )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField5"
"text": "some text"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button4"
"text": "..."
} )
}, new FormLayoutConstraints( null ) {
"title": "Tab 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label2"
"text": "text"
}, new FormLayoutConstraints( null ) {
"title": "Tab 3"
} )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridX": 1
"gridY": 7
@@ -143,27 +106,6 @@ new FormModel {
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel5"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label5"
"text": "LEFT"
} )
}, new FormLayoutConstraints( null ) {
"title": "Tab 1"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel6"
"border": #LineBorder0
}, new FormLayoutConstraints( null ) {
"title": "Tab 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label6"
"text": "text"
}, new FormLayoutConstraints( null ) {
"title": "Tab 3"
} )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridX": 3
"gridY": 7
@@ -174,28 +116,6 @@ new FormModel {
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel3"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label3"
"text": "BOTTOM"
} )
}, new FormLayoutConstraints( null ) {
"title": "Tab 1"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel4"
"border": #LineBorder0
}, new FormLayoutConstraints( null ) {
"title": "Tab 2"
"enabled": false
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label4"
"text": "text"
}, new FormLayoutConstraints( null ) {
"title": "Tab 3"
} )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridY": 9
} )
@@ -205,27 +125,6 @@ new FormModel {
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel7"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label7"
"text": "RIGHT"
} )
}, new FormLayoutConstraints( null ) {
"title": "Tab 1"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel8"
"border": #LineBorder0
}, new FormLayoutConstraints( null ) {
"title": "Tab 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label8"
"text": "text"
}, new FormLayoutConstraints( null ) {
"title": "Tab 3"
} )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridX": 3
"gridY": 9
@@ -271,8 +170,7 @@ new FormModel {
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "hasFullBorderCheckBox"
"text": "Show full border"
"mnemonic": 70
"text": "Show content border"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
@@ -291,5 +189,61 @@ new FormModel {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 625, 515 )
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "hidemode 3,align center center"
"$columnConstraints": "[fill][fill][fill]"
"$rowConstraints": "[fill]"
} ) {
name: "panel1"
auxiliary() {
"JavaCodeGenerator.className": "Panel1"
}
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label1"
"text": "text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField4"
"text": "some text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button3"
"text": "..."
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 595 )
"size": new java.awt.Dimension( 291, 118 )
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 0,hidemode 3,align center center"
"$columnConstraints": "[fill][fill]"
"$rowConstraints": "[fill]"
} ) {
name: "panel2"
auxiliary() {
"JavaCodeGenerator.className": "Panel2"
}
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField5"
"text": "more text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button4"
"text": "..."
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 340, 595 )
"size": new java.awt.Dimension( 291, 118 )
} )
}
}

View File

@@ -1,5 +1,17 @@
/*
* Created by JFormDesigner on Tue Aug 27 21:47:02 CEST 2019
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.testing;