JIDE: support TristateCheckBox

This commit is contained in:
Karl Tauber
2020-12-19 13:34:53 +01:00
parent d059d6b448
commit ef065d31a0
5 changed files with 77 additions and 3 deletions

View File

@@ -15,6 +15,7 @@ FlatLaf Change Log
to `com.formdev.flatlaf.extras.FlatSVGUtils`. to `com.formdev.flatlaf.extras.FlatSVGUtils`.
- IntelliJ Themes: Added flag whether a theme is dark to - IntelliJ Themes: Added flag whether a theme is dark to
`FlatAllIJThemes.INFOS`. (issue #221) `FlatAllIJThemes.INFOS`. (issue #221)
- JIDE Common Layer: Support `TristateCheckBox`.
#### Fixed bugs #### Fixed bugs

View File

@@ -8,6 +8,7 @@ Following JIDE Common Layer components are currently supported by this addon:
- `JideTabbedPane` - `JideTabbedPane`
- `RangeSlider` - `RangeSlider`
- `TristateCheckBox`
**Note**: We have currently no plans to support additional components. If you're **Note**: We have currently no plans to support additional components. If you're

View File

@@ -19,6 +19,7 @@ package com.formdev.flatlaf.jideoss;
import java.io.InputStream; import java.io.InputStream;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.swing.LookAndFeel;
import javax.swing.UIDefaults; import javax.swing.UIDefaults;
import com.formdev.flatlaf.FlatDefaultsAddon; import com.formdev.flatlaf.FlatDefaultsAddon;
import com.formdev.flatlaf.FlatLaf; import com.formdev.flatlaf.FlatLaf;
@@ -46,6 +47,14 @@ public class FlatJideOssDefaultsAddon
return super.getDefaults( lafClass ); return super.getDefaults( lafClass );
} }
@Override
public void afterDefaultsLoading( LookAndFeel laf, UIDefaults defaults ) {
// TristateCheckBox
defaults.put( "TristateCheckBox.icon", null );
defaults.put( "TristateCheckBox.setMixed.clientProperty", new Object[] { "JButton.selectedState", "indeterminate" } );
defaults.put( "TristateCheckBox.clearMixed.clientProperty", new Object[] { "JButton.selectedState", null } );
}
@Override @Override
public int getPriority() { public int getPriority() {
return 11; return 11;
@@ -71,6 +80,7 @@ public class FlatJideOssDefaultsAddon
Object key = e.getKey(); Object key = e.getKey();
if( key instanceof String && if( key instanceof String &&
(((String)key).startsWith( "Jide" ) || (((String)key).startsWith( "Jide" ) ||
((String)key).startsWith( "TristateCheckBox." ) ||
key.equals( "RangeSliderUI" ) || key.equals( "RangeSliderUI" ) ||
key.equals( "Resizable.resizeBorder" )) ) key.equals( "Resizable.resizeBorder" )) )
{ {
@@ -85,6 +95,9 @@ public class FlatJideOssDefaultsAddon
defaults.putAll( jideDefaults ); defaults.putAll( jideDefaults );
jideDefaults = null; jideDefaults = null;
} }
// TristateCheckBox
defaults.put( "TristateCheckBox.icon", null );
} }
} }
} }

View File

