FlatComponentStateTest added

This commit is contained in:
Karl Tauber
2021-01-30 18:43:11 +01:00
parent 212ae90401
commit 0ab4206540
2 changed files with 1412 additions and 0 deletions

View File

@@ -0,0 +1,872 @@
/*
* Copyright 2021 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.testing;
import java.awt.Component;
import java.util.function.Predicate;
import javax.swing.*;
import com.formdev.flatlaf.FlatClientProperties;
import net.miginfocom.swing.*;
/**
* @author Karl Tauber
*/
public class FlatComponentStateTest
extends FlatTestPanel
{
public static void main( String[] args ) {
SwingUtilities.invokeLater( () -> {
FlatTestFrame frame = FlatTestFrame.create( args, "FlatComponentStateTest" );
frame.showFrame( FlatComponentStateTest::new );
} );
}
FlatComponentStateTest() {
initComponents();
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
label11 = new JLabel();
label9 = new JLabel();
label12 = new JLabel();
label5 = new JLabel();
label6 = new JLabel();
label7 = new JLabel();
label8 = new JLabel();
label13 = new JLabel();
label14 = new JLabel();
label15 = new JLabel();
label16 = new JLabel();
label1 = new JLabel();
testStateButton1 = new FlatComponentStateTest.TestStateButton();
testStateButton4 = new FlatComponentStateTest.TestStateButton();
testStateButton7 = new FlatComponentStateTest.TestStateButton();
testStateButton10 = new FlatComponentStateTest.TestStateButton();
testStateToggleButton1 = new FlatComponentStateTest.TestStateToggleButton();
testStateToggleButton5 = new FlatComponentStateTest.TestStateToggleButton();
testStateToggleButton9 = new FlatComponentStateTest.TestStateToggleButton();
testStateToggleButton12 = new FlatComponentStateTest.TestStateToggleButton();
label2 = new JLabel();
testStateButton2 = new FlatComponentStateTest.TestStateButton();
testStateButton5 = new FlatComponentStateTest.TestStateButton();
testStateButton8 = new FlatComponentStateTest.TestStateButton();
testStateButton11 = new FlatComponentStateTest.TestStateButton();
testStateToggleButton2 = new FlatComponentStateTest.TestStateToggleButton();
testStateToggleButton6 = new FlatComponentStateTest.TestStateToggleButton();
testStateToggleButton10 = new FlatComponentStateTest.TestStateToggleButton();
testStateToggleButton13 = new FlatComponentStateTest.TestStateToggleButton();
label3 = new JLabel();
testStateButton3 = new FlatComponentStateTest.TestStateButton();
testStateButton6 = new FlatComponentStateTest.TestStateButton();
testStateButton9 = new FlatComponentStateTest.TestStateButton();
testStateButton12 = new FlatComponentStateTest.TestStateButton();
testStateToggleButton3 = new FlatComponentStateTest.TestStateToggleButton();
testStateToggleButton7 = new FlatComponentStateTest.TestStateToggleButton();
testStateToggleButton11 = new FlatComponentStateTest.TestStateToggleButton();
testStateToggleButton14 = new FlatComponentStateTest.TestStateToggleButton();
label4 = new JLabel();
testStateButton13 = new FlatComponentStateTest.TestStateButton();
testStateButton14 = new FlatComponentStateTest.TestStateButton();
testStateToggleButton4 = new FlatComponentStateTest.TestStateToggleButton();
testStateToggleButton8 = new FlatComponentStateTest.TestStateToggleButton();
label10 = new JLabel();
button1 = new JButton();
testDefaultButton1 = new FlatComponentStateTest.TestDefaultButton();
toggleButton1 = new JToggleButton();
toggleButton2 = new JToggleButton();
separator1 = new JSeparator();
label22 = new JLabel();
label27 = new JLabel();
label23 = new JLabel();
label24 = new JLabel();
label25 = new JLabel();
label26 = new JLabel();
label17 = new JLabel();
testStateCheckBox1 = new FlatComponentStateTest.TestStateCheckBox();
testStateCheckBox5 = new FlatComponentStateTest.TestStateCheckBox();
testStateRadioButton1 = new FlatComponentStateTest.TestStateRadioButton();
testStateRadioButton5 = new FlatComponentStateTest.TestStateRadioButton();
label18 = new JLabel();
testStateCheckBox2 = new FlatComponentStateTest.TestStateCheckBox();
testStateCheckBox6 = new FlatComponentStateTest.TestStateCheckBox();
testStateRadioButton2 = new FlatComponentStateTest.TestStateRadioButton();
testStateRadioButton6 = new FlatComponentStateTest.TestStateRadioButton();
label19 = new JLabel();
testStateCheckBox3 = new FlatComponentStateTest.TestStateCheckBox();
testStateCheckBox7 = new FlatComponentStateTest.TestStateCheckBox();
testStateRadioButton3 = new FlatComponentStateTest.TestStateRadioButton();
testStateRadioButton7 = new FlatComponentStateTest.TestStateRadioButton();
label20 = new JLabel();
testStateCheckBox4 = new FlatComponentStateTest.TestStateCheckBox();
testStateRadioButton4 = new FlatComponentStateTest.TestStateRadioButton();
label21 = new JLabel();
checkBox1 = new JCheckBox();
radioButton1 = new JRadioButton();
//======== this ========
setLayout(new MigLayout(
"hidemode 3",
// columns
"[fill]" +
"[fill]" +
"[fill]para" +
"[fill]" +
"[fill]para" +
"[fill]" +
"[fill]" +
"[fill]" +
"[fill]",
// rows
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]para" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]para" +
"[]"));
//---- label11 ----
label11.setText("JButton");
label11.setFont(label11.getFont().deriveFont(label11.getFont().getSize() + 4f));
add(label11, "cell 1 0 2 1");
//---- label9 ----
label9.setText("default JButton");
label9.setFont(label9.getFont().deriveFont(label9.getFont().getSize() + 4f));
add(label9, "cell 3 0 2 1");
//---- label12 ----
label12.setText("JToggleButton");
label12.setFont(label12.getFont().deriveFont(label12.getFont().getSize() + 4f));
add(label12, "cell 5 0 3 1");
//---- label5 ----
label5.setText("none");
add(label5, "cell 1 1");
//---- label6 ----
label6.setText("focused");
add(label6, "cell 2 1");
//---- label7 ----
label7.setText("none");
add(label7, "cell 3 1");
//---- label8 ----
label8.setText("focused");
add(label8, "cell 4 1");
//---- label13 ----
label13.setText("none");
add(label13, "cell 5 1");
//---- label14 ----
label14.setText("selected");
add(label14, "cell 6 1");
//---- label15 ----
label15.setText("focused");
add(label15, "cell 7 1");
//---- label16 ----
label16.setText("selected");
add(label16, "cell 8 1");
//---- label1 ----
label1.setText("none");
add(label1, "cell 0 2");
//---- testStateButton1 ----
testStateButton1.setText("text");
add(testStateButton1, "cell 1 2");
//---- testStateButton4 ----
testStateButton4.setText("text");
testStateButton4.setStateFocused(true);
add(testStateButton4, "cell 2 2");
//---- testStateButton7 ----
testStateButton7.setText("text");
testStateButton7.setStateDefault(true);
add(testStateButton7, "cell 3 2");
//---- testStateButton10 ----
testStateButton10.setText("text");
testStateButton10.setStateFocused(true);
testStateButton10.setStateDefault(true);
add(testStateButton10, "cell 4 2");
//---- testStateToggleButton1 ----
testStateToggleButton1.setText("text");
add(testStateToggleButton1, "cell 5 2");
//---- testStateToggleButton5 ----
testStateToggleButton5.setText("text");
testStateToggleButton5.setStateSelected(true);
add(testStateToggleButton5, "cell 6 2");
//---- testStateToggleButton9 ----
testStateToggleButton9.setText("text");
testStateToggleButton9.setStateFocused(true);
add(testStateToggleButton9, "cell 7 2");
//---- testStateToggleButton12 ----
testStateToggleButton12.setText("text");
testStateToggleButton12.setStateSelected(true);
testStateToggleButton12.setStateFocused(true);
add(testStateToggleButton12, "cell 8 2");
//---- label2 ----
label2.setText("hover");
add(label2, "cell 0 3");
//---- testStateButton2 ----
testStateButton2.setText("text");
testStateButton2.setStateHover(true);
add(testStateButton2, "cell 1 3");
//---- testStateButton5 ----
testStateButton5.setText("text");
testStateButton5.setStateHover(true);
testStateButton5.setStateFocused(true);
add(testStateButton5, "cell 2 3");
//---- testStateButton8 ----
testStateButton8.setText("text");
testStateButton8.setStateHover(true);
testStateButton8.setStateDefault(true);
add(testStateButton8, "cell 3 3");
//---- testStateButton11 ----
testStateButton11.setText("text");
testStateButton11.setStateHover(true);
testStateButton11.setStateFocused(true);
testStateButton11.setStateDefault(true);
add(testStateButton11, "cell 4 3");
//---- testStateToggleButton2 ----
testStateToggleButton2.setText("text");
testStateToggleButton2.setStateHover(true);
add(testStateToggleButton2, "cell 5 3");
//---- testStateToggleButton6 ----
testStateToggleButton6.setText("text");
testStateToggleButton6.setStateHover(true);
testStateToggleButton6.setStateSelected(true);
add(testStateToggleButton6, "cell 6 3");
//---- testStateToggleButton10 ----
testStateToggleButton10.setText("text");
testStateToggleButton10.setStateHover(true);
testStateToggleButton10.setStateFocused(true);
add(testStateToggleButton10, "cell 7 3");
//---- testStateToggleButton13 ----
testStateToggleButton13.setText("text");
testStateToggleButton13.setStateHover(true);
testStateToggleButton13.setStateSelected(true);
testStateToggleButton13.setStateFocused(true);
add(testStateToggleButton13, "cell 8 3");
//---- label3 ----
label3.setText("pressed");
add(label3, "cell 0 4");
//---- testStateButton3 ----
testStateButton3.setText("text");
testStateButton3.setStatePressed(true);
add(testStateButton3, "cell 1 4");
//---- testStateButton6 ----
testStateButton6.setText("text");
testStateButton6.setStatePressed(true);
testStateButton6.setStateFocused(true);
add(testStateButton6, "cell 2 4");
//---- testStateButton9 ----
testStateButton9.setText("text");
testStateButton9.setStatePressed(true);
testStateButton9.setStateDefault(true);
add(testStateButton9, "cell 3 4");
//---- testStateButton12 ----
testStateButton12.setText("text");
testStateButton12.setStatePressed(true);
testStateButton12.setStateFocused(true);
testStateButton12.setStateDefault(true);
add(testStateButton12, "cell 4 4");
//---- testStateToggleButton3 ----
testStateToggleButton3.setText("text");
testStateToggleButton3.setStatePressed(true);
add(testStateToggleButton3, "cell 5 4");
//---- testStateToggleButton7 ----
testStateToggleButton7.setText("text");
testStateToggleButton7.setStatePressed(true);
testStateToggleButton7.setStateSelected(true);
add(testStateToggleButton7, "cell 6 4");
//---- testStateToggleButton11 ----
testStateToggleButton11.setText("text");
testStateToggleButton11.setStatePressed(true);
testStateToggleButton11.setStateFocused(true);
add(testStateToggleButton11, "cell 7 4");
//---- testStateToggleButton14 ----
testStateToggleButton14.setText("text");
testStateToggleButton14.setStatePressed(true);
testStateToggleButton14.setStateSelected(true);
testStateToggleButton14.setStateFocused(true);
add(testStateToggleButton14, "cell 8 4");
//---- label4 ----
label4.setText("disabled");
add(label4, "cell 0 5");
//---- testStateButton13 ----
testStateButton13.setText("text");
testStateButton13.setEnabled(false);
add(testStateButton13, "cell 1 5");
//---- testStateButton14 ----
testStateButton14.setText("text");
testStateButton14.setEnabled(false);
testStateButton14.setStateDefault(true);
add(testStateButton14, "cell 3 5");
//---- testStateToggleButton4 ----
testStateToggleButton4.setText("text");
testStateToggleButton4.setEnabled(false);
add(testStateToggleButton4, "cell 5 5");
//---- testStateToggleButton8 ----
testStateToggleButton8.setText("text");
testStateToggleButton8.setEnabled(false);
testStateToggleButton8.setStateSelected(true);
add(testStateToggleButton8, "cell 6 5");
//---- label10 ----
label10.setText("raw");
add(label10, "cell 0 6");
//---- button1 ----
button1.setText("text");
add(button1, "cell 1 6");
//---- testDefaultButton1 ----
testDefaultButton1.setText("text");
add(testDefaultButton1, "cell 3 6");
//---- toggleButton1 ----
toggleButton1.setText("text");
add(toggleButton1, "cell 5 6");
//---- toggleButton2 ----
toggleButton2.setText("text");
toggleButton2.setSelected(true);
add(toggleButton2, "cell 6 6");
add(separator1, "cell 0 7 9 1");
//---- label22 ----
label22.setText("JCheckBox");
label22.setFont(label22.getFont().deriveFont(label22.getFont().getSize() + 4f));
add(label22, "cell 1 8 2 1");
//---- label27 ----
label27.setText("JRadioButton");
label27.setFont(label27.getFont().deriveFont(label27.getFont().getSize() + 4f));
add(label27, "cell 3 8 2 1");
//---- label23 ----
label23.setText("none");
add(label23, "cell 1 9");
//---- label24 ----
label24.setText("focused");
add(label24, "cell 2 9");
//---- label25 ----
label25.setText("none");
add(label25, "cell 3 9");
//---- label26 ----
label26.setText("focused");
add(label26, "cell 4 9");
//---- label17 ----
label17.setText("none");
add(label17, "cell 0 10");
//---- testStateCheckBox1 ----
testStateCheckBox1.setText("text");
add(testStateCheckBox1, "cell 1 10");
//---- testStateCheckBox5 ----
testStateCheckBox5.setText("text");
testStateCheckBox5.setStateFocused(true);
add(testStateCheckBox5, "cell 2 10");
//---- testStateRadioButton1 ----
testStateRadioButton1.setText("text");
add(testStateRadioButton1, "cell 3 10");
//---- testStateRadioButton5 ----
testStateRadioButton5.setText("text");
testStateRadioButton5.setStateFocused(true);
add(testStateRadioButton5, "cell 4 10");
//---- label18 ----
label18.setText("hover");
add(label18, "cell 0 11");
//---- testStateCheckBox2 ----
testStateCheckBox2.setText("text");
testStateCheckBox2.setStateHover(true);
add(testStateCheckBox2, "cell 1 11");
//---- testStateCheckBox6 ----
testStateCheckBox6.setText("text");
testStateCheckBox6.setStateFocused(true);
testStateCheckBox6.setStateHover(true);
add(testStateCheckBox6, "cell 2 11");
//---- testStateRadioButton2 ----
testStateRadioButton2.setText("text");
testStateRadioButton2.setStateHover(true);
add(testStateRadioButton2, "cell 3 11");
//---- testStateRadioButton6 ----
testStateRadioButton6.setText("text");
testStateRadioButton6.setStateFocused(true);
testStateRadioButton6.setStateHover(true);
add(testStateRadioButton6, "cell 4 11");
//---- label19 ----
label19.setText("pressed");
add(label19, "cell 0 12");
//---- testStateCheckBox3 ----
testStateCheckBox3.setText("text");
testStateCheckBox3.setStatePressed(true);
add(testStateCheckBox3, "cell 1 12");
//---- testStateCheckBox7 ----
testStateCheckBox7.setText("text");
testStateCheckBox7.setStateFocused(true);
testStateCheckBox7.setStatePressed(true);
add(testStateCheckBox7, "cell 2 12");
//---- testStateRadioButton3 ----
testStateRadioButton3.setText("text");
testStateRadioButton3.setStatePressed(true);
add(testStateRadioButton3, "cell 3 12");
//---- testStateRadioButton7 ----
testStateRadioButton7.setText("text");
testStateRadioButton7.setStateFocused(true);
testStateRadioButton7.setStatePressed(true);
add(testStateRadioButton7, "cell 4 12");
//---- label20 ----
label20.setText("disabled");
add(label20, "cell 0 13");
//---- testStateCheckBox4 ----
testStateCheckBox4.setText("text");
testStateCheckBox4.setEnabled(false);
add(testStateCheckBox4, "cell 1 13");
//---- testStateRadioButton4 ----
testStateRadioButton4.setText("text");
testStateRadioButton4.setEnabled(false);
add(testStateRadioButton4, "cell 3 13");
//---- label21 ----
label21.setText("raw");
add(label21, "cell 0 14");
//---- checkBox1 ----
checkBox1.setText("text");
add(checkBox1, "cell 1 14");
//---- radioButton1 ----
radioButton1.setText("text");
add(radioButton1, "cell 3 14");
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JLabel label11;
private JLabel label9;
private JLabel label12;
private JLabel label5;
private JLabel label6;
private JLabel label7;
private JLabel label8;
private JLabel label13;
private JLabel label14;
private JLabel label15;
private JLabel label16;
private JLabel label1;
private FlatComponentStateTest.TestStateButton testStateButton1;
private FlatComponentStateTest.TestStateButton testStateButton4;
private FlatComponentStateTest.TestStateButton testStateButton7;
private FlatComponentStateTest.TestStateButton testStateButton10;
private FlatComponentStateTest.TestStateToggleButton testStateToggleButton1;
private FlatComponentStateTest.TestStateToggleButton testStateToggleButton5;
private FlatComponentStateTest.TestStateToggleButton testStateToggleButton9;
private FlatComponentStateTest.TestStateToggleButton testStateToggleButton12;
private JLabel label2;
private FlatComponentStateTest.TestStateButton testStateButton2;
private FlatComponentStateTest.TestStateButton testStateButton5;
private FlatComponentStateTest.TestStateButton testStateButton8;
private FlatComponentStateTest.TestStateButton testStateButton11;
private FlatComponentStateTest.TestStateToggleButton testStateToggleButton2;
private FlatComponentStateTest.TestStateToggleButton testStateToggleButton6;
private FlatComponentStateTest.TestStateToggleButton testStateToggleButton10;
private FlatComponentStateTest.TestStateToggleButton testStateToggleButton13;
private JLabel label3;
private FlatComponentStateTest.TestStateButton testStateButton3;
private FlatComponentStateTest.TestStateButton testStateButton6;
private FlatComponentStateTest.TestStateButton testStateButton9;
private FlatComponentStateTest.TestStateButton testStateButton12;
private FlatComponentStateTest.TestStateToggleButton testStateToggleButton3;
private FlatComponentStateTest.TestStateToggleButton testStateToggleButton7;
private FlatComponentStateTest.TestStateToggleButton testStateToggleButton11;
private FlatComponentStateTest.TestStateToggleButton testStateToggleButton14;
private JLabel label4;
private FlatComponentStateTest.TestStateButton testStateButton13;
private FlatComponentStateTest.TestStateButton testStateButton14;
private FlatComponentStateTest.TestStateToggleButton testStateToggleButton4;
private FlatComponentStateTest.TestStateToggleButton testStateToggleButton8;
private JLabel label10;
private JButton button1;
private FlatComponentStateTest.TestDefaultButton testDefaultButton1;
private JToggleButton toggleButton1;
private JToggleButton toggleButton2;
private JSeparator separator1;
private JLabel label22;
private JLabel label27;
private JLabel label23;
private JLabel label24;
private JLabel label25;
private JLabel label26;
private JLabel label17;
private FlatComponentStateTest.TestStateCheckBox testStateCheckBox1;
private FlatComponentStateTest.TestStateCheckBox testStateCheckBox5;
private FlatComponentStateTest.TestStateRadioButton testStateRadioButton1;
private FlatComponentStateTest.TestStateRadioButton testStateRadioButton5;
private JLabel label18;
private FlatComponentStateTest.TestStateCheckBox testStateCheckBox2;
private FlatComponentStateTest.TestStateCheckBox testStateCheckBox6;
private FlatComponentStateTest.TestStateRadioButton testStateRadioButton2;
private FlatComponentStateTest.TestStateRadioButton testStateRadioButton6;
private JLabel label19;
private FlatComponentStateTest.TestStateCheckBox testStateCheckBox3;
private FlatComponentStateTest.TestStateCheckBox testStateCheckBox7;
private FlatComponentStateTest.TestStateRadioButton testStateRadioButton3;
private FlatComponentStateTest.TestStateRadioButton testStateRadioButton7;
private JLabel label20;
private FlatComponentStateTest.TestStateCheckBox testStateCheckBox4;
private FlatComponentStateTest.TestStateRadioButton testStateRadioButton4;
private JLabel label21;
private JCheckBox checkBox1;
private JRadioButton radioButton1;
// JFormDesigner - End of variables declaration //GEN-END:variables
//---- class TestStateButton ----------------------------------------------
private static class TestStateButton
extends JButton
{
private boolean stateHover;
private boolean statePressed;
private boolean stateFocused;
private boolean stateDefault;
public TestStateButton() {
setModel( new DefaultButtonModel() {
@Override
public boolean isRollover() {
return isStateHover();
}
@Override
public boolean isPressed() {
return isStatePressed();
}
} );
putClientProperty( FlatClientProperties.COMPONENT_FOCUS_OWNER,
(Predicate<Component>) c -> {
return ((TestStateButton)c).isStateFocused();
} );
}
public boolean isStateHover() {
return stateHover;
}
public void setStateHover( boolean stateHover ) {
this.stateHover = stateHover;
}
public boolean isStatePressed() {
return statePressed;
}
public void setStatePressed( boolean statePressed ) {
this.statePressed = statePressed;
}
public boolean isStateFocused() {
return stateFocused;
}
public void setStateFocused( boolean stateFocused ) {
this.stateFocused = stateFocused;
}
public boolean isStateDefault() {
return stateDefault;
}
public void setStateDefault( boolean stateDefault ) {
this.stateDefault = stateDefault;
}
@Override
public boolean isDefaultButton() {
return isStateDefault();
}
}
//---- class TestStateToggleButton ----------------------------------------
private static class TestStateToggleButton
extends JToggleButton
{
private boolean stateHover;
private boolean statePressed;
private boolean stateFocused;
private boolean stateSelected;
public TestStateToggleButton() {
setModel( new DefaultButtonModel() {
@Override
public boolean isRollover() {
return isStateHover();
}
@Override
public boolean isPressed() {
return isStatePressed();
}
@Override
public boolean isSelected() {
return isStateSelected();
}
} );
putClientProperty( FlatClientProperties.COMPONENT_FOCUS_OWNER,
(Predicate<Component>) c -> {
return ((TestStateToggleButton)c).isStateFocused();
} );
}
public boolean isStateHover() {
return stateHover;
}
public void setStateHover( boolean stateHover ) {
this.stateHover = stateHover;
}
public boolean isStatePressed() {
return statePressed;
}
public void setStatePressed( boolean statePressed ) {
this.statePressed = statePressed;
}
public boolean isStateFocused() {
return stateFocused;
}
public void setStateFocused( boolean stateFocused ) {
this.stateFocused = stateFocused;
}
public boolean isStateSelected() {
return stateSelected;
}
public void setStateSelected( boolean stateSelected ) {
this.stateSelected = stateSelected;
}
}
//---- class TestStateCheckBox --------------------------------------------
private static class TestStateCheckBox
extends JCheckBox
{
private boolean stateHover;
private boolean statePressed;
private boolean stateFocused;
private boolean stateSelected;
public TestStateCheckBox() {
setModel( new DefaultButtonModel() {
@Override
public boolean isRollover() {
return isStateHover();
}
@Override
public boolean isPressed() {
return isStatePressed();
}
@Override
public boolean isSelected() {
return isStateSelected();
}
} );
putClientProperty( FlatClientProperties.COMPONENT_FOCUS_OWNER,
(Predicate<Component>) c -> {
return ((TestStateCheckBox)c).isStateFocused();
} );
}
public boolean isStateHover() {
return stateHover;
}
public void setStateHover( boolean stateHover ) {
this.stateHover = stateHover;
}
public boolean isStatePressed() {
return statePressed;
}
public void setStatePressed( boolean statePressed ) {
this.statePressed = statePressed;
}
public boolean isStateFocused() {
return stateFocused;
}
public void setStateFocused( boolean stateFocused ) {
this.stateFocused = stateFocused;
}
public boolean isStateSelected() {
return stateSelected;
}
public void setStateSelected( boolean stateSelected ) {
this.stateSelected = stateSelected;
}
}
//---- class TestStateCheckBox --------------------------------------------
private static class TestStateRadioButton
extends JRadioButton
{
private boolean stateHover;
private boolean statePressed;
private boolean stateFocused;
private boolean stateSelected;
public TestStateRadioButton() {
setModel( new DefaultButtonModel() {
@Override
public boolean isRollover() {
return isStateHover();
}
@Override
public boolean isPressed() {
return isStatePressed();
}
@Override
public boolean isSelected() {
return isStateSelected();
}
} );
putClientProperty( FlatClientProperties.COMPONENT_FOCUS_OWNER,
(Predicate<Component>) c -> {
return ((TestStateRadioButton)c).isStateFocused();
} );
}
public boolean isStateHover() {
return stateHover;
}
public void setStateHover( boolean stateHover ) {
this.stateHover = stateHover;
}
public boolean isStatePressed() {
return statePressed;
}
public void setStatePressed( boolean statePressed ) {
this.statePressed = statePressed;
}
public boolean isStateFocused() {
return stateFocused;
}
public void setStateFocused( boolean stateFocused ) {
this.stateFocused = stateFocused;
}
public boolean isStateSelected() {
return stateSelected;
}
public void setStateSelected( boolean stateSelected ) {
this.stateSelected = stateSelected;
}
}
//---- class TestDefaultButton --------------------------------------------
private static class TestDefaultButton
extends JButton
{
@Override
public boolean isDefaultButton() {
return true;
}
}
}

