mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 14:30:56 +03:00
Demo: moved Laf combobox related code to new class LookAndFeelsComboBox
This commit is contained in:
@@ -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 javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import javax.swing.UIManager.LookAndFeelInfo;
|
||||||
import javax.swing.plaf.metal.MetalLookAndFeel;
|
import javax.swing.plaf.metal.MetalLookAndFeel;
|
||||||
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
|
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
|
||||||
import com.formdev.flatlaf.*;
|
import com.formdev.flatlaf.*;
|
||||||
@@ -43,11 +44,11 @@ class ControlBar
|
|||||||
initComponents();
|
initComponents();
|
||||||
|
|
||||||
// initialize look and feels combo box
|
// initialize look and feels combo box
|
||||||
DefaultComboBoxModel<LafInfo> lafModel = new DefaultComboBoxModel<>();
|
DefaultComboBoxModel<LookAndFeelInfo> lafModel = new DefaultComboBoxModel<>();
|
||||||
lafModel.addElement( new LafInfo( "Flat Light (F1)", FlatLightLaf.class.getName() ) );
|
lafModel.addElement( new LookAndFeelInfo( "Flat Light (F1)", FlatLightLaf.class.getName() ) );
|
||||||
lafModel.addElement( new LafInfo( "Flat Dark (F2)", FlatDarkLaf.class.getName() ) );
|
lafModel.addElement( new LookAndFeelInfo( "Flat Dark (F2)", FlatDarkLaf.class.getName() ) );
|
||||||
lafModel.addElement( new LafInfo( "Flat IntelliJ (F3)", FlatIntelliJLaf.class.getName() ) );
|
lafModel.addElement( new LookAndFeelInfo( "Flat IntelliJ (F3)", FlatIntelliJLaf.class.getName() ) );
|
||||||
lafModel.addElement( new LafInfo( "Flat Darcula (F4)", FlatDarculaLaf.class.getName() ) );
|
lafModel.addElement( new LookAndFeelInfo( "Flat Darcula (F4)", FlatDarculaLaf.class.getName() ) );
|
||||||
|
|
||||||
UIManager.LookAndFeelInfo[] lookAndFeels = UIManager.getInstalledLookAndFeels();
|
UIManager.LookAndFeelInfo[] lookAndFeels = UIManager.getInstalledLookAndFeels();
|
||||||
for( UIManager.LookAndFeelInfo lookAndFeel : lookAndFeels ) {
|
for( UIManager.LookAndFeelInfo lookAndFeel : lookAndFeels ) {
|
||||||
@@ -66,19 +67,11 @@ class ControlBar
|
|||||||
else if( className.equals( NimbusLookAndFeel.class.getName() ) )
|
else if( className.equals( NimbusLookAndFeel.class.getName() ) )
|
||||||
name += " (F11)";
|
name += " (F11)";
|
||||||
|
|
||||||
lafModel.addElement( new LafInfo( name, className ) );
|
lafModel.addElement( new LookAndFeelInfo( name, className ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
LookAndFeel activeLaf = UIManager.getLookAndFeel();
|
|
||||||
String activeLafClassName = activeLaf.getClass().getName();
|
|
||||||
int sel = lafModel.getIndexOf( new LafInfo( null, activeLafClassName ) );
|
|
||||||
if( sel < 0 ) {
|
|
||||||
lafModel.addElement( new LafInfo( activeLaf.getName(), activeLafClassName ) );
|
|
||||||
sel = lafModel.getSize() - 1;
|
|
||||||
}
|
|
||||||
lafModel.setSelectedItem( lafModel.getElementAt( sel ) );
|
|
||||||
|
|
||||||
lookAndFeelComboBox.setModel( lafModel );
|
lookAndFeelComboBox.setModel( lafModel );
|
||||||
|
lookAndFeelComboBox.selectedLookAndFeel( UIManager.getLookAndFeel() );
|
||||||
|
|
||||||
UIManager.addPropertyChangeListener( e -> {
|
UIManager.addPropertyChangeListener( e -> {
|
||||||
if( "lookAndFeel".equals( e.getPropertyName() ) ) {
|
if( "lookAndFeel".equals( e.getPropertyName() ) ) {
|
||||||
@@ -161,26 +154,23 @@ class ControlBar
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void selectLookAndFeel( String lafClassName ) {
|
private void selectLookAndFeel( String lafClassName ) {
|
||||||
DefaultComboBoxModel<LafInfo> lafModel = (DefaultComboBoxModel<LafInfo>) lookAndFeelComboBox.getModel();
|
lookAndFeelComboBox.setSelectedLookAndFeel( lafClassName );
|
||||||
int sel = lafModel.getIndexOf( new LafInfo( null, lafClassName ) );
|
|
||||||
if( sel >= 0 )
|
|
||||||
lookAndFeelComboBox.setSelectedIndex( sel );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void lookAndFeelChanged() {
|
private void lookAndFeelChanged() {
|
||||||
LafInfo newLaf = (LafInfo) lookAndFeelComboBox.getSelectedItem();
|
String lafClassName = lookAndFeelComboBox.getSelectedLookAndFeel();
|
||||||
if( newLaf == null )
|
if( lafClassName == null )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( newLaf.className.equals( UIManager.getLookAndFeel().getClass().getName() ) )
|
if( lafClassName.equals( UIManager.getLookAndFeel().getClass().getName() ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FlatLafDemo.prefs.put( FlatLafDemo.KEY_LAF, newLaf.className );
|
FlatLafDemo.prefs.put( FlatLafDemo.KEY_LAF, lafClassName );
|
||||||
|
|
||||||
EventQueue.invokeLater( () -> {
|
EventQueue.invokeLater( () -> {
|
||||||
try {
|
try {
|
||||||
// change look and feel
|
// change look and feel
|
||||||
UIManager.setLookAndFeel( newLaf.className );
|
UIManager.setLookAndFeel( lafClassName );
|
||||||
|
|
||||||
// update all components
|
// update all components
|
||||||
FlatLaf.updateUI();
|
FlatLaf.updateUI();
|
||||||
@@ -250,7 +240,7 @@ class ControlBar
|
|||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
||||||
separator1 = new JSeparator();
|
separator1 = new JSeparator();
|
||||||
lookAndFeelComboBox = new JComboBox<>();
|
lookAndFeelComboBox = new LookAndFeelsComboBox();
|
||||||
rightToLeftCheckBox = new JCheckBox();
|
rightToLeftCheckBox = new JCheckBox();
|
||||||
enabledCheckBox = new JCheckBox();
|
enabledCheckBox = new JCheckBox();
|
||||||
infoLabel = new JLabel();
|
infoLabel = new JLabel();
|
||||||
@@ -300,33 +290,10 @@ class ControlBar
|
|||||||
|
|
||||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
||||||
private JSeparator separator1;
|
private JSeparator separator1;
|
||||||
private JComboBox<LafInfo> lookAndFeelComboBox;
|
private LookAndFeelsComboBox lookAndFeelComboBox;
|
||||||
private JCheckBox rightToLeftCheckBox;
|
private JCheckBox rightToLeftCheckBox;
|
||||||
private JCheckBox enabledCheckBox;
|
private JCheckBox enabledCheckBox;
|
||||||
private JLabel infoLabel;
|
private JLabel infoLabel;
|
||||||
private JButton closeButton;
|
private JButton closeButton;
|
||||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||||
|
|
||||||
//---- class LafInfo ------------------------------------------------------
|
|
||||||
|
|
||||||
static class LafInfo
|
|
||||||
{
|
|
||||||
final String name;
|
|
||||||
final String className;
|
|
||||||
|
|
||||||
LafInfo( String name, String className ) {
|
|
||||||
this.name = name;
|
|
||||||
this.className = className;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals( Object obj ) {
|
|
||||||
return obj instanceof LafInfo && className.equals( ((LafInfo)obj).className );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,11 +15,8 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 0 5 1"
|
"value": "cell 0 0 5 1"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JComboBox" ) {
|
add( new FormComponent( "com.formdev.flatlaf.demo.LookAndFeelsComboBox" ) {
|
||||||
name: "lookAndFeelComboBox"
|
name: "lookAndFeelComboBox"
|
||||||
auxiliary() {
|
|
||||||
"JavaCodeGenerator.typeParameters": "LafInfo"
|
|
||||||
}
|
|
||||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "lookAndFeelChanged", false ) )
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "lookAndFeelChanged", false ) )
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 1"
|
"value": "cell 0 1"
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 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
|
||||||
|
*
|
||||||
|
* http://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.demo;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
import javax.swing.ComboBoxModel;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JList;
|
||||||
|
import javax.swing.LookAndFeel;
|
||||||
|
import javax.swing.MutableComboBoxModel;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
import javax.swing.UIManager.LookAndFeelInfo;
|
||||||
|
import javax.swing.plaf.basic.BasicComboBoxRenderer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Karl Tauber
|
||||||
|
*/
|
||||||
|
public class LookAndFeelsComboBox
|
||||||
|
extends JComboBox<UIManager.LookAndFeelInfo>
|
||||||
|
{
|
||||||
|
@SuppressWarnings( "unchecked" )
|
||||||
|
public LookAndFeelsComboBox() {
|
||||||
|
setRenderer( new BasicComboBoxRenderer() {
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings( "rawtypes" )
|
||||||
|
public Component getListCellRendererComponent( JList list, Object value,
|
||||||
|
int index, boolean isSelected, boolean cellHasFocus )
|
||||||
|
{
|
||||||
|
value = ((LookAndFeelInfo)value).getName();
|
||||||
|
return super.getListCellRendererComponent( list, value, index, isSelected, cellHasFocus );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLookAndFeel( String name, String className ) {
|
||||||
|
getMutableModel().addElement( new LookAndFeelInfo( name, className ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSelectedLookAndFeel() {
|
||||||
|
Object sel = getSelectedItem();
|
||||||
|
return (sel instanceof LookAndFeelInfo) ? ((LookAndFeelInfo)sel).getClassName() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectedLookAndFeel( String className ) {
|
||||||
|
int index = getIndexOfLookAndFeel( className );
|
||||||
|
if( index >= 0 )
|
||||||
|
setSelectedIndex( index );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectedLookAndFeel( LookAndFeel lookAndFeel ) {
|
||||||
|
String className = lookAndFeel.getClass().getName();
|
||||||
|
int index = getIndexOfLookAndFeel( className );
|
||||||
|
if( index < 0 ) {
|
||||||
|
addLookAndFeel( lookAndFeel.getName(), className );
|
||||||
|
index = getItemCount() - 1;
|
||||||
|
}
|
||||||
|
setSelectedIndex( index );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeLookAndFeel( String className ) {
|
||||||
|
int index = getIndexOfLookAndFeel( className );
|
||||||
|
if( index >= 0 )
|
||||||
|
getMutableModel().removeElementAt( index );
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIndexOfLookAndFeel( String className ) {
|
||||||
|
ComboBoxModel<LookAndFeelInfo> model = getModel();
|
||||||
|
int size = model.getSize();
|
||||||
|
for( int i = 0; i < size; i++ ) {
|
||||||
|
if( className.equals( model.getElementAt( i ).getClassName() ) )
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MutableComboBoxModel<LookAndFeelInfo> getMutableModel() {
|
||||||
|
return (MutableComboBoxModel<LookAndFeelInfo>) getModel();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,6 +25,7 @@ dependencies {
|
|||||||
implementation( project( ":flatlaf-extras" ) )
|
implementation( project( ":flatlaf-extras" ) )
|
||||||
implementation( project( ":flatlaf-swingx" ) )
|
implementation( project( ":flatlaf-swingx" ) )
|
||||||
implementation( project( ":flatlaf-jide-oss" ) )
|
implementation( project( ":flatlaf-jide-oss" ) )
|
||||||
|
implementation( project( ":flatlaf-demo" ) )
|
||||||
|
|
||||||
implementation( "com.miglayout:miglayout-swing:5.2" )
|
implementation( "com.miglayout:miglayout-swing:5.2" )
|
||||||
implementation( "com.jgoodies:jgoodies-forms:1.9.0" )
|
implementation( "com.jgoodies:jgoodies-forms:1.9.0" )
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import java.util.function.BiConsumer;
|
|||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import javax.swing.UIManager.LookAndFeelInfo;
|
||||||
import javax.swing.plaf.ColorUIResource;
|
import javax.swing.plaf.ColorUIResource;
|
||||||
import javax.swing.plaf.metal.MetalLookAndFeel;
|
import javax.swing.plaf.metal.MetalLookAndFeel;
|
||||||
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
|
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
|
||||||
@@ -34,6 +35,7 @@ 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.demo.LookAndFeelsComboBox;
|
||||||
import com.formdev.flatlaf.extras.*;
|
import com.formdev.flatlaf.extras.*;
|
||||||
import com.formdev.flatlaf.extras.TriStateCheckBox.State;
|
import com.formdev.flatlaf.extras.TriStateCheckBox.State;
|
||||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||||
@@ -93,12 +95,12 @@ public class FlatTestFrame
|
|||||||
initComponents();
|
initComponents();
|
||||||
|
|
||||||
// initialize look and feels combo box
|
// initialize look and feels combo box
|
||||||
DefaultComboBoxModel<LafInfo> lafModel = new DefaultComboBoxModel<>();
|
DefaultComboBoxModel<LookAndFeelInfo> lafModel = new DefaultComboBoxModel<>();
|
||||||
lafModel.addElement( new LafInfo( "Flat Light (F1)", FlatLightLaf.class.getName() ) );
|
lafModel.addElement( new LookAndFeelInfo( "Flat Light (F1)", FlatLightLaf.class.getName() ) );
|
||||||
lafModel.addElement( new LafInfo( "Flat Dark (F2)", FlatDarkLaf.class.getName() ) );
|
lafModel.addElement( new LookAndFeelInfo( "Flat Dark (F2)", FlatDarkLaf.class.getName() ) );
|
||||||
lafModel.addElement( new LafInfo( "Flat IntelliJ (F3)", FlatIntelliJLaf.class.getName() ) );
|
lafModel.addElement( new LookAndFeelInfo( "Flat IntelliJ (F3)", FlatIntelliJLaf.class.getName() ) );
|
||||||
lafModel.addElement( new LafInfo( "Flat Darcula (F4)", FlatDarculaLaf.class.getName() ) );
|
lafModel.addElement( new LookAndFeelInfo( "Flat Darcula (F4)", FlatDarculaLaf.class.getName() ) );
|
||||||
lafModel.addElement( new LafInfo( "Flat Test (F8)", FlatTestLaf.class.getName() ) );
|
lafModel.addElement( new LookAndFeelInfo( "Flat Test (F8)", FlatTestLaf.class.getName() ) );
|
||||||
|
|
||||||
UIManager.LookAndFeelInfo[] lookAndFeels = UIManager.getInstalledLookAndFeels();
|
UIManager.LookAndFeelInfo[] lookAndFeels = UIManager.getInstalledLookAndFeels();
|
||||||
for( UIManager.LookAndFeelInfo lookAndFeel : lookAndFeels ) {
|
for( UIManager.LookAndFeelInfo lookAndFeel : lookAndFeels ) {
|
||||||
@@ -117,19 +119,11 @@ public class FlatTestFrame
|
|||||||
else if( className.equals( NimbusLookAndFeel.class.getName() ) )
|
else if( className.equals( NimbusLookAndFeel.class.getName() ) )
|
||||||
name += " (F11)";
|
name += " (F11)";
|
||||||
|
|
||||||
lafModel.addElement( new LafInfo( name, className ) );
|
lafModel.addElement( new LookAndFeelInfo( name, className ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
LookAndFeel activeLaf = UIManager.getLookAndFeel();
|
|
||||||
String activeLafClassName = activeLaf.getClass().getName();
|
|
||||||
int sel = lafModel.getIndexOf( new LafInfo( null, activeLafClassName ) );
|
|
||||||
if( sel < 0 ) {
|
|
||||||
lafModel.addElement( new LafInfo( activeLaf.getName(), activeLafClassName ) );
|
|
||||||
sel = lafModel.getSize() - 1;
|
|
||||||
}
|
|
||||||
lafModel.setSelectedItem( lafModel.getElementAt( sel ) );
|
|
||||||
|
|
||||||
lookAndFeelComboBox.setModel( lafModel );
|
lookAndFeelComboBox.setModel( lafModel );
|
||||||
|
lookAndFeelComboBox.selectedLookAndFeel( UIManager.getLookAndFeel() );
|
||||||
|
|
||||||
updateScaleFactorComboBox();
|
updateScaleFactorComboBox();
|
||||||
String scaleFactor = System.getProperty( "flatlaf.uiScale", System.getProperty( "sun.java2d.uiScale" ) );
|
String scaleFactor = System.getProperty( "flatlaf.uiScale", System.getProperty( "sun.java2d.uiScale" ) );
|
||||||
@@ -230,26 +224,23 @@ public class FlatTestFrame
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void selectLookAndFeel( String lafClassName ) {
|
private void selectLookAndFeel( String lafClassName ) {
|
||||||
DefaultComboBoxModel<LafInfo> lafModel = (DefaultComboBoxModel<LafInfo>) lookAndFeelComboBox.getModel();
|
lookAndFeelComboBox.setSelectedLookAndFeel( lafClassName );
|
||||||
int sel = lafModel.getIndexOf( new LafInfo( null, lafClassName ) );
|
|
||||||
if( sel >= 0 )
|
|
||||||
lookAndFeelComboBox.setSelectedIndex( sel );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void lookAndFeelChanged() {
|
private void lookAndFeelChanged() {
|
||||||
LafInfo newLaf = (LafInfo) lookAndFeelComboBox.getSelectedItem();
|
String lafClassName = lookAndFeelComboBox.getSelectedLookAndFeel();
|
||||||
if( newLaf == null )
|
if( lafClassName == null )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( newLaf.className.equals( UIManager.getLookAndFeel().getClass().getName() ) )
|
if( lafClassName.equals( UIManager.getLookAndFeel().getClass().getName() ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// hide popup to avoid occasional StackOverflowError when updating UI
|
// hide popup to avoid occasional StackOverflowError when updating UI
|
||||||
lookAndFeelComboBox.setPopupVisible( false );
|
lookAndFeelComboBox.setPopupVisible( false );
|
||||||
|
|
||||||
Preferences.userRoot().node( PREFS_ROOT_PATH ).put( KEY_LAF, newLaf.className );
|
Preferences.userRoot().node( PREFS_ROOT_PATH ).put( KEY_LAF, lafClassName );
|
||||||
|
|
||||||
applyLookAndFeel( newLaf.className, false );
|
applyLookAndFeel( lafClassName, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyLookAndFeel( String lafClassName, boolean pack ) {
|
private void applyLookAndFeel( String lafClassName, boolean pack ) {
|
||||||
@@ -442,7 +433,7 @@ public class FlatTestFrame
|
|||||||
dialogPane = new JPanel();
|
dialogPane = new JPanel();
|
||||||
contentPanel = new JRootPane();
|
contentPanel = new JRootPane();
|
||||||
buttonBar = new JPanel();
|
buttonBar = new JPanel();
|
||||||
lookAndFeelComboBox = new JComboBox<>();
|
lookAndFeelComboBox = new LookAndFeelsComboBox();
|
||||||
scaleFactorComboBox = new JComboBox<>();
|
scaleFactorComboBox = new JComboBox<>();
|
||||||
rightToLeftCheckBox = new JCheckBox();
|
rightToLeftCheckBox = new JCheckBox();
|
||||||
enabledCheckBox = new JCheckBox();
|
enabledCheckBox = new JCheckBox();
|
||||||
@@ -564,7 +555,7 @@ public class FlatTestFrame
|
|||||||
private JPanel dialogPane;
|
private JPanel dialogPane;
|
||||||
private JRootPane contentPanel;
|
private JRootPane contentPanel;
|
||||||
private JPanel buttonBar;
|
private JPanel buttonBar;
|
||||||
private JComboBox<LafInfo> lookAndFeelComboBox;
|
private LookAndFeelsComboBox lookAndFeelComboBox;
|
||||||
private JComboBox<String> scaleFactorComboBox;
|
private JComboBox<String> scaleFactorComboBox;
|
||||||
private JCheckBox rightToLeftCheckBox;
|
private JCheckBox rightToLeftCheckBox;
|
||||||
private JCheckBox enabledCheckBox;
|
private JCheckBox enabledCheckBox;
|
||||||
@@ -574,27 +565,4 @@ public class FlatTestFrame
|
|||||||
private TriStateCheckBox opaqueTriStateCheckBox;
|
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
|
||||||
|
|
||||||
//---- class LafInfo ------------------------------------------------------
|
|
||||||
|
|
||||||
static class LafInfo
|
|
||||||
{
|
|
||||||
final String name;
|
|
||||||
final String className;
|
|
||||||
|
|
||||||
LafInfo( String name, String className ) {
|
|
||||||
this.name = name;
|
|
||||||
this.className = className;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals( Object obj ) {
|
|
||||||
return obj instanceof LafInfo && className.equals( ((LafInfo)obj).className );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,11 +25,8 @@ new FormModel {
|
|||||||
"$rowSpecs": "[fill]"
|
"$rowSpecs": "[fill]"
|
||||||
} ) {
|
} ) {
|
||||||
name: "buttonBar"
|
name: "buttonBar"
|
||||||
add( new FormComponent( "javax.swing.JComboBox" ) {
|
add( new FormComponent( "com.formdev.flatlaf.demo.LookAndFeelsComboBox" ) {
|
||||||
name: "lookAndFeelComboBox"
|
name: "lookAndFeelComboBox"
|
||||||
auxiliary() {
|
|
||||||
"JavaCodeGenerator.typeParameters": "LafInfo"
|
|
||||||
}
|
|
||||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "lookAndFeelChanged", false ) )
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "lookAndFeelChanged", false ) )
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 0"
|
"value": "cell 0 0"
|
||||||
|
|||||||
Reference in New Issue
Block a user