mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-08 06:50:56 +03:00
Testing: added "opaque" checkbox to test apps
This commit is contained in:
@@ -28,7 +28,7 @@ public class FlatChooserTest
|
|||||||
public static void main( String[] args ) {
|
public static void main( String[] args ) {
|
||||||
SwingUtilities.invokeLater( () -> {
|
SwingUtilities.invokeLater( () -> {
|
||||||
FlatTestFrame frame = FlatTestFrame.create( args, "FlatChooserTest" );
|
FlatTestFrame frame = FlatTestFrame.create( args, "FlatChooserTest" );
|
||||||
frame.showFrame( new FlatChooserTest() );
|
frame.showFrame( FlatChooserTest::new );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class FlatComponents2Test
|
|||||||
public static void main( String[] args ) {
|
public static void main( String[] args ) {
|
||||||
SwingUtilities.invokeLater( () -> {
|
SwingUtilities.invokeLater( () -> {
|
||||||
FlatTestFrame frame = FlatTestFrame.create( args, "FlatComponents2Test" );
|
FlatTestFrame frame = FlatTestFrame.create( args, "FlatComponents2Test" );
|
||||||
frame.showFrame( new FlatComponents2Test() );
|
frame.showFrame( FlatComponents2Test::new );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class FlatComponentsTest
|
|||||||
public static void main( String[] args ) {
|
public static void main( String[] args ) {
|
||||||
SwingUtilities.invokeLater( () -> {
|
SwingUtilities.invokeLater( () -> {
|
||||||
FlatTestFrame frame = FlatTestFrame.create( args, "FlatComponentsTest" );
|
FlatTestFrame frame = FlatTestFrame.create( args, "FlatComponentsTest" );
|
||||||
frame.showFrame( new FlatComponentsTest() );
|
frame.showFrame( FlatComponentsTest::new );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class FlatContainerTest
|
|||||||
public static void main( String[] args ) {
|
public static void main( String[] args ) {
|
||||||
SwingUtilities.invokeLater( () -> {
|
SwingUtilities.invokeLater( () -> {
|
||||||
FlatTestFrame frame = FlatTestFrame.create( args, "FlatContainerTest" );
|
FlatTestFrame frame = FlatTestFrame.create( args, "FlatContainerTest" );
|
||||||
frame.showFrame( new FlatContainerTest() );
|
frame.showFrame( FlatContainerTest::new );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class FlatMenusTest
|
|||||||
public static void main( String[] args ) {
|
public static void main( String[] args ) {
|
||||||
SwingUtilities.invokeLater( () -> {
|
SwingUtilities.invokeLater( () -> {
|
||||||
FlatTestFrame frame = FlatTestFrame.create( args, "FlatMenusTest" );
|
FlatTestFrame frame = FlatTestFrame.create( args, "FlatMenusTest" );
|
||||||
frame.showFrame( new FlatMenusTest() );
|
frame.showFrame( FlatMenusTest::new );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class FlatOptionPaneTest
|
|||||||
public static void main( String[] args ) {
|
public static void main( String[] args ) {
|
||||||
SwingUtilities.invokeLater( () -> {
|
SwingUtilities.invokeLater( () -> {
|
||||||
FlatTestFrame frame = FlatTestFrame.create( args, "FlatOptionPaneTest" );
|
FlatTestFrame frame = FlatTestFrame.create( args, "FlatOptionPaneTest" );
|
||||||
frame.showFrame( new FlatOptionPaneTest() );
|
frame.showFrame( FlatOptionPaneTest::new );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import java.awt.event.KeyEvent;
|
|||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.Supplier;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.plaf.ColorUIResource;
|
import javax.swing.plaf.ColorUIResource;
|
||||||
@@ -33,6 +34,8 @@ import com.formdev.flatlaf.FlatDarkLaf;
|
|||||||
import com.formdev.flatlaf.FlatIntelliJLaf;
|
import com.formdev.flatlaf.FlatIntelliJLaf;
|
||||||
import com.formdev.flatlaf.FlatLaf;
|
import com.formdev.flatlaf.FlatLaf;
|
||||||
import com.formdev.flatlaf.FlatLightLaf;
|
import com.formdev.flatlaf.FlatLightLaf;
|
||||||
|
import com.formdev.flatlaf.extras.*;
|
||||||
|
import com.formdev.flatlaf.extras.TriStateCheckBox.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;
|
||||||
@@ -49,6 +52,7 @@ public class FlatTestFrame
|
|||||||
private static final String KEY_SCALE_FACTOR = "scaleFactor";
|
private static final String KEY_SCALE_FACTOR = "scaleFactor";
|
||||||
|
|
||||||
private final String title;
|
private final String title;
|
||||||
|
private Supplier<JComponent> contentFactory;
|
||||||
private JComponent content;
|
private JComponent content;
|
||||||
private FlatInspector inspector;
|
private FlatInspector inspector;
|
||||||
|
|
||||||
@@ -211,8 +215,9 @@ public class FlatTestFrame
|
|||||||
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
|
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showFrame( JComponent content ) {
|
public void showFrame( Supplier<JComponent> contentFactory ) {
|
||||||
this.content = content;
|
this.contentFactory = contentFactory;
|
||||||
|
this.content = contentFactory.get();
|
||||||
|
|
||||||
contentPanel.getContentPane().add( content );
|
contentPanel.getContentPane().add( content );
|
||||||
pack();
|
pack();
|
||||||
@@ -403,6 +408,27 @@ public class FlatTestFrame
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void opaqueChanged() {
|
||||||
|
State opaque = opaqueTriStateCheckBox.getState();
|
||||||
|
if( opaque == State.INDETERMINATE )
|
||||||
|
recreateContent();
|
||||||
|
else {
|
||||||
|
updateComponentsRecur( content, (c, type) -> {
|
||||||
|
if( c instanceof JComponent )
|
||||||
|
((JComponent)c).setOpaque( opaque == State.SELECTED );
|
||||||
|
} );
|
||||||
|
contentPanel.repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void recreateContent() {
|
||||||
|
contentPanel.getContentPane().remove( content );
|
||||||
|
content = contentFactory.get();
|
||||||
|
contentPanel.getContentPane().add( content );
|
||||||
|
contentPanel.revalidate();
|
||||||
|
contentPanel.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
||||||
dialogPane = new JPanel();
|
dialogPane = new JPanel();
|
||||||
@@ -415,6 +441,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();
|
||||||
closeButton = new JButton();
|
closeButton = new JButton();
|
||||||
|
|
||||||
//======== this ========
|
//======== this ========
|
||||||
@@ -450,6 +477,7 @@ public class FlatTestFrame
|
|||||||
"[fill]" +
|
"[fill]" +
|
||||||
"[fill]" +
|
"[fill]" +
|
||||||
"[fill]" +
|
"[fill]" +
|
||||||
|
"[fill]" +
|
||||||
"[grow,fill]" +
|
"[grow,fill]" +
|
||||||
"[button,fill]",
|
"[button,fill]",
|
||||||
// rows
|
// rows
|
||||||
@@ -508,9 +536,15 @@ public class FlatTestFrame
|
|||||||
backgroundCheckBox.addActionListener(e -> backgroundChanged());
|
backgroundCheckBox.addActionListener(e -> backgroundChanged());
|
||||||
buttonBar.add(backgroundCheckBox, "cell 6 0");
|
buttonBar.add(backgroundCheckBox, "cell 6 0");
|
||||||
|
|
||||||
|
//---- opaqueTriStateCheckBox ----
|
||||||
|
opaqueTriStateCheckBox.setText("opaque");
|
||||||
|
opaqueTriStateCheckBox.setMnemonic('O');
|
||||||
|
opaqueTriStateCheckBox.addActionListener(e -> opaqueChanged());
|
||||||
|
buttonBar.add(opaqueTriStateCheckBox, "cell 7 0");
|
||||||
|
|
||||||
//---- closeButton ----
|
//---- closeButton ----
|
||||||
closeButton.setText("Close");
|
closeButton.setText("Close");
|
||||||
buttonBar.add(closeButton, "cell 8 0");
|
buttonBar.add(closeButton, "cell 9 0");
|
||||||
}
|
}
|
||||||
dialogPane.add(buttonBar, BorderLayout.SOUTH);
|
dialogPane.add(buttonBar, BorderLayout.SOUTH);
|
||||||
}
|
}
|
||||||
@@ -529,6 +563,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 JButton closeButton;
|
private JButton closeButton;
|
||||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ 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 dialog"
|
"$layoutConstraints": "insets dialog"
|
||||||
"$columnConstraints": "[fill][fill][fill][fill][fill][fill][fill][grow,fill][button,fill]"
|
"$columnConstraints": "[fill][fill][fill][fill][fill][fill][fill][fill][grow,fill][button,fill]"
|
||||||
"$rowSpecs": "[fill]"
|
"$rowSpecs": "[fill]"
|
||||||
} ) {
|
} ) {
|
||||||
name: "buttonBar"
|
name: "buttonBar"
|
||||||
@@ -99,11 +99,19 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 6 0"
|
"value": "cell 6 0"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "com.formdev.flatlaf.extras.TriStateCheckBox" ) {
|
||||||
|
name: "opaqueTriStateCheckBox"
|
||||||
|
"text": "opaque"
|
||||||
|
"mnemonic": 79
|
||||||
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "opaqueChanged", false ) )
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 7 0"
|
||||||
|
} )
|
||||||
add( new FormComponent( "javax.swing.JButton" ) {
|
add( new FormComponent( "javax.swing.JButton" ) {
|
||||||
name: "closeButton"
|
name: "closeButton"
|
||||||
"text": "Close"
|
"text": "Close"
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 8 0"
|
"value": "cell 9 0"
|
||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( class java.lang.String ) {
|
}, new FormLayoutConstraints( class java.lang.String ) {
|
||||||
"value": "South"
|
"value": "South"
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class FlatExtrasTest
|
|||||||
public static void main( String[] args ) {
|
public static void main( String[] args ) {
|
||||||
SwingUtilities.invokeLater( () -> {
|
SwingUtilities.invokeLater( () -> {
|
||||||
FlatTestFrame frame = FlatTestFrame.create( args, "FlatExtrasTest" );
|
FlatTestFrame frame = FlatTestFrame.create( args, "FlatExtrasTest" );
|
||||||
frame.showFrame( new FlatExtrasTest() );
|
frame.showFrame( FlatExtrasTest::new );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class FlatSwingXTest
|
|||||||
SwingUtilities.invokeLater( () -> {
|
SwingUtilities.invokeLater( () -> {
|
||||||
FlatTestFrame frame = FlatTestFrame.create( args, "FlatSwingXTest" );
|
FlatTestFrame frame = FlatTestFrame.create( args, "FlatSwingXTest" );
|
||||||
frame.useApplyComponentOrientation = true;
|
frame.useApplyComponentOrientation = true;
|
||||||
frame.showFrame( new FlatSwingXTest() );
|
frame.showFrame( FlatSwingXTest::new );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user