View File

@@ -0,0 +1,540 @@
JFDML JFormDesigner: "7.0.3.1.342" Java: "15" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
root: new FormRoot {
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "hidemode 3"
"$columnConstraints": "[fill][fill][fill]para[fill][fill]para[fill][fill][fill][fill]"
"$rowConstraints": "[][][][][][]para[][][][][][][][]para[]"
} ) {
name: "this"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label11"
"text": "JButton"
"font": &SwingDerivedFont0 new com.jformdesigner.model.SwingDerivedFont( null, 0, 4, false )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0 2 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label9"
"text": "default JButton"
"font": #SwingDerivedFont0
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 0 2 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label12"
"text": "JToggleButton"
"font": #SwingDerivedFont0
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 0 3 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label5"
"text": "none"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label6"
"text": "focused"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label7"
"text": "none"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label8"
"text": "focused"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label13"
"text": "none"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label14"
"text": "selected"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 6 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label15"
"text": "focused"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 7 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label16"
"text": "selected"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 8 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label1"
"text": "none"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateButton" ) {
name: "testStateButton1"
"text": "text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateButton" ) {
name: "testStateButton4"
"text": "text"
"stateFocused": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 2"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateButton" ) {
name: "testStateButton7"
"text": "text"
"stateDefault": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 2"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateButton" ) {
name: "testStateButton10"
"text": "text"
"stateFocused": true
"stateDefault": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 2"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateToggleButton" ) {
name: "testStateToggleButton1"
"text": "text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 2"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateToggleButton" ) {
name: "testStateToggleButton5"
"text": "text"
"stateSelected": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 6 2"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateToggleButton" ) {
name: "testStateToggleButton9"
"text": "text"
"stateFocused": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 7 2"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateToggleButton" ) {
name: "testStateToggleButton12"
"text": "text"
"stateSelected": true
"stateFocused": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 8 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label2"
"text": "hover"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateButton" ) {
name: "testStateButton2"
"text": "text"
"stateHover": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateButton" ) {
name: "testStateButton5"
"text": "text"
"stateHover": true
"stateFocused": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 3"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateButton" ) {
name: "testStateButton8"
"text": "text"
"stateHover": true
"stateDefault": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 3"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateButton" ) {
name: "testStateButton11"
"text": "text"
"stateHover": true
"stateFocused": true
"stateDefault": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 3"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateToggleButton" ) {
name: "testStateToggleButton2"
"text": "text"
"stateHover": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 3"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateToggleButton" ) {
name: "testStateToggleButton6"
"text": "text"
"stateHover": true
"stateSelected": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 6 3"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateToggleButton" ) {
name: "testStateToggleButton10"
"text": "text"
"stateHover": true
"stateFocused": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 7 3"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateToggleButton" ) {
name: "testStateToggleButton13"
"text": "text"
"stateHover": true
"stateSelected": true
"stateFocused": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 8 3"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label3"
"text": "pressed"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateButton" ) {
name: "testStateButton3"
"text": "text"
"statePressed": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateButton" ) {
name: "testStateButton6"
"text": "text"
"statePressed": true
"stateFocused": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 4"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateButton" ) {
name: "testStateButton9"
"text": "text"
"statePressed": true
"stateDefault": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 4"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateButton" ) {
name: "testStateButton12"
"text": "text"
"statePressed": true
"stateFocused": true
"stateDefault": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 4"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateToggleButton" ) {
name: "testStateToggleButton3"
"text": "text"
"statePressed": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 4"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateToggleButton" ) {
name: "testStateToggleButton7"
"text": "text"
"statePressed": true
"stateSelected": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 6 4"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateToggleButton" ) {
name: "testStateToggleButton11"
"text": "text"
"statePressed": true
"stateFocused": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 7 4"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateToggleButton" ) {
name: "testStateToggleButton14"
"text": "text"
"statePressed": true
"stateSelected": true
"stateFocused": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 8 4"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label4"
"text": "disabled"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateButton" ) {
name: "testStateButton13"
"text": "text"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateButton" ) {
name: "testStateButton14"
"text": "text"
"enabled": false
"stateDefault": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 5"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateToggleButton" ) {
name: "testStateToggleButton4"
"text": "text"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 5"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateToggleButton" ) {
name: "testStateToggleButton8"
"text": "text"
"enabled": false
"stateSelected": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 6 5"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label10"
"text": "raw"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button1"
"text": "text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 6"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestDefaultButton" ) {
name: "testDefaultButton1"
"text": "text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 6"
} )
add( new FormComponent( "javax.swing.JToggleButton" ) {
name: "toggleButton1"
"text": "text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 6"
} )
add( new FormComponent( "javax.swing.JToggleButton" ) {
name: "toggleButton2"
"text": "text"
"selected": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 6 6"
} )
add( new FormComponent( "javax.swing.JSeparator" ) {
name: "separator1"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 7 9 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label22"
"text": "JCheckBox"
"font": #SwingDerivedFont0
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 8 2 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label27"
"text": "JRadioButton"
"font": #SwingDerivedFont0
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 8 2 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label23"
"text": "none"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 9"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label24"
"text": "focused"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 9"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label25"
"text": "none"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 9"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label26"
"text": "focused"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 9"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label17"
"text": "none"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 10"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateCheckBox" ) {
name: "testStateCheckBox1"
"text": "text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 10"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateCheckBox" ) {
name: "testStateCheckBox5"
"text": "text"
"stateFocused": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 10"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateRadioButton" ) {
name: "testStateRadioButton1"
"text": "text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 10"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateRadioButton" ) {
name: "testStateRadioButton5"
"text": "text"
"stateFocused": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 10"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label18"
"text": "hover"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 11"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateCheckBox" ) {
name: "testStateCheckBox2"
"text": "text"
"stateHover": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 11"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateCheckBox" ) {
name: "testStateCheckBox6"
"text": "text"
"stateFocused": true
"stateHover": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 11"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateRadioButton" ) {
name: "testStateRadioButton2"
"text": "text"
"stateHover": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 11"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateRadioButton" ) {
name: "testStateRadioButton6"
"text": "text"
"stateFocused": true
"stateHover": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 11"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label19"
"text": "pressed"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 12"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateCheckBox" ) {
name: "testStateCheckBox3"
"text": "text"
"statePressed": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 12"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateCheckBox" ) {
name: "testStateCheckBox7"
"text": "text"
"stateFocused": true
"statePressed": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 12"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateRadioButton" ) {
name: "testStateRadioButton3"
"text": "text"
"statePressed": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 12"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateRadioButton" ) {
name: "testStateRadioButton7"
"text": "text"
"stateFocused": true
"statePressed": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 12"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label20"
"text": "disabled"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 13"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateCheckBox" ) {
name: "testStateCheckBox4"
"text": "text"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 13"
} )
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentStateTest$TestStateRadioButton" ) {
name: "testStateRadioButton4"
"text": "text"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 13"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label21"
"text": "raw"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 14"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "checkBox1"
"text": "text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 14"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "radioButton1"
"text": "text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 14"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 680, 685 )
} )
}
}