From 1907f8002445a4b6918579809b341fb32a9facb1 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Mon, 18 May 2020 21:07:11 +0200 Subject: [PATCH] Demo: fixed compiler warnings and improved error/warning hints --- .../flatlaf/demo/BasicComponentsPanel.java | 15 +++++++++++---- .../formdev/flatlaf/demo/BasicComponentsPanel.jfd | 13 +++++++++++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.java b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.java index d01e72cc..5f837ee2 100644 --- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.java +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.java @@ -116,11 +116,11 @@ class BasicComponentsPanel JTextPane textPane5 = new JTextPane(); JLabel label3 = new JLabel(); JTextField textField5 = new JTextField(); - JComboBox comboBox7 = new JComboBox(); + JComboBox comboBox7 = new JComboBox<>(); JSpinner spinner3 = new JSpinner(); JLabel label4 = new JLabel(); JTextField textField7 = new JTextField(); - JComboBox comboBox8 = new JComboBox(); + JComboBox comboBox8 = new JComboBox<>(); JSpinner spinner4 = new JSpinner(); JPopupMenu popupMenu1 = new JPopupMenu(); JMenuItem cutMenuItem = new JMenuItem(); @@ -607,7 +607,7 @@ class BasicComponentsPanel add(textPane5, "cell 5 11,growx"); //---- label3 ---- - label3.setText("Error:"); + label3.setText("Error hints:"); add(label3, "cell 0 12"); //---- textField5 ---- @@ -616,6 +616,10 @@ class BasicComponentsPanel //---- comboBox7 ---- comboBox7.putClientProperty("JComponent.outline", "error"); + comboBox7.setModel(new DefaultComboBoxModel<>(new String[] { + "editable" + })); + comboBox7.setEditable(true); add(comboBox7, "cell 2 12,growx"); //---- spinner3 ---- @@ -623,7 +627,7 @@ class BasicComponentsPanel add(spinner3, "cell 3 12,growx"); //---- label4 ---- - label4.setText("Warning:"); + label4.setText("Warning hints:"); add(label4, "cell 0 13"); //---- textField7 ---- @@ -632,6 +636,9 @@ class BasicComponentsPanel //---- comboBox8 ---- comboBox8.putClientProperty("JComponent.outline", "warning"); + comboBox8.setModel(new DefaultComboBoxModel<>(new String[] { + "not editable" + })); add(comboBox8, "cell 2 13,growx"); //---- spinner4 ---- diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.jfd b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.jfd index 486497c2..00239b64 100644 --- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.jfd +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.jfd @@ -593,7 +593,7 @@ new FormModel { } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label3" - "text": "Error:" + "text": "Error hints:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 12" } ) @@ -606,6 +606,11 @@ new FormModel { add( new FormComponent( "javax.swing.JComboBox" ) { name: "comboBox7" "$client.JComponent.outline": "error" + "model": new javax.swing.DefaultComboBoxModel { + selectedItem: "editable" + addElement( "editable" ) + } + "editable": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 2 12,growx" } ) @@ -617,7 +622,7 @@ new FormModel { } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label4" - "text": "Warning:" + "text": "Warning hints:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 13" } ) @@ -630,6 +635,10 @@ new FormModel { add( new FormComponent( "javax.swing.JComboBox" ) { name: "comboBox8" "$client.JComponent.outline": "warning" + "model": new javax.swing.DefaultComboBoxModel { + selectedItem: "not editable" + addElement( "not editable" ) + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 2 13,growx" } )