@@ -51,6 +51,8 @@ public class FlatJideOssTest
FlatJideOssTest() { FlatJideOssTest() {
initComponents(); initComponents();
tristateCheckBox1Changed();
} }
private void tabScrollChanged() { private void tabScrollChanged() {
@@ -104,6 +106,16 @@ public class FlatJideOssTest
popupMenu.showPopup(); popupMenu.showPopup();
} }
private void tristateCheckBox1Changed() {
String text = null;
switch( tristateCheckBox1.getState() ) {
case TristateCheckBox.STATE_UNSELECTED: text = "UNSELECTED"; break;
case TristateCheckBox.STATE_SELECTED: text = "SELECTED"; break;
case TristateCheckBox.STATE_MIXED: text = "MIXED"; break;
}
triStateLabel1.setText( text );
}
private void initComponents() { private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JPanel panel9 = new JPanel(); JPanel panel9 = new JPanel();
@@ -135,6 +147,9 @@ public class FlatJideOssTest
JPanel panel10 = new JPanel(); JPanel panel10 = new JPanel();
JLabel jidePopupLabel = new JLabel(); JLabel jidePopupLabel = new JLabel();
JButton showJidePopupButton = new JButton(); JButton showJidePopupButton = new JButton();
JLabel label9 = new JLabel();
tristateCheckBox1 = new TristateCheckBox();
triStateLabel1 = new JLabel();
CellConstraints cc = new CellConstraints(); CellConstraints cc = new CellConstraints();
//======== this ======== //======== this ========
@@ -303,8 +318,10 @@ public class FlatJideOssTest
"insets 3 0 3 3,hidemode 3", "insets 3 0 3 3,hidemode 3",
// columns // columns
"[fill]" + "[fill]" +
"[fill]" +
"[fill]", "[fill]",
// rows // rows
"[]" +
"[]")); "[]"));
//---- jidePopupLabel ---- //---- jidePopupLabel ----
@@ -315,6 +332,20 @@ public class FlatJideOssTest
showJidePopupButton.setText("show JidePopup"); showJidePopupButton.setText("show JidePopup");
showJidePopupButton.addActionListener(e -> showJidePopupButtonActionPerformed(e)); showJidePopupButton.addActionListener(e -> showJidePopupButtonActionPerformed(e));
panel10.add(showJidePopupButton, "cell 1 0"); panel10.add(showJidePopupButton, "cell 1 0");
//---- label9 ----
label9.setText("TristateCheckBox:");
panel10.add(label9, "cell 0 1");
//---- tristateCheckBox1 ----
tristateCheckBox1.setText("three states");
tristateCheckBox1.addActionListener(e -> tristateCheckBox1Changed());
panel10.add(tristateCheckBox1, "cell 1 1");
//---- triStateLabel1 ----
triStateLabel1.setText("text");
triStateLabel1.setEnabled(false);
panel10.add(triStateLabel1, "cell 2 1");
} }
panel9.add(panel10, cc.xy(1, 9)); panel9.add(panel10, cc.xy(1, 9));
} }
@@ -330,5 +361,7 @@ public class FlatJideOssTest
private JCheckBox moreTabsCheckBox; private JCheckBox moreTabsCheckBox;
private JCheckBox tabScrollCheckBox; private JCheckBox tabScrollCheckBox;
private JCheckBox hasFullBorderCheckBox; private JCheckBox hasFullBorderCheckBox;
private TristateCheckBox tristateCheckBox1;
private JLabel triStateLabel1;
// JFormDesigner - End of variables declaration //GEN-END:variables // JFormDesigner - End of variables declaration //GEN-END:variables
} }

View File

@@ -1,4 +1,4 @@
JFDML JFormDesigner: "7.0.0.0.194" Java: "11.0.2" encoding: "UTF-8" JFDML JFormDesigner: "7.0.3.1.342" Java: "15" encoding: "UTF-8"
new FormModel { new FormModel {
contentType: "form/swing" contentType: "form/swing"
@@ -194,8 +194,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 3 0 3 3,hidemode 3" "$layoutConstraints": "insets 3 0 3 3,hidemode 3"
"$columnConstraints": "[fill][fill]" "$columnConstraints": "[fill][fill][fill]"
"$rowConstraints": "[]" "$rowConstraints": "[][]"
} ) { } ) {
name: "panel10" name: "panel10"
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
@@ -211,6 +211,32 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0" "value": "cell 1 0"
} ) } )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label9"
"text": "TristateCheckBox:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "com.jidesoft.swing.TristateCheckBox" ) {
name: "tristateCheckBox1"
"text": "three states"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tristateCheckBox1Changed", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "triStateLabel1"
"text": "text"
"enabled": false
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 1"
} )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridY": 9 "gridY": 9
} ) } )