From e6de6b565b3a306ace004a261d5fa8b08d9cc831 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sun, 8 Sep 2019 19:00:27 +0200 Subject: [PATCH] Demo: added SplitPane --- .../com/formdev/flatlaf/demo/DemoFrame.java | 2 +- .../com/formdev/flatlaf/demo/DemoFrame.jfd | 2 +- .../com/formdev/flatlaf/demo/TabsPanel.java | 79 ++++++++++++++++--- .../com/formdev/flatlaf/demo/TabsPanel.jfd | 70 +++++++++++++--- 4 files changed, 132 insertions(+), 21 deletions(-) diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.java b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.java index f121077e..8d6150cd 100644 --- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.java +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.java @@ -237,7 +237,7 @@ class DemoFrame tabbedPane.addTab("Basic Components", basicComponentsPanel); tabbedPane.addTab("More Components", moreComponentsPanel); tabbedPane.addTab("Data Components", dataComponentsPanel); - tabbedPane.addTab("Tabs", tabsPanel); + tabbedPane.addTab("SplitPane & Tabs", tabsPanel); tabbedPane.addTab("Option Pane", optionPanePanel); } contentPanel.add(tabbedPane, "cell 0 0"); diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.jfd b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.jfd index a5ad4ff8..7066dfb7 100644 --- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.jfd +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.jfd @@ -79,7 +79,7 @@ new FormModel { add( new FormComponent( "com.formdev.flatlaf.demo.TabsPanel" ) { name: "tabsPanel" }, new FormLayoutConstraints( null ) { - "title": "Tabs" + "title": "SplitPane & Tabs" } ) add( new FormComponent( "com.formdev.flatlaf.demo.OptionPanePanel" ) { name: "optionPanePanel" diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/TabsPanel.java b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/TabsPanel.java index 03cb408a..9ef0f7e9 100644 --- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/TabsPanel.java +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/TabsPanel.java @@ -63,6 +63,14 @@ class TabsPanel 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(); + JPanel panel11 = new JPanel(); + JSplitPane splitPane2 = new JSplitPane(); + JPanel panel12 = new JPanel(); + JPanel panel13 = new JPanel(); JLabel tabbedPaneLabel = new JLabel(); tabbedPane1 = new JTabbedPane(); JPanel panel1 = new JPanel(); @@ -101,11 +109,64 @@ class TabsPanel { panel9.setLayout(new FormLayout( "70dlu:grow, $lcgap, 70dlu:grow", - "pref, 2*($lgap, fill:70dlu:grow), 2*($lgap, pref)")); + "default, $lgap, fill:70dlu, $lgap, pref, 2*($lgap, fill:70dlu:grow), 2*($lgap, pref)")); + + //---- splitPaneLabel ---- + splitPaneLabel.setText("JSplitPane:"); + panel9.add(splitPaneLabel, cc.xy(1, 1)); + + //======== splitPane3 ======== + { + splitPane3.setResizeWeight(0.5); + + //======== splitPane1 ======== + { + splitPane1.setResizeWeight(0.5); + splitPane1.setOneTouchExpandable(true); + + //======== panel10 ======== + { + panel10.setBackground(Color.orange); + panel10.setLayout(new FlowLayout()); + } + splitPane1.setLeftComponent(panel10); + + //======== panel11 ======== + { + panel11.setBackground(Color.magenta); + panel11.setLayout(new FlowLayout()); + } + splitPane1.setRightComponent(panel11); + } + splitPane3.setLeftComponent(splitPane1); + + //======== splitPane2 ======== + { + splitPane2.setOrientation(JSplitPane.VERTICAL_SPLIT); + splitPane2.setResizeWeight(0.5); + splitPane2.setOneTouchExpandable(true); + + //======== panel12 ======== + { + panel12.setBackground(Color.orange); + panel12.setLayout(new FlowLayout()); + } + splitPane2.setTopComponent(panel12); + + //======== panel13 ======== + { + panel13.setBackground(Color.magenta); + panel13.setLayout(new FlowLayout()); + } + splitPane2.setBottomComponent(panel13); + } + splitPane3.setRightComponent(splitPane2); + } + panel9.add(splitPane3, cc.xywh(1, 3, 3, 1)); //---- tabbedPaneLabel ---- tabbedPaneLabel.setText("JTabbedPane:"); - panel9.add(tabbedPaneLabel, cc.xy(1, 1)); + panel9.add(tabbedPaneLabel, cc.xy(1, 5)); //======== tabbedPane1 ======== { @@ -131,7 +192,7 @@ class TabsPanel label2.setText("text"); tabbedPane1.addTab("Tab 3", label2); } - panel9.add(tabbedPane1, cc.xy(1, 3)); + panel9.add(tabbedPane1, cc.xy(1, 7)); //======== tabbedPane3 ======== { @@ -158,7 +219,7 @@ class TabsPanel label6.setText("text"); tabbedPane3.addTab("Tab 3", label6); } - panel9.add(tabbedPane3, cc.xy(3, 3)); + panel9.add(tabbedPane3, cc.xy(3, 7)); //======== tabbedPane2 ======== { @@ -186,7 +247,7 @@ class TabsPanel label4.setText("text"); tabbedPane2.addTab("Tab 3", label4); } - panel9.add(tabbedPane2, cc.xy(1, 5)); + panel9.add(tabbedPane2, cc.xy(1, 9)); //======== tabbedPane4 ======== { @@ -213,25 +274,25 @@ class TabsPanel label8.setText("text"); tabbedPane4.addTab("Tab 3", label8); } - panel9.add(tabbedPane4, cc.xy(3, 5)); + panel9.add(tabbedPane4, cc.xy(3, 9)); //---- tabScrollCheckBox ---- tabScrollCheckBox.setText("tabLayoutPolicy = SCROLL"); tabScrollCheckBox.setMnemonic('S'); tabScrollCheckBox.addActionListener(e -> tabScrollChanged()); - panel9.add(tabScrollCheckBox, cc.xy(1, 7, CellConstraints.LEFT, CellConstraints.DEFAULT)); + panel9.add(tabScrollCheckBox, cc.xy(1, 11, CellConstraints.LEFT, CellConstraints.DEFAULT)); //---- hasFullBorderCheckBox ---- hasFullBorderCheckBox.setText("JTabbedPane.hasFullBorder"); hasFullBorderCheckBox.setMnemonic('F'); hasFullBorderCheckBox.addActionListener(e -> hasFullBorderChanged()); - panel9.add(hasFullBorderCheckBox, cc.xy(3, 7, CellConstraints.LEFT, CellConstraints.DEFAULT)); + panel9.add(hasFullBorderCheckBox, cc.xy(3, 11, CellConstraints.LEFT, CellConstraints.DEFAULT)); //---- moreTabsCheckBox ---- moreTabsCheckBox.setText("more tabs"); moreTabsCheckBox.setMnemonic('M'); moreTabsCheckBox.addActionListener(e -> moreTabsChanged()); - panel9.add(moreTabsCheckBox, cc.xy(1, 9, CellConstraints.LEFT, CellConstraints.DEFAULT)); + panel9.add(moreTabsCheckBox, cc.xy(1, 13, CellConstraints.LEFT, CellConstraints.DEFAULT)); } add(panel9, "cell 0 0"); // JFormDesigner - End of component initialization //GEN-END:initComponents diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/TabsPanel.jfd b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/TabsPanel.jfd index 230253f9..da428d8f 100644 --- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/TabsPanel.jfd +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/TabsPanel.jfd @@ -14,15 +14,65 @@ new FormModel { name: "this" add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class com.jgoodies.forms.layout.FormLayout ) { "$columnSpecs": "70dlu:grow, labelcompgap, 70dlu:grow" - "$rowSpecs": "pref, linegap, fill:70dlu:grow, linegap, fill:70dlu:grow, linegap, pref, linegap, pref" + "$rowSpecs": "default, linegap, fill:70dlu, linegap, pref, linegap, fill:70dlu:grow, linegap, fill:70dlu:grow, linegap, pref, linegap, pref" } ) { name: "panel9" + add( new FormComponent( "javax.swing.JLabel" ) { + name: "splitPaneLabel" + "text": "JSplitPane:" + }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) ) + add( new FormContainer( "javax.swing.JSplitPane", new FormLayoutManager( class javax.swing.JSplitPane ) ) { + name: "splitPane3" + "resizeWeight": 0.5 + 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 ) ) { + name: "panel10" + "background": sfield java.awt.Color orange + }, 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 + }, new FormLayoutConstraints( class java.lang.String ) { + "value": "right" + } ) + }, new FormLayoutConstraints( class java.lang.String ) { + "value": "left" + } ) + add( new FormContainer( "javax.swing.JSplitPane", new FormLayoutManager( class javax.swing.JSplitPane ) ) { + name: "splitPane2" + "orientation": 0 + "resizeWeight": 0.5 + "oneTouchExpandable": true + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) { + name: "panel12" + "background": sfield java.awt.Color orange + }, new FormLayoutConstraints( class java.lang.String ) { + "value": "left" + } ) + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) { + name: "panel13" + "background": sfield java.awt.Color magenta + }, new FormLayoutConstraints( class java.lang.String ) { + "value": "right" + } ) + }, new FormLayoutConstraints( class java.lang.String ) { + "value": "right" + } ) + }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { + "gridY": 3 + "gridWidth": 3 + } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "tabbedPaneLabel" "text": "JTabbedPane:" }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { "gridX": 1 - "gridY": 1 + "gridY": 5 } ) add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { name: "tabbedPane1" @@ -52,7 +102,7 @@ new FormModel { } ) }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { "gridX": 1 - "gridY": 3 + "gridY": 7 } ) add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { name: "tabbedPane3" @@ -83,7 +133,7 @@ new FormModel { } ) }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { "gridX": 3 - "gridY": 3 + "gridY": 7 } ) add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { name: "tabbedPane2" @@ -114,7 +164,7 @@ new FormModel { "title": "Tab 3" } ) }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { - "gridY": 5 + "gridY": 9 } ) add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { name: "tabbedPane4" @@ -145,7 +195,7 @@ new FormModel { } ) }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { "gridX": 3 - "gridY": 5 + "gridY": 9 } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "tabScrollCheckBox" @@ -157,7 +207,7 @@ new FormModel { addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabScrollChanged", false ) ) }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { "gridX": 1 - "gridY": 7 + "gridY": 11 "hAlign": sfield com.jgoodies.forms.layout.CellConstraints LEFT } ) add( new FormComponent( "javax.swing.JCheckBox" ) { @@ -170,7 +220,7 @@ new FormModel { addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "hasFullBorderChanged", false ) ) }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { "gridX": 3 - "gridY": 7 + "gridY": 11 "hAlign": sfield com.jgoodies.forms.layout.CellConstraints LEFT } ) add( new FormComponent( "javax.swing.JCheckBox" ) { @@ -183,7 +233,7 @@ new FormModel { addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "moreTabsChanged", false ) ) }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { "gridX": 1 - "gridY": 9 + "gridY": 13 "hAlign": sfield com.jgoodies.forms.layout.CellConstraints LEFT } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { @@ -191,7 +241,7 @@ new FormModel { } ) }, new FormLayoutConstraints( null ) { "location": new java.awt.Point( 0, 0 ) - "size": new java.awt.Dimension( 400, 400 ) + "size": new java.awt.Dimension( 400, 585 ) } ) } }