SwingX: JXTitledPanel support (issue #22)

This commit is contained in:
Karl Tauber
2019-11-28 18:24:55 +01:00
parent a99ffd4821
commit f3f8c81518
9 changed files with 281 additions and 3 deletions

View File

@@ -36,6 +36,12 @@ public class FlatSwingXTest
public static void main( String[] args ) {
SwingUtilities.invokeLater( () -> {
FlatTestFrame frame = FlatTestFrame.create( args, "FlatSwingXTest" );
// without this, painting becomes very slow as soon as JXTitledPanel
// is used, because JXTitledPanel sets opaque to false and JXPanel
// then installs its own repaint manager
UIManager.put( "JXPanel.patch", true );
frame.useApplyComponentOrientation = true;
frame.showFrame( FlatSwingXTest::new );
} );
@@ -107,6 +113,19 @@ public class FlatSwingXTest
table = new JTable();
JLabel headerLabel = new JLabel();
JXHeader xHeader1 = new JXHeader();
JXTitledPanel xTitledPanel1 = new JXTitledPanel();
JLabel label7 = new JLabel();
JTextField textField1 = new JTextField();
JLabel label8 = new JLabel();
JTextField textField2 = new JTextField();
JLabel titledPanelLabel = new JLabel();
JXTitledPanel xTitledPanel2 = new JXTitledPanel();
JLabel label9 = new JLabel();
JTextField textField3 = new JTextField();
JLabel label10 = new JLabel();
JTextField textField4 = new JTextField();
JButton button1 = new JButton();
JButton button2 = new JButton();
//======== this ========
setLayout(new MigLayout(
@@ -125,7 +144,9 @@ public class FlatSwingXTest
"[]" +
"[]" +
"[]" +
"[]"));
"[]" +
"[]" +
"[37]"));
//---- label1 ----
label1.setText("enabled");
@@ -345,6 +366,70 @@ public class FlatSwingXTest
xHeader1.setDescription("Description\nMore description");
xHeader1.setIcon(new ImageIcon(getClass().getResource("/org/jdesktop/swingx/plaf/windows/resources/tipoftheday.png")));
add(xHeader1, "cell 1 7 3 1,width 200");
//======== xTitledPanel1 ========
{
xTitledPanel1.setTitle("Title");
xTitledPanel1.setOpaque(true);
Container xTitledPanel1ContentContainer = xTitledPanel1.getContentContainer();
xTitledPanel1ContentContainer.setLayout(new MigLayout(
"hidemode 3",
// columns
"[fill]" +
"[100,fill]",
// rows
"[]" +
"[]"));
//---- label7 ----
label7.setText("text");
xTitledPanel1ContentContainer.add(label7, "cell 0 0");
xTitledPanel1ContentContainer.add(textField1, "cell 1 0");
//---- label8 ----
label8.setText("text");
xTitledPanel1ContentContainer.add(label8, "cell 0 1");
xTitledPanel1ContentContainer.add(textField2, "cell 1 1");
}
add(xTitledPanel1, "cell 1 8 2 1,grow");
//---- titledPanelLabel ----
titledPanelLabel.setText("JXTitledPanel:");
add(titledPanelLabel, "cell 0 8,aligny top,growy 0");
//======== xTitledPanel2 ========
{
xTitledPanel2.setTitle("Title");
xTitledPanel2.setOpaque(true);
xTitledPanel2.setLeftDecoration(button1);
xTitledPanel2.setRightDecoration(button2);
Container xTitledPanel2ContentContainer = xTitledPanel2.getContentContainer();
xTitledPanel2ContentContainer.setLayout(new MigLayout(
"hidemode 3",
// columns
"[fill]" +
"[100,fill]",
// rows
"[]" +
"[]"));
//---- label9 ----
label9.setText("text");
xTitledPanel2ContentContainer.add(label9, "cell 0 0");
xTitledPanel2ContentContainer.add(textField3, "cell 1 0");
//---- label10 ----
label10.setText("text");
xTitledPanel2ContentContainer.add(label10, "cell 0 1");
xTitledPanel2ContentContainer.add(textField4, "cell 1 1");
}
add(xTitledPanel2, "cell 3 8,grow");
//---- button1 ----
button1.setText("<");
//---- button2 ----
button2.setText(">");
// JFormDesigner - End of component initialization //GEN-END:initComponents
xDatePicker1.setDate( new Date() );

View File

@@ -9,7 +9,7 @@ new FormModel {
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "ltr,insets dialog,hidemode 3"
"$columnConstraints": "[left][][][][fill]"
"$rowConstraints": "[]0[][]0[top][][][][]"
"$rowConstraints": "[]0[][]0[top][][][][][][37]"
} ) {
name: "this"
add( new FormComponent( "javax.swing.JLabel" ) {
@@ -280,9 +280,95 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 7 3 1,width 200"
} )
add( new FormContainer( "org.jdesktop.swingx.JXTitledPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "hidemode 3"
"$columnConstraints": "[fill][100,fill]"
"$rowConstraints": "[][]"
} ) {
name: "xTitledPanel1"
"title": "Title"
"opaque": true
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label7"
"text": "text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField1"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label8"
"text": "text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField2"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 8 2 1,grow"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "titledPanelLabel"
"text": "JXTitledPanel:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 8,aligny top,growy 0"
} )
add( new FormContainer( "org.jdesktop.swingx.JXTitledPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "hidemode 3"
"$columnConstraints": "[fill][100,fill]"
"$rowConstraints": "[][]"
} ) {
name: "xTitledPanel2"
"title": "Title"
"opaque": true
"leftDecoration": new FormReference( "button1" )
"rightDecoration": new FormReference( "button2" )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label9"
"text": "text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField3"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label10"
"text": "text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField4"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 8,grow"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 700, 600 )
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button1"
"text": "<"
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 5, 650 )
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button2"
"text": ">"
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 75, 650 )
} )
}
}