mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-08 23:08:42 +03:00
Demo: "Data components" tab: added checkboxes to control table grid and selection
This commit is contained in:
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.formdev.flatlaf.demo;
|
package com.formdev.flatlaf.demo;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.EventQueue;
|
||||||
import java.awt.datatransfer.DataFlavor;
|
import java.awt.datatransfer.DataFlavor;
|
||||||
import java.awt.datatransfer.StringSelection;
|
import java.awt.datatransfer.StringSelection;
|
||||||
import java.awt.datatransfer.Transferable;
|
import java.awt.datatransfer.Transferable;
|
||||||
@@ -64,6 +67,41 @@ class DataComponentsPanel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void rowSelectionChanged() {
|
||||||
|
table1.setRowSelectionAllowed( rowSelectionCheckBox.isSelected() );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void columnSelectionChanged() {
|
||||||
|
table1.setColumnSelectionAllowed( columnSelectionCheckBox.isSelected() );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showHorizontalLinesChanged() {
|
||||||
|
table1.setShowHorizontalLines( showHorizontalLinesCheckBox.isSelected() );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showVerticalLinesChanged() {
|
||||||
|
table1.setShowVerticalLines( showVerticalLinesCheckBox.isSelected() );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void intercellSpacingChanged() {
|
||||||
|
table1.setIntercellSpacing( intercellSpacingCheckBox.isSelected() ? new Dimension( 1, 1 ) : new Dimension() );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void redGridColorChanged() {
|
||||||
|
table1.setGridColor( redGridColorCheckBox.isSelected() ? Color.red : UIManager.getColor( "Table.gridColor" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateUI() {
|
||||||
|
super.updateUI();
|
||||||
|
|
||||||
|
EventQueue.invokeLater( () -> {
|
||||||
|
showHorizontalLinesChanged();
|
||||||
|
showVerticalLinesChanged();
|
||||||
|
intercellSpacingChanged();
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings( { "unchecked", "rawtypes" } )
|
@SuppressWarnings( { "unchecked", "rawtypes" } )
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
||||||
@@ -80,6 +118,13 @@ class DataComponentsPanel
|
|||||||
JLabel tableLabel = new JLabel();
|
JLabel tableLabel = new JLabel();
|
||||||
JScrollPane scrollPane5 = new JScrollPane();
|
JScrollPane scrollPane5 = new JScrollPane();
|
||||||
table1 = new JTable();
|
table1 = new JTable();
|
||||||
|
JPanel tableOptionsPanel = new JPanel();
|
||||||
|
showHorizontalLinesCheckBox = new JCheckBox();
|
||||||
|
showVerticalLinesCheckBox = new JCheckBox();
|
||||||
|
intercellSpacingCheckBox = new JCheckBox();
|
||||||
|
redGridColorCheckBox = new JCheckBox();
|
||||||
|
rowSelectionCheckBox = new JCheckBox();
|
||||||
|
columnSelectionCheckBox = new JCheckBox();
|
||||||
dndCheckBox = new JCheckBox();
|
dndCheckBox = new JCheckBox();
|
||||||
JPopupMenu popupMenu2 = new JPopupMenu();
|
JPopupMenu popupMenu2 = new JPopupMenu();
|
||||||
JMenuItem menuItem3 = new JMenuItem();
|
JMenuItem menuItem3 = new JMenuItem();
|
||||||
@@ -93,12 +138,12 @@ class DataComponentsPanel
|
|||||||
// columns
|
// columns
|
||||||
"[]" +
|
"[]" +
|
||||||
"[200,fill]" +
|
"[200,fill]" +
|
||||||
"[200,fill]",
|
"[200,fill]" +
|
||||||
|
"[fill]",
|
||||||
// rows
|
// rows
|
||||||
"[150,grow,sizegroup 1,fill]" +
|
"[150,grow,sizegroup 1,fill]" +
|
||||||
"[150,grow,sizegroup 1,fill]" +
|
"[150,grow,sizegroup 1,fill]" +
|
||||||
"[150,grow,sizegroup 1,fill]" +
|
"[150,grow,sizegroup 1,fill]"));
|
||||||
"[]"));
|
|
||||||
|
|
||||||
//---- listLabel ----
|
//---- listLabel ----
|
||||||
listLabel.setText("JList:");
|
listLabel.setText("JList:");
|
||||||
@@ -299,11 +344,59 @@ class DataComponentsPanel
|
|||||||
}
|
}
|
||||||
add(scrollPane5, "cell 1 2 2 1,width 300");
|
add(scrollPane5, "cell 1 2 2 1,width 300");
|
||||||
|
|
||||||
|
//======== tableOptionsPanel ========
|
||||||
|
{
|
||||||
|
tableOptionsPanel.setLayout(new MigLayout(
|
||||||
|
"insets 0,hidemode 3",
|
||||||
|
// columns
|
||||||
|
"[]",
|
||||||
|
// rows
|
||||||
|
"[]0" +
|
||||||
|
"[]0" +
|
||||||
|
"[]0" +
|
||||||
|
"[]0" +
|
||||||
|
"[]0" +
|
||||||
|
"[]0" +
|
||||||
|
"[]0"));
|
||||||
|
|
||||||
|
//---- showHorizontalLinesCheckBox ----
|
||||||
|
showHorizontalLinesCheckBox.setText("show horizontal lines");
|
||||||
|
showHorizontalLinesCheckBox.addActionListener(e -> showHorizontalLinesChanged());
|
||||||
|
tableOptionsPanel.add(showHorizontalLinesCheckBox, "cell 0 0");
|
||||||
|
|
||||||
|
//---- showVerticalLinesCheckBox ----
|
||||||
|
showVerticalLinesCheckBox.setText("show vertical lines");
|
||||||
|
showVerticalLinesCheckBox.addActionListener(e -> showVerticalLinesChanged());
|
||||||
|
tableOptionsPanel.add(showVerticalLinesCheckBox, "cell 0 1");
|
||||||
|
|
||||||
|
//---- intercellSpacingCheckBox ----
|
||||||
|
intercellSpacingCheckBox.setText("intercell spacing");
|
||||||
|
intercellSpacingCheckBox.addActionListener(e -> intercellSpacingChanged());
|
||||||
|
tableOptionsPanel.add(intercellSpacingCheckBox, "cell 0 2");
|
||||||
|
|
||||||
|
//---- redGridColorCheckBox ----
|
||||||
|
redGridColorCheckBox.setText("red grid color");
|
||||||
|
redGridColorCheckBox.addActionListener(e -> redGridColorChanged());
|
||||||
|
tableOptionsPanel.add(redGridColorCheckBox, "cell 0 3");
|
||||||
|
|
||||||
|
//---- rowSelectionCheckBox ----
|
||||||
|
rowSelectionCheckBox.setText("row selection");
|
||||||
|
rowSelectionCheckBox.setSelected(true);
|
||||||
|
rowSelectionCheckBox.addActionListener(e -> rowSelectionChanged());
|
||||||
|
tableOptionsPanel.add(rowSelectionCheckBox, "cell 0 4");
|
||||||
|
|
||||||
|
//---- columnSelectionCheckBox ----
|
||||||
|
columnSelectionCheckBox.setText("column selection");
|
||||||
|
columnSelectionCheckBox.addActionListener(e -> columnSelectionChanged());
|
||||||
|
tableOptionsPanel.add(columnSelectionCheckBox, "cell 0 5");
|
||||||
|
|
||||||
//---- dndCheckBox ----
|
//---- dndCheckBox ----
|
||||||
dndCheckBox.setText("enable drag and drop");
|
dndCheckBox.setText("enable drag and drop");
|
||||||
dndCheckBox.setMnemonic('D');
|
dndCheckBox.setMnemonic('D');
|
||||||
dndCheckBox.addActionListener(e -> dndChanged());
|
dndCheckBox.addActionListener(e -> dndChanged());
|
||||||
add(dndCheckBox, "cell 0 3 3 1");
|
tableOptionsPanel.add(dndCheckBox, "cell 0 6");
|
||||||
|
}
|
||||||
|
add(tableOptionsPanel, "cell 3 2");
|
||||||
|
|
||||||
//======== popupMenu2 ========
|
//======== popupMenu2 ========
|
||||||
{
|
{
|
||||||
@@ -336,6 +429,12 @@ class DataComponentsPanel
|
|||||||
private JTree tree1;
|
private JTree tree1;
|
||||||
private JTree tree2;
|
private JTree tree2;
|
||||||
private JTable table1;
|
private JTable table1;
|
||||||
|
private JCheckBox showHorizontalLinesCheckBox;
|
||||||
|
private JCheckBox showVerticalLinesCheckBox;
|
||||||
|
private JCheckBox intercellSpacingCheckBox;
|
||||||
|
private JCheckBox redGridColorCheckBox;
|
||||||
|
private JCheckBox rowSelectionCheckBox;
|
||||||
|
private JCheckBox columnSelectionCheckBox;
|
||||||
private JCheckBox dndCheckBox;
|
private JCheckBox dndCheckBox;
|
||||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ new FormModel {
|
|||||||
}
|
}
|
||||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||||
"$layoutConstraints": "insets dialog,hidemode 3"
|
"$layoutConstraints": "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][]"
|
"$rowConstraints": "[150,grow,sizegroup 1,fill][150,grow,sizegroup 1,fill][150,grow,sizegroup 1,fill]"
|
||||||
} ) {
|
} ) {
|
||||||
name: "this"
|
name: "this"
|
||||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||||
@@ -309,6 +309,73 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 2 2 1,width 300"
|
"value": "cell 1 2 2 1,width 300"
|
||||||
} )
|
} )
|
||||||
|
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||||
|
"$layoutConstraints": "insets 0,hidemode 3"
|
||||||
|
"$columnConstraints": "[]"
|
||||||
|
"$rowConstraints": "[]0[]0[]0[]0[]0[]0[]0"
|
||||||
|
} ) {
|
||||||
|
name: "tableOptionsPanel"
|
||||||
|
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||||
|
name: "showHorizontalLinesCheckBox"
|
||||||
|
"text": "show horizontal lines"
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showHorizontalLinesChanged", false ) )
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 0 0"
|
||||||
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||||
|
name: "showVerticalLinesCheckBox"
|
||||||
|
"text": "show vertical lines"
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showVerticalLinesChanged", false ) )
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 0 1"
|
||||||
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||||
|
name: "intercellSpacingCheckBox"
|
||||||
|
"text": "intercell spacing"
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "intercellSpacingChanged", false ) )
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 0 2"
|
||||||
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||||
|
name: "redGridColorCheckBox"
|
||||||
|
"text": "red grid color"
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "redGridColorChanged", false ) )
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 0 3"
|
||||||
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||||
|
name: "rowSelectionCheckBox"
|
||||||
|
"text": "row selection"
|
||||||
|
"selected": true
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "rowSelectionChanged", false ) )
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 0 4"
|
||||||
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||||
|
name: "columnSelectionCheckBox"
|
||||||
|
"text": "column selection"
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "columnSelectionChanged", false ) )
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 0 5"
|
||||||
|
} )
|
||||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||||
name: "dndCheckBox"
|
name: "dndCheckBox"
|
||||||
"text": "enable drag and drop"
|
"text": "enable drag and drop"
|
||||||
@@ -318,11 +385,14 @@ new FormModel {
|
|||||||
}
|
}
|
||||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "dndChanged", false ) )
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "dndChanged", false ) )
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 3 3 1"
|
"value": "cell 0 6"
|
||||||
|
} )
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 3 2"
|
||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( null ) {
|
}, new FormLayoutConstraints( null ) {
|
||||||
"location": new java.awt.Point( 0, 0 )
|
"location": new java.awt.Point( 0, 0 )
|
||||||
"size": new java.awt.Dimension( 790, 715 )
|
"size": new java.awt.Dimension( 790, 745 )
|
||||||
} )
|
} )
|
||||||
add( new FormContainer( "javax.swing.JPopupMenu", new FormLayoutManager( class javax.swing.JPopupMenu ) ) {
|
add( new FormContainer( "javax.swing.JPopupMenu", new FormLayoutManager( class javax.swing.JPopupMenu ) ) {
|
||||||
name: "popupMenu2"
|
name: "popupMenu2"
|
||||||
@@ -346,7 +416,7 @@ new FormModel {
|
|||||||
"text": "Noop Action"
|
"text": "Noop Action"
|
||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( null ) {
|
}, new FormLayoutConstraints( null ) {
|
||||||
"location": new java.awt.Point( 0, 740 )
|
"location": new java.awt.Point( 0, 800 )
|
||||||
} )
|
} )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user