support different component border colors to indicate errors, warnings or custom state (set client property JComponent.outline to error, warning or any java.awt.Color)

This commit is contained in:
Karl Tauber
2020-05-17 13:43:19 +02:00
parent ff545e6ecd
commit 800dbf3ba9
15 changed files with 339 additions and 7 deletions

View File

@@ -114,6 +114,14 @@ class BasicComponentsPanel
JScrollPane scrollPane12 = new JScrollPane();
JTextPane textPane4 = new JTextPane();
JTextPane textPane5 = new JTextPane();
JLabel label3 = new JLabel();
JTextField textField5 = new JTextField();
JComboBox comboBox7 = new JComboBox();
JSpinner spinner3 = new JSpinner();
JLabel label4 = new JLabel();
JTextField textField7 = new JTextField();
JComboBox comboBox8 = new JComboBox();
JSpinner spinner4 = new JSpinner();
JPopupMenu popupMenu1 = new JPopupMenu();
JMenuItem cutMenuItem = new JMenuItem();
JMenuItem copyMenuItem = new JMenuItem();
@@ -141,6 +149,8 @@ class BasicComponentsPanel
"[]" +
"[]" +
"[]" +
"[]para" +
"[]" +
"[]"));
//---- labelLabel ----
@@ -596,6 +606,38 @@ class BasicComponentsPanel
textPane5.setText("no scroll pane");
add(textPane5, "cell 5 11,growx");
//---- label3 ----
label3.setText("Error:");
add(label3, "cell 0 12");
//---- textField5 ----
textField5.putClientProperty("JComponent.outline", "error");
add(textField5, "cell 1 12,growx");
//---- comboBox7 ----
comboBox7.putClientProperty("JComponent.outline", "error");
add(comboBox7, "cell 2 12,growx");
//---- spinner3 ----
spinner3.putClientProperty("JComponent.outline", "error");
add(spinner3, "cell 3 12,growx");
//---- label4 ----
label4.setText("Warning:");
add(label4, "cell 0 13");
//---- textField7 ----
textField7.putClientProperty("JComponent.outline", "warning");
add(textField7, "cell 1 13,growx");
//---- comboBox8 ----
comboBox8.putClientProperty("JComponent.outline", "warning");
add(comboBox8, "cell 2 13,growx");
//---- spinner4 ----
spinner4.putClientProperty("JComponent.outline", "warning");
add(spinner4, "cell 3 13,growx");
//======== popupMenu1 ========
{

View File

@@ -9,7 +9,7 @@ new FormModel {
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "hidemode 3"
"$columnConstraints": "[][][][][][]"
"$rowConstraints": "[][][][][][][][][][][][]"
"$rowConstraints": "[][][][][][][][][][][][]para[][]"
} ) {
name: "this"
add( new FormComponent( "javax.swing.JLabel" ) {
@@ -591,9 +591,57 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 11,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label3"
"text": "Error:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 12"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField5"
"$client.JComponent.outline": "error"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 12,growx"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "comboBox7"
"$client.JComponent.outline": "error"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 12,growx"
} )
add( new FormComponent( "javax.swing.JSpinner" ) {
name: "spinner3"
"$client.JComponent.outline": "error"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 12,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label4"
"text": "Warning:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 13"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField7"
"$client.JComponent.outline": "warning"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 13,growx"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "comboBox8"
"$client.JComponent.outline": "warning"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 13,growx"
} )
add( new FormComponent( "javax.swing.JSpinner" ) {
name: "spinner4"
"$client.JComponent.outline": "warning"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 13,growx"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 790, 440 )
"size": new java.awt.Dimension( 920, 440 )
} )
add( new FormContainer( "javax.swing.JPopupMenu", new FormLayoutManager( class javax.swing.JPopupMenu ) ) {
name: "popupMenu1"