diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponents2Test.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponents2Test.java index 2a4546ea..2868c4da 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponents2Test.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponents2Test.java @@ -22,8 +22,15 @@ import java.awt.EventQueue; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.Transferable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; import javax.swing.*; import javax.swing.table.*; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; import com.formdev.flatlaf.icons.FlatMenuArrowIcon; import net.miginfocom.swing.*; @@ -40,8 +47,78 @@ public class FlatComponents2Test } ); } + private final TestListModel listModel; + private final TestTreeModel treeModel; + private final TestTableModel tableModel; + FlatComponents2Test() { initComponents(); + + // list model + listModel = new TestListModel( (Integer) listRowCountSpinner.getValue() ); + list1.setModel( listModel ); + list2.setModel( listModel ); + + // tree model + treeModel = new TestTreeModel( (Integer) treeRowCountSpinner.getValue() ); + tree1.setModel( treeModel ); + tree2.setModel( treeModel ); + + // table model + tableModel = new TestTableModel( (Integer) tableRowCountSpinner.getValue() ); + table1.setModel( tableModel ); + + // table column editors + TableColumnModel cm = table1.getColumnModel(); + String[] months = new String[] { + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" + }; + cm.getColumn(2).setCellEditor( new DefaultCellEditor( new JComboBox<>( months ) ) ); + JComboBox editableComboBox = new JComboBox<>( months ); + editableComboBox.setEditable( true ); + cm.getColumn(3).setCellEditor( new DefaultCellEditor( editableComboBox ) ); + + expandTree( tree1 ); + expandTree( tree2 ); + } + + private void expandTree( JTree tree ) { + int count = tree.getRowCount(); + for( int i = count - 1; i >= 0; i-- ) + tree.expandRow( i ); + } + + private void listRowCountChanged() { + listModel.setSize( (Integer) listRowCountSpinner.getValue() ); + } + + private void treeRowCountChanged() { + int rowCount = (Integer) treeRowCountSpinner.getValue(); + + // round to 20 + if( rowCount % 20 != 0 ) { + rowCount += 20 - (rowCount % 20); + treeRowCountSpinner.setValue( rowCount ); + } + + int oldCount1 = tree1.getRowCount(); + int oldCount2 = tree2.getRowCount(); + + treeModel.setRowCount( rowCount ); + + int newCount1 = tree1.getRowCount(); + int newCount2 = tree2.getRowCount(); + + // expand added rows + for( int i = newCount1 - 1; i >= oldCount1; i-- ) + tree1.expandRow( i ); + for( int i = newCount2 - 1; i >= oldCount2; i-- ) + tree2.expandRow( i ); + } + + private void tableRowCountChanged() { + tableModel.setRowCount( (Integer) tableRowCountSpinner.getValue() ); } private void dndChanged() { @@ -121,7 +198,6 @@ public class FlatComponents2Test } ); } - @SuppressWarnings( { "unchecked", "rawtypes" } ) private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents JLabel textFieldLabel = new JLabel(); @@ -132,14 +208,23 @@ public class FlatComponents2Test list1 = new JList<>(); JScrollPane scrollPane2 = new JScrollPane(); list2 = new JList<>(); + JPanel listOptionsPanel = new JPanel(); + JLabel listRowCountLabel = new JLabel(); + listRowCountSpinner = new JSpinner(); JLabel treeLabel = new JLabel(); JScrollPane scrollPane3 = new JScrollPane(); tree1 = new JTree(); JScrollPane scrollPane4 = new JScrollPane(); tree2 = new JTree(); + JPanel treeOptionsPanel = new JPanel(); + JLabel treeRowCountLabel = new JLabel(); + treeRowCountSpinner = new JSpinner(); JLabel tableLabel = new JLabel(); scrollPane5 = new JScrollPane(); table1 = new JTable(); + JPanel tableOptionsPanel = new JPanel(); + JLabel tableRowCountLabel = new JLabel(); + tableRowCountSpinner = new JSpinner(); dndCheckBox = new JCheckBox(); tableHeaderButtonCheckBox = new JCheckBox(); rowSelectionCheckBox = new JCheckBox(); @@ -155,7 +240,8 @@ public class FlatComponents2Test // columns "[]" + "[200,fill]" + - "[200,fill]", + "[200,fill]" + + "[fill]", // rows "[]" + "[150,grow,sizegroup 1,fill]" + @@ -183,31 +269,6 @@ public class FlatComponents2Test //======== scrollPane1 ======== { - - //---- list1 ---- - list1.setModel(new AbstractListModel() { - String[] values = { - "item 1", - "item 2", - "item 3", - "item 4", - "item 5", - "item 6", - "item 7", - "item 8", - "item 9", - "item 10", - "item 11", - "item 12", - "item 13", - "item 14", - "item 15" - }; - @Override - public int getSize() { return values.length; } - @Override - public String getElementAt(int i) { return values[i]; } - }); scrollPane1.setViewportView(list1); } add(scrollPane1, "cell 1 1"); @@ -216,34 +277,32 @@ public class FlatComponents2Test { //---- list2 ---- - list2.setModel(new AbstractListModel() { - String[] values = { - "item 1", - "item 2", - "item 3", - "item 4", - "item 5", - "item 6", - "item 7", - "item 8", - "item 9", - "item 10", - "item 11", - "item 12", - "item 13", - "item 14", - "item 15" - }; - @Override - public int getSize() { return values.length; } - @Override - public String getElementAt(int i) { return values[i]; } - }); list2.setEnabled(false); scrollPane2.setViewportView(list2); } add(scrollPane2, "cell 2 1"); + //======== listOptionsPanel ======== + { + listOptionsPanel.setLayout(new MigLayout( + "hidemode 3", + // columns + "[fill]" + + "[90,fill]", + // rows + "[]")); + + //---- listRowCountLabel ---- + listRowCountLabel.setText("Row count:"); + listOptionsPanel.add(listRowCountLabel, "cell 0 0"); + + //---- listRowCountSpinner ---- + listRowCountSpinner.setModel(new SpinnerNumberModel(20, 0, null, 10)); + listRowCountSpinner.addChangeListener(e -> listRowCountChanged()); + listOptionsPanel.add(listRowCountSpinner, "cell 1 0"); + } + add(listOptionsPanel, "cell 3 1"); + //---- treeLabel ---- treeLabel.setText("JTree:"); add(treeLabel, "cell 0 2,aligny top,growy 0"); @@ -267,6 +326,27 @@ public class FlatComponents2Test } add(scrollPane4, "cell 2 2"); + //======== treeOptionsPanel ======== + { + treeOptionsPanel.setLayout(new MigLayout( + "hidemode 3", + // columns + "[fill]" + + "[90,fill]", + // rows + "[]")); + + //---- treeRowCountLabel ---- + treeRowCountLabel.setText("Row count:"); + treeOptionsPanel.add(treeRowCountLabel, "cell 0 0"); + + //---- treeRowCountSpinner ---- + treeRowCountSpinner.setModel(new SpinnerNumberModel(20, 20, null, 20)); + treeRowCountSpinner.addChangeListener(e -> treeRowCountChanged()); + treeOptionsPanel.add(treeRowCountSpinner, "cell 1 0"); + } + add(treeOptionsPanel, "cell 3 2"); + //---- tableLabel ---- tableLabel.setText("JTable:"); add(tableLabel, "cell 0 3,aligny top,growy 0"); @@ -275,78 +355,32 @@ public class FlatComponents2Test { //---- table1 ---- - table1.setModel(new DefaultTableModel( - new Object[][] { - {"item 1", "item 1b", "January", "July", 123, null}, - {"item 2", "item 2b", "February", "August", 456, true}, - {"item 3", null, "March", null, null, null}, - {"item 4", null, "April", null, null, null}, - {"item 5", null, "May", null, null, null}, - {"item 6", null, "June", null, null, null}, - {"item 7", null, "July", null, null, null}, - {"item 8", null, "August", null, null, null}, - {"item 9", null, "September", null, null, null}, - {"item 10", null, "October", null, null, null}, - {"item 11", null, "November", null, null, null}, - {"item 12", null, "December", null, null, null}, - }, - new String[] { - "Not editable", "Text", "Combo", "Combo Editable", "Integer", "Boolean" - } - ) { - Class[] columnTypes = new Class[] { - Object.class, Object.class, String.class, String.class, Integer.class, Boolean.class - }; - boolean[] columnEditable = new boolean[] { - false, true, true, true, true, true - }; - @Override - public Class getColumnClass(int columnIndex) { - return columnTypes[columnIndex]; - } - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return columnEditable[columnIndex]; - } - }); - { - TableColumnModel cm = table1.getColumnModel(); - cm.getColumn(2).setCellEditor(new DefaultCellEditor( - new JComboBox(new DefaultComboBoxModel(new String[] { - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December" - })))); - cm.getColumn(3).setCellEditor(new DefaultCellEditor( - new JComboBox(new DefaultComboBoxModel(new String[] { - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December" - })))); - } table1.setAutoCreateRowSorter(true); scrollPane5.setViewportView(table1); } add(scrollPane5, "cell 1 3 2 1,width 300"); + //======== tableOptionsPanel ======== + { + tableOptionsPanel.setLayout(new MigLayout( + "hidemode 3", + // columns + "[fill]" + + "[90,fill]", + // rows + "[]")); + + //---- tableRowCountLabel ---- + tableRowCountLabel.setText("Row count:"); + tableOptionsPanel.add(tableRowCountLabel, "cell 0 0"); + + //---- tableRowCountSpinner ---- + tableRowCountSpinner.setModel(new SpinnerNumberModel(20, 0, null, 10)); + tableRowCountSpinner.addChangeListener(e -> tableRowCountChanged()); + tableOptionsPanel.add(tableRowCountSpinner, "cell 1 0"); + } + add(tableOptionsPanel, "cell 3 3"); + //---- dndCheckBox ---- dndCheckBox.setText("enable drag and drop"); dndCheckBox.setMnemonic('D'); @@ -389,17 +423,18 @@ public class FlatComponents2Test redGridColorCheckBox.addActionListener(e -> redGridColorChanged()); add(redGridColorCheckBox, "cell 0 5 3 1"); // JFormDesigner - End of component initialization //GEN-END:initComponents - - ((JComboBox)((DefaultCellEditor)table1.getColumnModel().getColumn( 3 ).getCellEditor()).getComponent()).setEditable( true ); } // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables private JList list1; private JList list2; + private JSpinner listRowCountSpinner; private JTree tree1; private JTree tree2; + private JSpinner treeRowCountSpinner; private JScrollPane scrollPane5; private JTable table1; + private JSpinner tableRowCountSpinner; private JCheckBox dndCheckBox; private JCheckBox tableHeaderButtonCheckBox; private JCheckBox rowSelectionCheckBox; @@ -410,6 +445,27 @@ public class FlatComponents2Test private JCheckBox redGridColorCheckBox; // JFormDesigner - End of variables declaration //GEN-END:variables + private final String[] randomRowStrings = new String[1000]; + private final Random random = new Random(); + + private String randomRowString( int row ) { + int index = row % randomRowStrings.length; + + String s = randomRowStrings[index]; + if( s != null ) + return s; + + char[] chars = new char[3 + random.nextInt( 15 - 3 )]; + for( int i = 0; i < chars.length; i++ ) + chars[i] = (char) ((i == 0 ? 'A' : 'a') + random.nextInt( 26 )); + if( chars.length > 6 ) + chars[chars.length / 2] = ' '; + s = new String( chars ); + + randomRowStrings[index] = s; + return s; + } + //---- class DummyTransferHandler ----------------------------------------- private static class DummyTransferHandler @@ -443,4 +499,234 @@ public class FlatComponents2Test return false; } } + + //---- class TestListModel ------------------------------------------------ + + private class TestListModel + extends AbstractListModel + { + private int size; + + TestListModel( int size ) { + setSize( size ); + } + + void setSize( int size ) { + int oldSize = this.size; + this.size = size; + + // fire event + if( size > oldSize ) + fireIntervalAdded( this, oldSize, size - 1 ); + else if( size < oldSize ) + fireIntervalRemoved( this, size, oldSize - 1 ); + } + + @Override + public int getSize() { + return size; + } + + @Override + public String getElementAt( int index ) { + return (index < 20) + ? "item " + (index + 1) + : "item " + (index + 1) + " " + randomRowString( index ); + } + } + + //---- TestTreeModel ------------------------------------------------------ + + private class TestTreeModel + extends DefaultTreeModel + { + private int rowCount; + + TestTreeModel( int rowCount ) { + super( new DefaultMutableTreeNode( "JTree" ) ); + setRowCount( rowCount ); + } + + void setRowCount( int rowCount ) { + if( rowCount < 20 ) + rowCount = 20; + + if( rowCount > this.rowCount ) { + // add nodes + int oldRootChildCount = root.getChildCount(); + while( rowCount > this.rowCount ) { + addTwentyNodes( (DefaultMutableTreeNode) root, this.rowCount ); + this.rowCount += 20; + } + + // fire event + int newRootChildCount = root.getChildCount(); + if( newRootChildCount > oldRootChildCount ) { + int[] childIndices = new int[newRootChildCount - oldRootChildCount]; + for( int i = 0; i < childIndices.length; i++ ) + childIndices[i] = oldRootChildCount + i; + nodesWereInserted( root, childIndices ); + } + } else if( rowCount < this.rowCount ) { + // remove nodes + int oldRootChildCount = root.getChildCount(); + List removedChildren = new ArrayList<>(); + while( this.rowCount > rowCount ) { + int index = root.getChildCount() - 1; + removedChildren.add( 0, root.getChildAt( index ) ); + ((DefaultMutableTreeNode)root).remove( index ); + this.rowCount -= 20; + } + + // fire event + int newRootChildCount = root.getChildCount(); + if( newRootChildCount < oldRootChildCount ) { + int[] childIndices = new int[oldRootChildCount - newRootChildCount]; + for( int i = 0; i < childIndices.length; i++ ) + childIndices[i] = newRootChildCount + i; + nodesWereRemoved( root, childIndices, removedChildren.toArray() ); + } + } + } + + private void addTwentyNodes( DefaultMutableTreeNode root, int firstRowIndex ) { + if( firstRowIndex == 0 ) { + DefaultMutableTreeNode n = new DefaultMutableTreeNode( "colors" ); + n.add( new DefaultMutableTreeNode( "blue" ) ); + n.add( new DefaultMutableTreeNode( "violet" ) ); + n.add( new DefaultMutableTreeNode( "red" ) ); + n.add( new DefaultMutableTreeNode( "yellow" ) ); + root.add( n ); + + n = new DefaultMutableTreeNode( "sports" ); + n.add( new DefaultMutableTreeNode( "basketball" ) ); + n.add( new DefaultMutableTreeNode( "soccer" ) ); + n.add( new DefaultMutableTreeNode( "football" ) ); + n.add( new DefaultMutableTreeNode( "hockey" ) ); + root.add( n ); + + n = new DefaultMutableTreeNode( "food" ); + n.add( new DefaultMutableTreeNode( "hot dogs" ) ); + + DefaultMutableTreeNode n2 = new DefaultMutableTreeNode( "pizza" ); + n2.add( new DefaultMutableTreeNode( "pizza aglio e olio" ) ); + n2.add( new DefaultMutableTreeNode( "pizza calabrese" ) ); + n2.add( new DefaultMutableTreeNode( "pizza infernale" ) ); + n2.add( new DefaultMutableTreeNode( "pizza margherita bianca" ) ); + n2.add( new DefaultMutableTreeNode( "pizza quattro stagioni" ) ); + n.add( n2 ); + + n.add( new DefaultMutableTreeNode( "ravioli" ) ); + n.add( new DefaultMutableTreeNode( "bananas" ) ); + root.add( n ); + } else { + DefaultMutableTreeNode n = new DefaultMutableTreeNode( "item " + firstRowIndex + " " + randomRowString( firstRowIndex ) ); + for( int i = 1; i < 20; i++ ) { + int index = firstRowIndex + i; + n.add( new DefaultMutableTreeNode( "item " + index + " " + randomRowString( index ) ) ); + } + root.add( n ); + } + } + } + + //---- TestTableModel ----------------------------------------------------- + + private class TestTableModel + extends AbstractTableModel + { + private final String[] columnNames = new String[] { + "Not editable", "Text", "Combo", "Combo Editable", "Integer", "Boolean" + }; + + private final Class[] columnTypes = new Class[] { + Object.class, Object.class, String.class, String.class, Integer.class, Boolean.class + }; + + private final boolean[] columnEditable = new boolean[] { + false, true, true, true, true, true + }; + + private final Object[][] rows = new Object[][] { + { "item 1", "item 1b", "January", "July", 123, null }, + { "item 2", "item 2b", "February", "August", 456, true }, + { "item 3", null, "March", null, null, null }, + { "item 4", null, "April", null, null, null }, + { "item 5", null, "May", null, null, null }, + { "item 6", null, "June", null, null, null }, + { "item 7", null, "July", null, null, null }, + { "item 8", null, "August", null, null, null }, + { "item 9", null, "September", null, null, null }, + { "item 10", null, "October", null, null, null }, + { "item 11", null, "November", null, null, null }, + { "item 12", null, "December", null, null, null }, + }; + + private int rowCount = rows.length; + private final Map moreRowsMap = new HashMap<>(); + + TestTableModel( int rowCount ) { + setRowCount( rowCount ); + } + + void setRowCount( int rowCount ) { + int oldRowCount = this.rowCount; + this.rowCount = rowCount; + + // fire event + if( rowCount > oldRowCount ) + fireTableRowsInserted( oldRowCount, rowCount - 1 ); + else if( rowCount < oldRowCount ) + fireTableRowsDeleted( rowCount, oldRowCount - 1 ); + } + + @Override + public int getRowCount() { + return rowCount; + } + + @Override + public int getColumnCount() { + return columnNames.length; + } + + @Override + public String getColumnName( int columnIndex ) { + return columnNames[columnIndex]; + } + + @Override + public Class getColumnClass( int columnIndex ) { + return columnTypes[columnIndex]; + } + + @Override + public boolean isCellEditable( int rowIndex, int columnIndex ) { + return columnEditable[columnIndex]; + } + + @Override + public Object getValueAt( int rowIndex, int columnIndex ) { + if( rowIndex < rows.length ) + return rows[rowIndex][columnIndex]; + + Object[] row = moreRowsMap.get( rowIndex ); + Object value = (row != null) + ? row[columnIndex] + : (columnIndex == 1 ? randomRowString( rowIndex ) : null); + return (columnIndex == 0 && value == null) ? "item " + (rowIndex + 1) : value; + } + + @Override + public void setValueAt( Object value, int rowIndex, int columnIndex ) { + if( rowIndex < rows.length ) + rows[rowIndex][columnIndex] = value; + else { + Object[] row = moreRowsMap.computeIfAbsent( rowIndex, k -> new Object[getColumnCount()] ); + row[columnIndex] = value; + } + + fireTableCellUpdated( rowIndex, columnIndex ); + } + } } diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponents2Test.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponents2Test.jfd index fecac421..352aa7ee 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponents2Test.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponents2Test.jfd @@ -8,7 +8,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": "[][200,fill][200,fill]" + "$columnConstraints": "[][200,fill][200,fill][fill]" "$rowConstraints": "[][150,grow,sizegroup 1,fill][150,grow,sizegroup 1,fill][150,grow,sizegroup 1,fill][][]" } ) { name: "this" @@ -41,23 +41,6 @@ new FormModel { name: "scrollPane1" add( new FormComponent( "javax.swing.JList" ) { name: "list1" - "model": new javax.swing.DefaultListModel { - addElement( "item 1" ) - addElement( "item 2" ) - addElement( "item 3" ) - addElement( "item 4" ) - addElement( "item 5" ) - addElement( "item 6" ) - addElement( "item 7" ) - addElement( "item 8" ) - addElement( "item 9" ) - addElement( "item 10" ) - addElement( "item 11" ) - addElement( "item 12" ) - addElement( "item 13" ) - addElement( "item 14" ) - addElement( "item 15" ) - } auxiliary() { "JavaCodeGenerator.typeParameters": "String" "JavaCodeGenerator.variableLocal": false @@ -70,23 +53,6 @@ new FormModel { name: "scrollPane2" add( new FormComponent( "javax.swing.JList" ) { name: "list2" - "model": new javax.swing.DefaultListModel { - addElement( "item 1" ) - addElement( "item 2" ) - addElement( "item 3" ) - addElement( "item 4" ) - addElement( "item 5" ) - addElement( "item 6" ) - addElement( "item 7" ) - addElement( "item 8" ) - addElement( "item 9" ) - addElement( "item 10" ) - addElement( "item 11" ) - addElement( "item 12" ) - addElement( "item 13" ) - addElement( "item 14" ) - addElement( "item 15" ) - } "enabled": false auxiliary() { "JavaCodeGenerator.typeParameters": "String" @@ -96,6 +62,35 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 2 1" } ) + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + "$layoutConstraints": "hidemode 3" + "$columnConstraints": "[fill][90,fill]" + "$rowConstraints": "[]" + } ) { + name: "listOptionsPanel" + add( new FormComponent( "javax.swing.JLabel" ) { + name: "listRowCountLabel" + "text": "Row count:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0" + } ) + add( new FormComponent( "javax.swing.JSpinner" ) { + name: "listRowCountSpinner" + "model": &SpinnerNumberModel0 new javax.swing.SpinnerNumberModel { + minimum: 0 + stepSize: 10 + value: 20 + } + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "listRowCountChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 0" + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 1" + } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "treeLabel" "text": "JTree:" @@ -127,6 +122,35 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 2 2" } ) + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + "$layoutConstraints": "hidemode 3" + "$columnConstraints": "[fill][90,fill]" + "$rowConstraints": "[]" + } ) { + name: "treeOptionsPanel" + add( new FormComponent( "javax.swing.JLabel" ) { + name: "treeRowCountLabel" + "text": "Row count:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0" + } ) + add( new FormComponent( "javax.swing.JSpinner" ) { + name: "treeRowCountSpinner" + "model": new javax.swing.SpinnerNumberModel { + minimum: 20 + stepSize: 20 + value: 20 + } + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "treeRowCountChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 0" + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 2" + } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "tableLabel" "text": "JTable:" @@ -140,132 +164,6 @@ new FormModel { } add( new FormComponent( "javax.swing.JTable" ) { name: "table1" - "model": new com.jformdesigner.model.SwingTableModel( new java.util.Vector { - add( new java.util.Vector { - add( "item 1" ) - add( "item 1b" ) - add( "January" ) - add( "July" ) - add( 123 ) - add( null ) - } ) - add( new java.util.Vector { - add( "item 2" ) - add( "item 2b" ) - add( "February" ) - add( "August" ) - add( 456 ) - add( true ) - } ) - add( new java.util.Vector { - add( "item 3" ) - add( null ) - add( "March" ) - add( null ) - add( null ) - add( null ) - } ) - add( new java.util.Vector { - add( "item 4" ) - add( null ) - add( "April" ) - add( null ) - add( null ) - add( null ) - } ) - add( new java.util.Vector { - add( "item 5" ) - add( null ) - add( "May" ) - add( null ) - add( null ) - add( null ) - } ) - add( new java.util.Vector { - add( "item 6" ) - add( null ) - add( "June" ) - add( null ) - add( null ) - add( null ) - } ) - add( new java.util.Vector { - add( "item 7" ) - add( null ) - add( "July" ) - add( null ) - add( null ) - add( null ) - } ) - add( new java.util.Vector { - add( "item 8" ) - add( null ) - add( "August" ) - add( null ) - add( null ) - add( null ) - } ) - add( new java.util.Vector { - add( "item 9" ) - add( null ) - add( "September" ) - add( null ) - add( null ) - add( null ) - } ) - add( new java.util.Vector { - add( "item 10" ) - add( null ) - add( "October" ) - add( null ) - add( null ) - add( null ) - } ) - add( new java.util.Vector { - add( "item 11" ) - add( null ) - add( "November" ) - add( null ) - add( null ) - add( null ) - } ) - add( new java.util.Vector { - add( "item 12" ) - add( null ) - add( "December" ) - add( null ) - add( null ) - add( null ) - } ) - }, new java.util.Vector { - add( "Not editable" ) - add( "Text" ) - add( "Combo" ) - add( "Combo Editable" ) - add( "Integer" ) - add( "Boolean" ) - }, new java.util.Vector { - add( null ) - add( null ) - add( class java.lang.String ) - add( class java.lang.String ) - add( class java.lang.Integer ) - add( class java.lang.Boolean ) - }, new java.util.Vector { - add( false ) - add( null ) - add( null ) - add( null ) - add( null ) - add( null ) - }, new java.util.Vector { - add( null ) - add( null ) - add( new com.jformdesigner.model.SwingTableColumn( new java.lang.Object[ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], 0, 0, 0, true ) ) - add( new com.jformdesigner.model.SwingTableColumn( new java.lang.Object[ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], 0, 0, 0, true ) ) - add( null ) - add( null ) - } ) "autoCreateRowSorter": true auxiliary() { "JavaCodeGenerator.variableLocal": false @@ -274,6 +172,31 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 3 2 1,width 300" } ) + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + "$layoutConstraints": "hidemode 3" + "$columnConstraints": "[fill][90,fill]" + "$rowConstraints": "[]" + } ) { + name: "tableOptionsPanel" + add( new FormComponent( "javax.swing.JLabel" ) { + name: "tableRowCountLabel" + "text": "Row count:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0" + } ) + add( new FormComponent( "javax.swing.JSpinner" ) { + name: "tableRowCountSpinner" + "model": #SpinnerNumberModel0 + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "tableRowCountChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 0" + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 3" + } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "dndCheckBox" "text": "enable drag and drop"