Extras: Renamed tri-state check box class from

`com.formdev.flatlaf.extras.TriStateCheckBox` to
`com.formdev.flatlaf.extras.components.FlatTriStateCheckBox`
This commit is contained in:
Karl Tauber
2020-12-12 00:33:51 +01:00
parent 534384438b
commit 234003e2b1
13 changed files with 41 additions and 30 deletions

View File

@@ -3,6 +3,13 @@ FlatLaf Change Log
## 0.46-SNAPSHOT ## 0.46-SNAPSHOT
#### New features and improvements
- Extras: Renamed tri-state check box class from
`com.formdev.flatlaf.extras.TriStateCheckBox` to
`com.formdev.flatlaf.extras.components.FlatTriStateCheckBox`.
#### Fixed bugs #### Fixed bugs
- Table and TableHeader: Fixed missing right vertical grid line if using table - Table and TableHeader: Fixed missing right vertical grid line if using table

View File

@@ -18,6 +18,7 @@ package com.formdev.flatlaf.demo.extras;
import javax.swing.*; import javax.swing.*;
import com.formdev.flatlaf.extras.*; import com.formdev.flatlaf.extras.*;
import com.formdev.flatlaf.extras.components.FlatTriStateCheckBox;
import net.miginfocom.swing.*; import net.miginfocom.swing.*;
/** /**
@@ -63,7 +64,7 @@ public class ExtrasPanel
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
label4 = new JLabel(); label4 = new JLabel();
label1 = new JLabel(); label1 = new JLabel();
triStateCheckBox1 = new TriStateCheckBox(); triStateCheckBox1 = new FlatTriStateCheckBox();
triStateLabel1 = new JLabel(); triStateLabel1 = new JLabel();
label2 = new JLabel(); label2 = new JLabel();
svgIconsPanel = new JPanel(); svgIconsPanel = new JPanel();
@@ -124,7 +125,7 @@ public class ExtrasPanel
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JLabel label4; private JLabel label4;
private JLabel label1; private JLabel label1;
private TriStateCheckBox triStateCheckBox1; private FlatTriStateCheckBox triStateCheckBox1;
private JLabel triStateLabel1; private JLabel triStateLabel1;
private JLabel label2; private JLabel label2;
private JPanel svgIconsPanel; private JPanel svgIconsPanel;

View File

@@ -21,7 +21,7 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1" "value": "cell 0 1"
} ) } )
add( new FormComponent( "com.formdev.flatlaf.extras.TriStateCheckBox" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "triStateCheckBox1" name: "triStateCheckBox1"
"text": "Three States" "text": "Three States"
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "triStateCheckBox1Changed", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "triStateCheckBox1Changed", false ) )

View File

@@ -7,7 +7,7 @@ This sub-project provides some additional components and classes:
An icon that displays SVG using An icon that displays SVG using
[svgSalamander](https://github.com/JFormDesigner/svgSalamander).\ [svgSalamander](https://github.com/JFormDesigner/svgSalamander).\
![FlatSVGIcon.png](../images/extras-FlatSVGIcon.png) ![FlatSVGIcon.png](../images/extras-FlatSVGIcon.png)
- [TriStateCheckBox](https://www.javadoc.io/doc/com.formdev/flatlaf-extras/latest/com/formdev/flatlaf/extras/TriStateCheckBox.html): - [FlatTriStateCheckBox](https://www.javadoc.io/doc/com.formdev/flatlaf-extras/latest/com/formdev/flatlaf/extras/components/FlatTriStateCheckBox.html):
A tri-state check box.\ A tri-state check box.\
![TriStateCheckBox.png](../images/extras-TriStateCheckBox.png) ![TriStateCheckBox.png](../images/extras-TriStateCheckBox.png)
- [FlatAnimatedLafChange](https://www.javadoc.io/doc/com.formdev/flatlaf-extras/latest/com/formdev/flatlaf/extras/FlatAnimatedLafChange.html): - [FlatAnimatedLafChange](https://www.javadoc.io/doc/com.formdev/flatlaf-extras/latest/com/formdev/flatlaf/extras/FlatAnimatedLafChange.html):

View File

@@ -14,8 +14,9 @@
* limitations under the License. * limitations under the License.
*/ */
package com.formdev.flatlaf.extras; package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color; import java.awt.Color;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
@@ -36,7 +37,7 @@ import com.formdev.flatlaf.FlatLaf;
* *
* @author Karl Tauber * @author Karl Tauber
*/ */
public class TriStateCheckBox public class FlatTriStateCheckBox
extends JCheckBox extends JCheckBox
{ {
public enum State { INDETERMINATE, SELECTED, UNSELECTED } public enum State { INDETERMINATE, SELECTED, UNSELECTED }
@@ -44,15 +45,15 @@ public class TriStateCheckBox
private State state; private State state;
private boolean thirdStateEnabled = true; private boolean thirdStateEnabled = true;
public TriStateCheckBox() { public FlatTriStateCheckBox() {
this( null ); this( null );
} }
public TriStateCheckBox( String text ) { public FlatTriStateCheckBox( String text ) {
this( text, State.INDETERMINATE ); this( text, State.INDETERMINATE );
} }
public TriStateCheckBox( String text, State initialState ) { public FlatTriStateCheckBox( String text, State initialState ) {
super( text ); super( text );
setModel( new ToggleButtonModel() { setModel( new ToggleButtonModel() {
@@ -89,7 +90,7 @@ public class TriStateCheckBox
State oldState = this.state; State oldState = this.state;
this.state = state; this.state = state;
putClientProperty( "JButton.selectedState", state == State.INDETERMINATE ? "indeterminate" : null ); putClientProperty( SELECTED_STATE, state == State.INDETERMINATE ? SELECTED_STATE_INDETERMINATE : null );
firePropertyChange( "state", oldState, state ); firePropertyChange( "state", oldState, state );
repaint(); repaint();

View File

@@ -22,9 +22,9 @@ import java.awt.event.MouseEvent;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.*; import javax.swing.border.*;
import com.formdev.flatlaf.FlatLaf; import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.extras.TriStateCheckBox;
import com.formdev.flatlaf.extras.components.FlatTabbedPane; import com.formdev.flatlaf.extras.components.FlatTabbedPane;
import com.formdev.flatlaf.extras.components.FlatTabbedPane.*; import com.formdev.flatlaf.extras.components.FlatTabbedPane.*;
import com.formdev.flatlaf.extras.components.FlatTriStateCheckBox;
import com.formdev.flatlaf.icons.FlatInternalFrameCloseIcon; import com.formdev.flatlaf.icons.FlatInternalFrameCloseIcon;
import com.formdev.flatlaf.util.ScaledImageIcon; import com.formdev.flatlaf.util.ScaledImageIcon;
import com.jgoodies.forms.layout.*; import com.jgoodies.forms.layout.*;
@@ -450,7 +450,7 @@ public class FlatContainerTest
tabsClosableCheckBox = new JCheckBox(); tabsClosableCheckBox = new JCheckBox();
JLabel tabPlacementLabel = new JLabel(); JLabel tabPlacementLabel = new JLabel();
tabPlacementField = new FlatTestEnumComboBox<>(); tabPlacementField = new FlatTestEnumComboBox<>();
secondTabClosableCheckBox = new TriStateCheckBox(); secondTabClosableCheckBox = new FlatTriStateCheckBox();
JLabel tabAreaAlignmentLabel = new JLabel(); JLabel tabAreaAlignmentLabel = new JLabel();
tabAreaAlignmentField = new FlatTestEnumComboBox<>(); tabAreaAlignmentField = new FlatTestEnumComboBox<>();
tabAlignmentField = new FlatTestEnumComboBox<>(); tabAlignmentField = new FlatTestEnumComboBox<>();
@@ -795,7 +795,7 @@ public class FlatContainerTest
private FlatTestEnumComboBox<ScrollButtonsPlacement> scrollButtonsPlacementField; private FlatTestEnumComboBox<ScrollButtonsPlacement> scrollButtonsPlacementField;
private JCheckBox tabsClosableCheckBox; private JCheckBox tabsClosableCheckBox;
private FlatTestEnumComboBox<TabPlacement> tabPlacementField; private FlatTestEnumComboBox<TabPlacement> tabPlacementField;
private TriStateCheckBox secondTabClosableCheckBox; private FlatTriStateCheckBox secondTabClosableCheckBox;
private FlatTestEnumComboBox<TabAreaAlignment> tabAreaAlignmentField; private FlatTestEnumComboBox<TabAreaAlignment> tabAreaAlignmentField;
private FlatTestEnumComboBox<TabAlignment> tabAlignmentField; private FlatTestEnumComboBox<TabAlignment> tabAlignmentField;
private FlatTestEnumComboBox<TabWidthMode> tabWidthModeField; private FlatTestEnumComboBox<TabWidthMode> tabWidthModeField;

View File

@@ -320,7 +320,7 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4" "value": "cell 1 4"
} ) } )
add( new FormComponent( "com.formdev.flatlaf.extras.TriStateCheckBox" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "secondTabClosableCheckBox" name: "secondTabClosableCheckBox"
"text": "Second Tab closable" "text": "Second Tab closable"
auxiliary() { auxiliary() {

View File

@@ -19,7 +19,7 @@ package com.formdev.flatlaf.testing;
import java.awt.*; import java.awt.*;
import java.beans.PropertyVetoException; import java.beans.PropertyVetoException;
import javax.swing.*; import javax.swing.*;
import com.formdev.flatlaf.extras.TriStateCheckBox; import com.formdev.flatlaf.extras.components.FlatTriStateCheckBox;
import com.formdev.flatlaf.icons.FlatFileViewFloppyDriveIcon; import com.formdev.flatlaf.icons.FlatFileViewFloppyDriveIcon;
import com.formdev.flatlaf.util.UIScale; import com.formdev.flatlaf.util.UIScale;
import net.miginfocom.swing.*; import net.miginfocom.swing.*;
@@ -63,9 +63,9 @@ public class FlatInternalFrameTest
maximizableCheckBox.isSelected(), maximizableCheckBox.isSelected(),
iconifiableCheckBox.isSelected() ); iconifiableCheckBox.isSelected() );
if( iconCheckBox.getState() == TriStateCheckBox.State.SELECTED ) if( iconCheckBox.getState() == FlatTriStateCheckBox.State.SELECTED )
internalFrame.setFrameIcon( new FlatFileViewFloppyDriveIcon() ); internalFrame.setFrameIcon( new FlatFileViewFloppyDriveIcon() );
else if( iconCheckBox.getState() == TriStateCheckBox.State.UNSELECTED ) else if( iconCheckBox.getState() == FlatTriStateCheckBox.State.UNSELECTED )
internalFrame.setFrameIcon( null ); internalFrame.setFrameIcon( null );
if( menuBarCheckBox.isSelected() ) { if( menuBarCheckBox.isSelected() ) {
@@ -115,7 +115,7 @@ public class FlatInternalFrameTest
closableCheckBox = new JCheckBox(); closableCheckBox = new JCheckBox();
iconifiableCheckBox = new JCheckBox(); iconifiableCheckBox = new JCheckBox();
maximizableCheckBox = new JCheckBox(); maximizableCheckBox = new JCheckBox();
iconCheckBox = new TriStateCheckBox(); iconCheckBox = new FlatTriStateCheckBox();
menuBarCheckBox = new JCheckBox(); menuBarCheckBox = new JCheckBox();
titleLabel = new JLabel(); titleLabel = new JLabel();
titleField = new JTextField(); titleField = new JTextField();
@@ -207,7 +207,7 @@ public class FlatInternalFrameTest
private JCheckBox closableCheckBox; private JCheckBox closableCheckBox;
private JCheckBox iconifiableCheckBox; private JCheckBox iconifiableCheckBox;
private JCheckBox maximizableCheckBox; private JCheckBox maximizableCheckBox;
private TriStateCheckBox iconCheckBox; private FlatTriStateCheckBox iconCheckBox;
private JCheckBox menuBarCheckBox; private JCheckBox menuBarCheckBox;
private JLabel titleLabel; private JLabel titleLabel;
private JTextField titleField; private JTextField titleField;

View File

@@ -50,7 +50,7 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1,alignx left,growx 0" "value": "cell 1 1,alignx left,growx 0"
} ) } )
add( new FormComponent( "com.formdev.flatlaf.extras.TriStateCheckBox" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "iconCheckBox" name: "iconCheckBox"
"text": "Frame icon" "text": "Frame icon"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {

View File

@@ -43,7 +43,8 @@ import com.formdev.flatlaf.demo.LookAndFeelsComboBox;
import com.formdev.flatlaf.demo.DemoPrefs; import com.formdev.flatlaf.demo.DemoPrefs;
import com.formdev.flatlaf.demo.intellijthemes.*; import com.formdev.flatlaf.demo.intellijthemes.*;
import com.formdev.flatlaf.extras.*; import com.formdev.flatlaf.extras.*;
import com.formdev.flatlaf.extras.TriStateCheckBox.State; import com.formdev.flatlaf.extras.components.FlatTriStateCheckBox;
import com.formdev.flatlaf.extras.components.FlatTriStateCheckBox.State;
import com.formdev.flatlaf.ui.FlatUIUtils; import com.formdev.flatlaf.ui.FlatUIUtils;
import com.formdev.flatlaf.util.SystemInfo; import com.formdev.flatlaf.util.SystemInfo;
import com.formdev.flatlaf.util.UIScale; import com.formdev.flatlaf.util.UIScale;
@@ -660,7 +661,7 @@ public class FlatTestFrame
inspectCheckBox = new JCheckBox(); inspectCheckBox = new JCheckBox();
explicitColorsCheckBox = new JCheckBox(); explicitColorsCheckBox = new JCheckBox();
backgroundCheckBox = new JCheckBox(); backgroundCheckBox = new JCheckBox();
opaqueTriStateCheckBox = new TriStateCheckBox(); opaqueTriStateCheckBox = new FlatTriStateCheckBox();
sizeVariantComboBox = new JComboBox<>(); sizeVariantComboBox = new JComboBox<>();
closeButton = new JButton(); closeButton = new JButton();
themesPanel = new IJThemesPanel(); themesPanel = new IJThemesPanel();
@@ -805,7 +806,7 @@ public class FlatTestFrame
private JCheckBox inspectCheckBox; private JCheckBox inspectCheckBox;
private JCheckBox explicitColorsCheckBox; private JCheckBox explicitColorsCheckBox;
private JCheckBox backgroundCheckBox; private JCheckBox backgroundCheckBox;
private TriStateCheckBox opaqueTriStateCheckBox; private FlatTriStateCheckBox opaqueTriStateCheckBox;
private JComboBox<String> sizeVariantComboBox; private JComboBox<String> sizeVariantComboBox;
private JButton closeButton; private JButton closeButton;
private IJThemesPanel themesPanel; private IJThemesPanel themesPanel;

View File

@@ -107,7 +107,7 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 7 0" "value": "cell 7 0"
} ) } )
add( new FormComponent( "com.formdev.flatlaf.extras.TriStateCheckBox" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "opaqueTriStateCheckBox" name: "opaqueTriStateCheckBox"
"text": "opaque" "text": "opaque"
"mnemonic": 79 "mnemonic": 79

View File

@@ -18,6 +18,7 @@ package com.formdev.flatlaf.testing.extras;
import javax.swing.*; import javax.swing.*;
import com.formdev.flatlaf.extras.*; import com.formdev.flatlaf.extras.*;
import com.formdev.flatlaf.extras.components.*;
import com.formdev.flatlaf.testing.*; import com.formdev.flatlaf.testing.*;
import net.miginfocom.swing.*; import net.miginfocom.swing.*;
@@ -117,9 +118,9 @@ public class FlatExtrasTest
private void initComponents() { private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
label1 = new JLabel(); label1 = new JLabel();
triStateCheckBox1 = new TriStateCheckBox(); triStateCheckBox1 = new FlatTriStateCheckBox();
triStateLabel1 = new JLabel(); triStateLabel1 = new JLabel();
triStateCheckBox2 = new TriStateCheckBox(); triStateCheckBox2 = new FlatTriStateCheckBox();
triStateLabel2 = new JLabel(); triStateLabel2 = new JLabel();
label2 = new JLabel(); label2 = new JLabel();
svgIconsPanel = new JPanel(); svgIconsPanel = new JPanel();
@@ -238,9 +239,9 @@ public class FlatExtrasTest
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JLabel label1; private JLabel label1;
private TriStateCheckBox triStateCheckBox1; private FlatTriStateCheckBox triStateCheckBox1;
private JLabel triStateLabel1; private JLabel triStateLabel1;
private TriStateCheckBox triStateCheckBox2; private FlatTriStateCheckBox triStateCheckBox2;
private JLabel triStateLabel2; private JLabel triStateLabel2;
private JLabel label2; private JLabel label2;
private JPanel svgIconsPanel; private JPanel svgIconsPanel;

View File

@@ -15,7 +15,7 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0" "value": "cell 0 0"
} ) } )
add( new FormComponent( "com.formdev.flatlaf.extras.TriStateCheckBox" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "triStateCheckBox1" name: "triStateCheckBox1"
"text": "three states" "text": "three states"
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "triStateCheckBox1Changed", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "triStateCheckBox1Changed", false ) )
@@ -29,7 +29,7 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0,gapx 30" "value": "cell 2 0,gapx 30"
} ) } )
add( new FormComponent( "com.formdev.flatlaf.extras.TriStateCheckBox" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "triStateCheckBox2" name: "triStateCheckBox2"
"text": "third state disabled" "text": "third state disabled"
"thirdStateEnabled": false "thirdStateEnabled": false