moved testing applications from src/test to new project flatlaf-testing (part 1)

This commit is contained in:
Karl Tauber
2019-10-23 16:00:40 +02:00
parent 6438e890bb
commit 62895a602f
20 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,126 @@
/*
* 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;
import javax.swing.*;
import net.miginfocom.swing.*;
/**
* @author Karl Tauber
*/
public class FlatChooserTest
extends JPanel
{
public static void main( String[] args ) {
SwingUtilities.invokeLater( () -> {
FlatTestFrame frame = FlatTestFrame.create( args, "FlatChooserTest" );
frame.showFrame( new FlatChooserTest() );
} );
}
FlatChooserTest() {
initComponents();
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JLabel colorChooserLabel = new JLabel();
JColorChooser colorChooser1 = new JColorChooser();
JLabel fileChooserLabel = new JLabel();
JFileChooser fileChooser1 = new JFileChooser();
JLabel label1 = new JLabel();
JLabel label2 = new JLabel();
JLabel label3 = new JLabel();
JLabel label4 = new JLabel();
JLabel label5 = new JLabel();
JLabel label6 = new JLabel();
JLabel label7 = new JLabel();
JLabel label8 = new JLabel();
JLabel label9 = new JLabel();
JLabel label10 = new JLabel();
JLabel label11 = new JLabel();
//======== this ========
setLayout(new MigLayout(
"insets 0,hidemode 3,gap 5 5,ltr",
// columns
"[]" +
"[]",
// rows
"[top]" +
"[top]" +
"[]"));
//---- colorChooserLabel ----
colorChooserLabel.setText("JColorChooser:");
add(colorChooserLabel, "cell 0 0");
add(colorChooser1, "cell 1 0");
//---- fileChooserLabel ----
fileChooserLabel.setText("JFileChooser:");
add(fileChooserLabel, "cell 0 1");
add(fileChooser1, "cell 1 1");
//---- label1 ----
label1.setText("icons:");
add(label1, "cell 0 2");
//---- label2 ----
label2.setIcon(UIManager.getIcon("FileView.directoryIcon"));
add(label2, "cell 1 2");
//---- label3 ----
label3.setIcon(UIManager.getIcon("FileView.fileIcon"));
add(label3, "cell 1 2");
//---- label4 ----
label4.setIcon(UIManager.getIcon("FileView.computerIcon"));
add(label4, "cell 1 2");
//---- label5 ----
label5.setIcon(UIManager.getIcon("FileView.hardDriveIcon"));
add(label5, "cell 1 2");
//---- label6 ----
label6.setIcon(UIManager.getIcon("FileView.floppyDriveIcon"));
add(label6, "cell 1 2");
//---- label7 ----
label7.setIcon(UIManager.getIcon("FileChooser.newFolderIcon"));
add(label7, "cell 1 2");
//---- label8 ----
label8.setIcon(UIManager.getIcon("FileChooser.upFolderIcon"));
add(label8, "cell 1 2");
//---- label9 ----
label9.setIcon(UIManager.getIcon("FileChooser.homeFolderIcon"));
add(label9, "cell 1 2");
//---- label10 ----
label10.setIcon(UIManager.getIcon("FileChooser.detailsViewIcon"));
add(label10, "cell 1 2");
//---- label11 ----
label11.setIcon(UIManager.getIcon("FileChooser.listViewIcon"));
add(label11, "cell 1 2");
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
// JFormDesigner - End of variables declaration //GEN-END:variables
}

View File

@@ -0,0 +1,108 @@
JFDML JFormDesigner: "7.0.0.0.194" Java: "11.0.2" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
root: new FormRoot {
auxiliary() {
"JavaCodeGenerator.defaultVariableLocal": true
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 0,hidemode 3,gap 5 5,ltr"
"$columnConstraints": "[][]"
"$rowConstraints": "[top][top][]"
} ) {
name: "this"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "colorChooserLabel"
"text": "JColorChooser:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JColorChooser" ) {
name: "colorChooser1"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "fileChooserLabel"
"text": "JFileChooser:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "javax.swing.JFileChooser" ) {
name: "fileChooser1"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label1"
"text": "icons:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label2"
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileView.directoryIcon" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label3"
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileView.fileIcon" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label4"
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileView.computerIcon" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label5"
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileView.hardDriveIcon" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label6"
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileView.floppyDriveIcon" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label7"
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileChooser.newFolderIcon" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label8"
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileChooser.upFolderIcon" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label9"
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileChooser.homeFolderIcon" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label10"
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileChooser.detailsViewIcon" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label11"
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileChooser.listViewIcon" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 790, 715 )
} )
}
}

View File

@@ -0,0 +1,251 @@
/*
* 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;
import javax.swing.*;
import javax.swing.table.*;
import net.miginfocom.swing.*;
/**
* @author Karl Tauber
*/
public class FlatComponents2Test
extends JPanel
{
public static void main( String[] args ) {
SwingUtilities.invokeLater( () -> {
FlatTestFrame frame = FlatTestFrame.create( args, "FlatComponents2Test" );
frame.showFrame( new FlatComponents2Test() );
} );
}
FlatComponents2Test() {
initComponents();
}
@SuppressWarnings( { "unchecked", "rawtypes" } )
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JLabel labelLabel = new JLabel();
JLabel label1 = new JLabel();
JLabel label2 = new JLabel();
JLabel textFieldLabel = new JLabel();
JTextField textField1 = new JTextField();
JTextField textField2 = new JTextField();
JLabel listLabel = new JLabel();
JScrollPane scrollPane1 = new JScrollPane();
JList<String> list1 = new JList<>();
JScrollPane scrollPane2 = new JScrollPane();
JList<String> list2 = new JList<>();
JLabel treeLabel = new JLabel();
JScrollPane scrollPane3 = new JScrollPane();
JTree tree1 = new JTree();
JScrollPane scrollPane4 = new JScrollPane();
JTree tree2 = new JTree();
JLabel tableLabel = new JLabel();
JScrollPane scrollPane5 = new JScrollPane();
JTable table1 = new JTable();
//======== this ========
setLayout(new MigLayout(
"insets 0,hidemode 3,gap 5 5,ltr",
// columns
"[]" +
"[200]" +
"[200]",
// rows
"[]" +
"[]" +
"[]" +
"[::200]" +
"[::150]"));
//---- labelLabel ----
labelLabel.setText("JLabel:");
add(labelLabel, "cell 0 0");
//---- label1 ----
label1.setText("enabled");
label1.setDisplayedMnemonic('E');
add(label1, "cell 1 0");
//---- label2 ----
label2.setText("disabled");
label2.setDisplayedMnemonic('D');
label2.setEnabled(false);
add(label2, "cell 2 0");
//---- textFieldLabel ----
textFieldLabel.setText("JTextField:");
add(textFieldLabel, "cell 0 1");
//---- textField1 ----
textField1.setText("editable");
add(textField1, "cell 1 1,growx");
//---- textField2 ----
textField2.setText("disabled");
textField2.setEnabled(false);
add(textField2, "cell 2 1,growx");
//---- listLabel ----
listLabel.setText("JList:");
add(listLabel, "cell 0 2");
//======== scrollPane1 ========
{
scrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
scrollPane1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
//---- list1 ----
list1.setModel(new AbstractListModel<String>() {
String[] values = {
"abc",
"de",
"f"
};
@Override
public int getSize() { return values.length; }
@Override
public String getElementAt(int i) { return values[i]; }
});
scrollPane1.setViewportView(list1);
}
add(scrollPane1, "cell 1 2,growx");
//======== scrollPane2 ========
{
scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
//---- list2 ----
list2.setModel(new AbstractListModel<String>() {
String[] values = {
"abc",
"de",
"f"
};
@Override
public int getSize() { return values.length; }
@Override
public String getElementAt(int i) { return values[i]; }
});
list2.setEnabled(false);
scrollPane2.setViewportView(list2);
}
add(scrollPane2, "cell 2 2,growx");
//---- treeLabel ----
treeLabel.setText("JTree:");
add(treeLabel, "cell 0 3");
//======== scrollPane3 ========
{
//---- tree1 ----
tree1.setShowsRootHandles(true);
tree1.setEditable(true);
scrollPane3.setViewportView(tree1);
}
add(scrollPane3, "cell 1 3,growx");
//======== scrollPane4 ========
{
//---- tree2 ----
tree2.setEnabled(false);
scrollPane4.setViewportView(tree2);
}
add(scrollPane4, "cell 2 3,growx");
//---- tableLabel ----
tableLabel.setText("JTable:");
add(tableLabel, "cell 0 4");
//======== scrollPane5 ========
{
//---- table1 ----
table1.setModel(new DefaultTableModel(
new Object[][] {
{"Item 1a", "Item 2a", "January", "July", 123, null},
{"Item 1b", "Item 2b", "February", "August", 456, true},
},
new String[] {
"Not editable", "Text", "Combo", "Combo Editable", "Integer", "Boolean"
}
) {
Class<?>[] columnTypes = new Class<?>[] {
Object.class, Object.class, String.class, String.class, Integer.class, Boolean.class
};
boolean[] columnEditable = new boolean[] {
false, true, true, true, true, true
};
@Override
public Class<?> getColumnClass(int columnIndex) {
return columnTypes[columnIndex];
}
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return columnEditable[columnIndex];
}
});
{
TableColumnModel cm = table1.getColumnModel();
cm.getColumn(2).setCellEditor(new DefaultCellEditor(
new JComboBox(new DefaultComboBoxModel(new String[] {
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
}))));
cm.getColumn(3).setCellEditor(new DefaultCellEditor(
new JComboBox(new DefaultComboBoxModel(new String[] {
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
}))));
}
table1.setAutoCreateRowSorter(true);
scrollPane5.setViewportView(table1);
}
add(scrollPane5, "cell 1 4 2 1,growx,width 300");
// JFormDesigner - End of component initialization //GEN-END:initComponents
((JComboBox)((DefaultCellEditor)table1.getColumnModel().getColumn( 3 ).getCellEditor()).getComponent()).setEditable( true );
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
// JFormDesigner - End of variables declaration //GEN-END:variables
}

View File

@@ -0,0 +1,185 @@
JFDML JFormDesigner: "7.0.0.0.194" Java: "11.0.2" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
root: new FormRoot {
auxiliary() {
"JavaCodeGenerator.defaultVariableLocal": true
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 0,hidemode 3,gap 5 5,ltr"
"$columnConstraints": "[][200][200]"
"$rowConstraints": "[][][][::200][::150]"
} ) {
name: "this"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "labelLabel"
"text": "JLabel:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label1"
"text": "enabled"
"displayedMnemonic": 69
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label2"
"text": "disabled"
"displayedMnemonic": 68
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "textFieldLabel"
"text": "JTextField:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField1"
"text": "editable"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1,growx"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField2"
"text": "disabled"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 1,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "listLabel"
"text": "JList:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane1"
"verticalScrollBarPolicy": 21
"horizontalScrollBarPolicy": 31
add( new FormComponent( "javax.swing.JList" ) {
name: "list1"
"model": &DefaultListModel0 new javax.swing.DefaultListModel {
addElement( "abc" )
addElement( "de" )
addElement( "f" )
}
auxiliary() {
"JavaCodeGenerator.typeParameters": "String"
}
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2,growx"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane2"
"verticalScrollBarPolicy": 21
"horizontalScrollBarPolicy": 31
add( new FormComponent( "javax.swing.JList" ) {
name: "list2"
"model": #DefaultListModel0
"enabled": false
auxiliary() {
"JavaCodeGenerator.typeParameters": "String"
}
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 2,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "treeLabel"
"text": "JTree:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane3"
add( new FormComponent( "javax.swing.JTree" ) {
name: "tree1"
"showsRootHandles": true
"editable": true
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3,growx"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane4"
add( new FormComponent( "javax.swing.JTree" ) {
name: "tree2"
"enabled": false
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 3,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "tableLabel"
"text": "JTable:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane5"
add( new FormComponent( "javax.swing.JTable" ) {
name: "table1"
"model": new com.jformdesigner.model.SwingTableModel( new java.util.Vector {
add( new java.util.Vector {
add( "Item 1a" )
add( "Item 2a" )
add( "January" )
add( "July" )
add( 123 )
add( null )
} )
add( new java.util.Vector {
add( "Item 1b" )
add( "Item 2b" )
add( "February" )
add( "August" )
add( 456 )
add( true )
} )
}, new java.util.Vector {
add( "Not editable" )
add( "Text" )
add( "Combo" )
add( "Combo Editable" )
add( "Integer" )
add( "Boolean" )
}, new java.util.Vector {
add( null )
add( null )
add( class java.lang.String )
add( class java.lang.String )
add( class java.lang.Integer )
add( class java.lang.Boolean )
}, new java.util.Vector {
add( false )
add( null )
add( null )
add( null )
add( null )
add( null )
}, new java.util.Vector {
add( null )
add( null )
add( new com.jformdesigner.model.SwingTableColumn( new java.lang.Object[ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], 0, 0, 0, true ) )
add( new com.jformdesigner.model.SwingTableColumn( new java.lang.Object[ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], 0, 0, 0, true ) )
add( null )
add( null )
} )
"autoCreateRowSorter": true
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4 2 1,growx,width 300"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 790, 715 )
} )
}
}

View File

@@ -0,0 +1,927 @@
/*
* 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;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import net.miginfocom.swing.*;
/**
* @author Karl Tauber
*/
public class FlatComponentsTest
extends JPanel
{
public static void main( String[] args ) {
SwingUtilities.invokeLater( () -> {
FlatTestFrame frame = FlatTestFrame.create( args, "FlatComponentsTest" );
frame.showFrame( new FlatComponentsTest() );
} );
}
FlatComponentsTest() {
initComponents();
}
private void indeterminateCheckBoxActionPerformed() {
boolean indeterminate = indeterminateCheckBox.isSelected();
progressBar1.setIndeterminate( indeterminate );
progressBar2.setIndeterminate( indeterminate );
progressBar3.setIndeterminate( indeterminate );
progressBar4.setIndeterminate( indeterminate );
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JLabel labelLabel = new JLabel();
JLabel label1 = new JLabel();
JLabel label2 = new JLabel();
JLabel buttonLabel = new JLabel();
JButton button1 = new JButton();
JButton button2 = new JButton();
FlatComponentsTest.TestDefaultButton button5 = new FlatComponentsTest.TestDefaultButton();
JButton button3 = new JButton();
JButton button12 = new JButton();
JButton button13 = new JButton();
JLabel toggleButtonLabel = new JLabel();
JToggleButton toggleButton1 = new JToggleButton();
JToggleButton toggleButton2 = new JToggleButton();
JToggleButton toggleButton3 = new JToggleButton();
JToggleButton toggleButton4 = new JToggleButton();
JLabel checkBoxLabel = new JLabel();
JCheckBox checkBox1 = new JCheckBox();
JCheckBox checkBox2 = new JCheckBox();
JCheckBox checkBox3 = new JCheckBox();
JCheckBox checkBox4 = new JCheckBox();
JLabel radioButtonLabel = new JLabel();
JRadioButton radioButton1 = new JRadioButton();
JRadioButton radioButton2 = new JRadioButton();
JRadioButton radioButton3 = new JRadioButton();
JRadioButton radioButton4 = new JRadioButton();
JLabel comboBoxLabel = new JLabel();
JComboBox<String> comboBox1 = new JComboBox<>();
JComboBox<String> comboBox2 = new JComboBox<>();
JComboBox<String> comboBox3 = new JComboBox<>();
JComboBox<String> comboBox4 = new JComboBox<>();
JComboBox<String> comboBox5 = new JComboBox<>();
JLabel spinnerLabel = new JLabel();
JSpinner spinner1 = new JSpinner();
JSpinner spinner2 = new JSpinner();
JLabel textFieldLabel = new JLabel();
JTextField textField1 = new JTextField();
JTextField textField2 = new JTextField();
JTextField textField3 = new JTextField();
JTextField textField4 = new JTextField();
JLabel formattedTextFieldLabel = new JLabel();
JFormattedTextField formattedTextField1 = new JFormattedTextField();
JFormattedTextField formattedTextField2 = new JFormattedTextField();
JFormattedTextField formattedTextField3 = new JFormattedTextField();
JFormattedTextField formattedTextField4 = new JFormattedTextField();
JLabel passwordFieldLabel = new JLabel();
JPasswordField passwordField1 = new JPasswordField();
JPasswordField passwordField2 = new JPasswordField();
JPasswordField passwordField3 = new JPasswordField();
JPasswordField passwordField4 = new JPasswordField();
JLabel textAreaLabel = new JLabel();
JScrollPane scrollPane1 = new JScrollPane();
JTextArea textArea1 = new JTextArea();
JScrollPane scrollPane2 = new JScrollPane();
JTextArea textArea2 = new JTextArea();
JScrollPane scrollPane3 = new JScrollPane();
JTextArea textArea3 = new JTextArea();
JScrollPane scrollPane4 = new JScrollPane();
JTextArea textArea4 = new JTextArea();
JTextArea textArea5 = new JTextArea();
JLabel editorPaneLabel = new JLabel();
JScrollPane scrollPane5 = new JScrollPane();
JEditorPane editorPane1 = new JEditorPane();
JScrollPane scrollPane6 = new JScrollPane();
JEditorPane editorPane2 = new JEditorPane();
JScrollPane scrollPane7 = new JScrollPane();
JEditorPane editorPane3 = new JEditorPane();
JScrollPane scrollPane8 = new JScrollPane();
JEditorPane editorPane4 = new JEditorPane();
JEditorPane editorPane5 = new JEditorPane();
JLabel textPaneLabel = new JLabel();
JScrollPane scrollPane9 = new JScrollPane();
JTextPane textPane1 = new JTextPane();
JScrollPane scrollPane10 = new JScrollPane();
JTextPane textPane2 = new JTextPane();
JScrollPane scrollPane11 = new JScrollPane();
JTextPane textPane3 = new JTextPane();
JScrollPane scrollPane12 = new JScrollPane();
JTextPane textPane4 = new JTextPane();
JTextPane textPane5 = new JTextPane();
JLabel scrollPaneLabel = new JLabel();
JScrollPane scrollPane13 = new JScrollPane();
JPanel panel1 = new JPanel();
JScrollBar scrollBar2 = new JScrollBar();
JScrollBar scrollBar3 = new JScrollBar();
JSeparator separator2 = new JSeparator();
JSlider slider2 = new JSlider();
JSlider slider4 = new JSlider();
JScrollPane scrollPane14 = new JScrollPane();
progressBar3 = new JProgressBar();
progressBar4 = new JProgressBar();
JToolBar toolBar2 = new JToolBar();
JButton button9 = new JButton();
JButton button10 = new JButton();
JButton button11 = new JButton();
JToggleButton toggleButton7 = new JToggleButton();
JLabel scrollBarLabel = new JLabel();
JScrollBar scrollBar1 = new JScrollBar();
JLabel label4 = new JLabel();
JScrollBar scrollBar4 = new JScrollBar();
JPanel panel3 = new JPanel();
JLabel label3 = new JLabel();
JScrollPane scrollPane15 = new JScrollPane();
JEditorPane editorPane6 = new JEditorPane();
JScrollPane scrollPane16 = new JScrollPane();
JTextPane textPane6 = new JTextPane();
JLabel separatorLabel = new JLabel();
JSeparator separator1 = new JSeparator();
JPanel panel2 = new JPanel();
JLabel sliderLabel = new JLabel();
JSlider slider1 = new JSlider();
JSlider slider6 = new JSlider();
JSlider slider3 = new JSlider();
JSlider slider5 = new JSlider();
JLabel progressBarLabel = new JLabel();
progressBar1 = new JProgressBar();
progressBar2 = new JProgressBar();
indeterminateCheckBox = new JCheckBox();
JLabel toolTipLabel = new JLabel();
JToolTip toolTip1 = new JToolTip();
JToolTip toolTip2 = new JToolTip();
JLabel toolBarLabel = new JLabel();
JToolBar toolBar1 = new JToolBar();
JButton button4 = new JButton();
JButton button6 = new JButton();
JButton button7 = new JButton();
JButton button8 = new JButton();
JToggleButton toggleButton6 = new JToggleButton();
//======== this ========
setLayout(new MigLayout(
"insets 0,hidemode 3,gap 5 5,ltr",
// columns
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]",
// rows
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]"));
//---- labelLabel ----
labelLabel.setText("JLabel:");
add(labelLabel, "cell 0 0");
//---- label1 ----
label1.setText("enabled");
label1.setDisplayedMnemonic('E');
add(label1, "cell 1 0");
//---- label2 ----
label2.setText("disabled");
label2.setDisplayedMnemonic('D');
label2.setEnabled(false);
add(label2, "cell 2 0");
//---- buttonLabel ----
buttonLabel.setText("JButton:");
add(buttonLabel, "cell 0 1");
//---- button1 ----
button1.setText("enabled");
button1.setDisplayedMnemonicIndex(0);
button1.setToolTipText("This button is enabled.");
add(button1, "cell 1 1");
//---- button2 ----
button2.setText("disabled");
button2.setDisplayedMnemonicIndex(0);
button2.setEnabled(false);
button2.setToolTipText("This button is disabled.");
add(button2, "cell 2 1");
//---- button5 ----
button5.setText("default");
button5.setDisplayedMnemonicIndex(0);
button5.setToolTipText("Tool tip with\nmultiple\nlines.");
add(button5, "cell 3 1");
//---- button3 ----
button3.setText("Help");
button3.putClientProperty("JButton.buttonType", "help");
add(button3, "cell 4 1");
//---- button12 ----
button12.setText("Help");
button12.putClientProperty("JButton.buttonType", "help");
button12.setEnabled(false);
add(button12, "cell 4 1");
//---- button13 ----
button13.setIcon(UIManager.getIcon("Tree.closedIcon"));
add(button13, "cell 5 1");
//---- toggleButtonLabel ----
toggleButtonLabel.setText("JToggleButton:");
add(toggleButtonLabel, "cell 0 2");
//---- toggleButton1 ----
toggleButton1.setText("enabled");
add(toggleButton1, "cell 1 2");
//---- toggleButton2 ----
toggleButton2.setText("disabled");
toggleButton2.setEnabled(false);
add(toggleButton2, "cell 2 2");
//---- toggleButton3 ----
toggleButton3.setText("selected");
toggleButton3.setSelected(true);
add(toggleButton3, "cell 3 2");
//---- toggleButton4 ----
toggleButton4.setText("selected disabled");
toggleButton4.setEnabled(false);
toggleButton4.setSelected(true);
add(toggleButton4, "cell 4 2");
//---- checkBoxLabel ----
checkBoxLabel.setText("JCheckBox");
add(checkBoxLabel, "cell 0 3");
//---- checkBox1 ----
checkBox1.setText("enabled");
checkBox1.setMnemonic('A');
add(checkBox1, "cell 1 3");
//---- checkBox2 ----
checkBox2.setText("disabled");
checkBox2.setEnabled(false);
checkBox2.setMnemonic('D');
add(checkBox2, "cell 2 3");
//---- checkBox3 ----
checkBox3.setText("selected");
checkBox3.setSelected(true);
add(checkBox3, "cell 3 3");
//---- checkBox4 ----
checkBox4.setText("selected disabled");
checkBox4.setSelected(true);
checkBox4.setEnabled(false);
add(checkBox4, "cell 4 3");
//---- radioButtonLabel ----
radioButtonLabel.setText("JRadioButton:");
add(radioButtonLabel, "cell 0 4");
//---- radioButton1 ----
radioButton1.setText("enabled");
radioButton1.setMnemonic('N');
add(radioButton1, "cell 1 4");
//---- radioButton2 ----
radioButton2.setText("disabled");
radioButton2.setEnabled(false);
radioButton2.setMnemonic('S');
add(radioButton2, "cell 2 4");
//---- radioButton3 ----
radioButton3.setText("selected");
radioButton3.setSelected(true);
add(radioButton3, "cell 3 4");
//---- radioButton4 ----
radioButton4.setText("selected disabled");
radioButton4.setSelected(true);
radioButton4.setEnabled(false);
add(radioButton4, "cell 4 4");
//---- comboBoxLabel ----
comboBoxLabel.setText("JComboBox:");
add(comboBoxLabel, "cell 0 5");
//---- comboBox1 ----
comboBox1.setEditable(true);
comboBox1.setModel(new DefaultComboBoxModel<>(new String[] {
"editable",
"a",
"bb",
"ccc",
"dd",
"e",
"ff",
"ggg",
"hh",
"i",
"jj",
"kkk"
}));
add(comboBox1, "cell 1 5,growx");
//---- comboBox2 ----
comboBox2.setEditable(true);
comboBox2.setEnabled(false);
comboBox2.setModel(new DefaultComboBoxModel<>(new String[] {
"disabled",
"a",
"bb",
"ccc"
}));
add(comboBox2, "cell 2 5,growx");
//---- comboBox3 ----
comboBox3.setModel(new DefaultComboBoxModel<>(new String[] {
"not editable",
"a",
"bb",
"ccc",
"dd",
"e",
"ff",
"ggg",
"hh",
"i",
"jj",
"kkk"
}));
add(comboBox3, "cell 3 5,growx");
//---- comboBox4 ----
comboBox4.setModel(new DefaultComboBoxModel<>(new String[] {
"not editable disabled",
"a",
"bb",
"ccc"
}));
comboBox4.setEnabled(false);
add(comboBox4, "cell 4 5,growx");
//---- comboBox5 ----
comboBox5.setPrototypeDisplayValue("12345");
comboBox5.setModel(new DefaultComboBoxModel<>(new String[] {
"wide popup if text is longer",
"aa",
"bbb",
"cccc"
}));
add(comboBox5, "cell 5 5,growx");
//---- spinnerLabel ----
spinnerLabel.setText("JSpinner:");
add(spinnerLabel, "cell 0 6");
add(spinner1, "cell 1 6,growx");
//---- spinner2 ----
spinner2.setEnabled(false);
add(spinner2, "cell 2 6,growx");
//---- textFieldLabel ----
textFieldLabel.setText("JTextField:");
add(textFieldLabel, "cell 0 7");
//---- textField1 ----
textField1.setText("editable");
add(textField1, "cell 1 7,growx");
//---- textField2 ----
textField2.setText("disabled");
textField2.setEnabled(false);
add(textField2, "cell 2 7,growx");
//---- textField3 ----
textField3.setText("not editable");
textField3.setEditable(false);
add(textField3, "cell 3 7,growx");
//---- textField4 ----
textField4.setText("not editable disabled");
textField4.setEnabled(false);
textField4.setEditable(false);
add(textField4, "cell 4 7,growx");
//---- formattedTextFieldLabel ----
formattedTextFieldLabel.setText("JFormattedTextField:");
add(formattedTextFieldLabel, "cell 0 8");
//---- formattedTextField1 ----
formattedTextField1.setText("editable");
add(formattedTextField1, "cell 1 8,growx");
//---- formattedTextField2 ----
formattedTextField2.setText("disabled");
formattedTextField2.setEnabled(false);
add(formattedTextField2, "cell 2 8,growx");
//---- formattedTextField3 ----
formattedTextField3.setText("not editable");
formattedTextField3.setEditable(false);
add(formattedTextField3, "cell 3 8,growx");
//---- formattedTextField4 ----
formattedTextField4.setText("not editable disabled");
formattedTextField4.setEnabled(false);
formattedTextField4.setEditable(false);
add(formattedTextField4, "cell 4 8,growx");
//---- passwordFieldLabel ----
passwordFieldLabel.setText("JPasswordField:");
add(passwordFieldLabel, "cell 0 9");
//---- passwordField1 ----
passwordField1.setText("editable");
add(passwordField1, "cell 1 9,growx");
//---- passwordField2 ----
passwordField2.setText("disabled");
passwordField2.setEnabled(false);
add(passwordField2, "cell 2 9,growx");
//---- passwordField3 ----
passwordField3.setText("not editable");
passwordField3.setEditable(false);
add(passwordField3, "cell 3 9,growx");
//---- passwordField4 ----
passwordField4.setText("not editable disabled");
passwordField4.setEnabled(false);
passwordField4.setEditable(false);
add(passwordField4, "cell 4 9,growx");
//---- textAreaLabel ----
textAreaLabel.setText("JTextArea:");
add(textAreaLabel, "cell 0 10");
//======== scrollPane1 ========
{
scrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
scrollPane1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
//---- textArea1 ----
textArea1.setText("editable");
textArea1.setRows(2);
scrollPane1.setViewportView(textArea1);
}
add(scrollPane1, "cell 1 10,growx");
//======== scrollPane2 ========
{
scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
//---- textArea2 ----
textArea2.setText("disabled");
textArea2.setRows(2);
textArea2.setEnabled(false);
scrollPane2.setViewportView(textArea2);
}
add(scrollPane2, "cell 2 10,growx");
//======== scrollPane3 ========
{
scrollPane3.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
scrollPane3.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
//---- textArea3 ----
textArea3.setText("not editable");
textArea3.setRows(2);
textArea3.setEditable(false);
scrollPane3.setViewportView(textArea3);
}
add(scrollPane3, "cell 3 10,growx");
//======== scrollPane4 ========
{
scrollPane4.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
scrollPane4.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
//---- textArea4 ----
textArea4.setText("not editable disabled");
textArea4.setRows(2);
textArea4.setEditable(false);
textArea4.setEnabled(false);
scrollPane4.setViewportView(textArea4);
}
add(scrollPane4, "cell 4 10,growx");
//---- textArea5 ----
textArea5.setRows(2);
textArea5.setText("no scroll pane");
add(textArea5, "cell 5 10,growx");
//---- editorPaneLabel ----
editorPaneLabel.setText("JEditorPane");
add(editorPaneLabel, "cell 0 11");
//======== scrollPane5 ========
{
scrollPane5.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
scrollPane5.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
//---- editorPane1 ----
editorPane1.setText("editable");
scrollPane5.setViewportView(editorPane1);
}
add(scrollPane5, "cell 1 11,growx");
//======== scrollPane6 ========
{
scrollPane6.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
scrollPane6.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
//---- editorPane2 ----
editorPane2.setText("disabled");
editorPane2.setEnabled(false);
scrollPane6.setViewportView(editorPane2);
}
add(scrollPane6, "cell 2 11,growx");
//======== scrollPane7 ========
{
scrollPane7.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
scrollPane7.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
//---- editorPane3 ----
editorPane3.setText("not editable");
editorPane3.setEditable(false);
scrollPane7.setViewportView(editorPane3);
}
add(scrollPane7, "cell 3 11,growx");
//======== scrollPane8 ========
{
scrollPane8.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
scrollPane8.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
//---- editorPane4 ----
editorPane4.setText("not editable disabled");
editorPane4.setEditable(false);
editorPane4.setEnabled(false);
scrollPane8.setViewportView(editorPane4);
}
add(scrollPane8, "cell 4 11,growx");
//---- editorPane5 ----
editorPane5.setText("no scroll pane");
add(editorPane5, "cell 5 11,growx");
//---- textPaneLabel ----
textPaneLabel.setText("JTextPane:");
add(textPaneLabel, "cell 0 12");
//======== scrollPane9 ========
{
scrollPane9.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
scrollPane9.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
//---- textPane1 ----
textPane1.setText("editable");
scrollPane9.setViewportView(textPane1);
}
add(scrollPane9, "cell 1 12,growx");
//======== scrollPane10 ========
{
scrollPane10.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
scrollPane10.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
//---- textPane2 ----
textPane2.setText("disabled");
textPane2.setEnabled(false);
scrollPane10.setViewportView(textPane2);
}
add(scrollPane10, "cell 2 12,growx");
//======== scrollPane11 ========
{
scrollPane11.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
scrollPane11.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
//---- textPane3 ----
textPane3.setText("not editable");
textPane3.setEditable(false);
scrollPane11.setViewportView(textPane3);
}
add(scrollPane11, "cell 3 12,growx");
//======== scrollPane12 ========
{
scrollPane12.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
scrollPane12.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
//---- textPane4 ----
textPane4.setText("not editable disabled");
textPane4.setEditable(false);
textPane4.setEnabled(false);
scrollPane12.setViewportView(textPane4);
}
add(scrollPane12, "cell 4 12,growx");
//---- textPane5 ----
textPane5.setText("no scroll pane");
add(textPane5, "cell 5 12,growx");
//---- scrollPaneLabel ----
scrollPaneLabel.setText("JScrollPane:");
add(scrollPaneLabel, "cell 0 13");
//======== scrollPane13 ========
{
scrollPane13.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollPane13.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
//======== panel1 ========
{
panel1.setPreferredSize(new Dimension(200, 200));
panel1.setLayout(new BorderLayout());
}
scrollPane13.setViewportView(panel1);
}
add(scrollPane13, "cell 1 13,grow,width 70,height 70");
add(scrollBar2, "cell 2 13 1 4,growy");
//---- scrollBar3 ----
scrollBar3.setEnabled(false);
add(scrollBar3, "cell 2 13 1 4,growy");
//---- separator2 ----
separator2.setOrientation(SwingConstants.VERTICAL);
add(separator2, "cell 2 13 1 4,growy");
//---- slider2 ----
slider2.setOrientation(SwingConstants.VERTICAL);
slider2.setValue(30);
add(slider2, "cell 2 13 1 4,growy");
//---- slider4 ----
slider4.setMinorTickSpacing(10);
slider4.setPaintTicks(true);
slider4.setMajorTickSpacing(50);
slider4.setPaintLabels(true);
slider4.setOrientation(SwingConstants.VERTICAL);
slider4.setValue(30);
add(slider4, "cell 2 13 1 4,growy");
add(scrollPane14, "cell 3 13,grow");
//---- progressBar3 ----
progressBar3.setOrientation(SwingConstants.VERTICAL);
progressBar3.setValue(50);
add(progressBar3, "cell 4 13 1 4,growy");
//---- progressBar4 ----
progressBar4.setOrientation(SwingConstants.VERTICAL);
progressBar4.setValue(55);
progressBar4.setStringPainted(true);
add(progressBar4, "cell 4 13 1 4,growy");
//======== toolBar2 ========
{
toolBar2.setOrientation(SwingConstants.VERTICAL);
//---- button9 ----
button9.setIcon(UIManager.getIcon("Tree.closedIcon"));
toolBar2.add(button9);
//---- button10 ----
button10.setIcon(UIManager.getIcon("Tree.openIcon"));
toolBar2.add(button10);
toolBar2.addSeparator();
//---- button11 ----
button11.setIcon(UIManager.getIcon("Tree.leafIcon"));
toolBar2.add(button11);
//---- toggleButton7 ----
toggleButton7.setIcon(UIManager.getIcon("Tree.closedIcon"));
toolBar2.add(toggleButton7);
}
add(toolBar2, "cell 4 13 1 4,growy");
//---- scrollBarLabel ----
scrollBarLabel.setText("JScrollBar:");
add(scrollBarLabel, "cell 0 14");
//---- scrollBar1 ----
scrollBar1.setOrientation(Adjustable.HORIZONTAL);
add(scrollBar1, "cell 1 14,growx");
//---- label4 ----
label4.setText("HTML:");
add(label4, "cell 5 14");
//---- scrollBar4 ----
scrollBar4.setOrientation(Adjustable.HORIZONTAL);
scrollBar4.setEnabled(false);
add(scrollBar4, "cell 1 15,growx");
//======== panel3 ========
{
panel3.setLayout(new MigLayout(
"insets 0,hidemode 3,gap 5 5,ltr",
// columns
"[]",
// rows
"[]" +
"[]" +
"[]"));
//---- label3 ----
label3.setText("<html>JLabel HTML<br>Sample <b>content</b><br> <u>text</u></html>");
panel3.add(label3, "cell 0 0");
//======== scrollPane15 ========
{
//---- editorPane6 ----
editorPane6.setContentType("text/html");
editorPane6.setText("JEditorPane HTML<br>Sample <b>content</b><br> <u>text</u>");
scrollPane15.setViewportView(editorPane6);
}
panel3.add(scrollPane15, "cell 0 1,grow");
//======== scrollPane16 ========
{
//---- textPane6 ----
textPane6.setContentType("text/html");
textPane6.setText("JTextPane HTML<br>Sample <b>content</b><br> <u>text</u>");
scrollPane16.setViewportView(textPane6);
}
panel3.add(scrollPane16, "cell 0 2,grow");
}
add(panel3, "cell 5 15 1 7,aligny top,grow 100 0");
//---- separatorLabel ----
separatorLabel.setText("JSeparator:");
add(separatorLabel, "cell 0 16");
add(separator1, "cell 1 16,growx");
//======== panel2 ========
{
panel2.setBorder(new TitledBorder("TitledBorder"));
panel2.setLayout(new FlowLayout());
}
add(panel2, "cell 3 16,grow");
//---- sliderLabel ----
sliderLabel.setText("JSlider:");
add(sliderLabel, "cell 0 17");
//---- slider1 ----
slider1.setValue(30);
add(slider1, "cell 1 17 3 1,aligny top,grow 100 0");
//---- slider6 ----
slider6.setEnabled(false);
slider6.setValue(30);
add(slider6, "cell 1 17 3 1,aligny top,growy 0");
//---- slider3 ----
slider3.setMinorTickSpacing(10);
slider3.setPaintTicks(true);
slider3.setMajorTickSpacing(50);
slider3.setPaintLabels(true);
slider3.setValue(30);
add(slider3, "cell 1 18 3 1,aligny top,grow 100 0");
//---- slider5 ----
slider5.setMinorTickSpacing(10);
slider5.setPaintTicks(true);
slider5.setMajorTickSpacing(50);
slider5.setPaintLabels(true);
slider5.setEnabled(false);
slider5.setValue(30);
add(slider5, "cell 1 18 3 1,aligny top,growy 0");
//---- progressBarLabel ----
progressBarLabel.setText("JProgressBar:");
add(progressBarLabel, "cell 0 19");
//---- progressBar1 ----
progressBar1.setValue(50);
add(progressBar1, "cell 1 19 3 1,growx");
//---- progressBar2 ----
progressBar2.setStringPainted(true);
progressBar2.setValue(55);
add(progressBar2, "cell 1 19 3 1,growx");
//---- indeterminateCheckBox ----
indeterminateCheckBox.setText("indeterminate");
indeterminateCheckBox.addActionListener(e -> indeterminateCheckBoxActionPerformed());
add(indeterminateCheckBox, "cell 4 19");
//---- toolTipLabel ----
toolTipLabel.setText("JToolTip:");
add(toolTipLabel, "cell 0 20");
//---- toolTip1 ----
toolTip1.setTipText("Some text in tool tip.");
add(toolTip1, "cell 1 20 3 1");
//---- toolTip2 ----
toolTip2.setTipText("Tool tip with\nmultiple\nlines.");
add(toolTip2, "cell 1 20 3 1");
//---- toolBarLabel ----
toolBarLabel.setText("JToolBar:");
add(toolBarLabel, "cell 0 21");
//======== toolBar1 ========
{
//---- button4 ----
button4.setIcon(UIManager.getIcon("Tree.closedIcon"));
toolBar1.add(button4);
//---- button6 ----
button6.setIcon(UIManager.getIcon("Tree.openIcon"));
toolBar1.add(button6);
toolBar1.addSeparator();
//---- button7 ----
button7.setIcon(UIManager.getIcon("Tree.leafIcon"));
toolBar1.add(button7);
toolBar1.addSeparator();
//---- button8 ----
button8.setText("Text");
button8.setIcon(UIManager.getIcon("Tree.expandedIcon"));
toolBar1.add(button8);
//---- toggleButton6 ----
toggleButton6.setText("Toggle");
toggleButton6.setIcon(UIManager.getIcon("Tree.leafIcon"));
toggleButton6.setSelected(true);
toolBar1.add(toggleButton6);
}
add(toolBar1, "cell 1 21 3 1,growx");
// JFormDesigner - End of component initialization //GEN-END:initComponents
// BasicComboBoxRenderer customaRenderer = new BasicComboBoxRenderer();
// customaRenderer.setBorder( new LineBorder( Color.red ) );
// comboBox1.setRenderer( customaRenderer );
// comboBox3.setRenderer( customaRenderer );
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JProgressBar progressBar3;
private JProgressBar progressBar4;
private JProgressBar progressBar1;
private JProgressBar progressBar2;
private JCheckBox indeterminateCheckBox;
// JFormDesigner - End of variables declaration //GEN-END:variables
//---- class TestDefaultButton --------------------------------------------
private static class TestDefaultButton
extends JButton
{
@Override
public boolean isDefaultButton() {
return true;
}
}
}

View File

@@ -0,0 +1,903 @@
JFDML JFormDesigner: "7.0.0.0.194" Java: "11.0.2" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
root: new FormRoot {
auxiliary() {
"JavaCodeGenerator.defaultVariableLocal": true
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 0,hidemode 3,gap 5 5,ltr"
"$columnConstraints": "[][][][][][]"
"$rowConstraints": "[][][][][][][][][][][][][][][][][][][][][][]"
} ) {
name: "this"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "labelLabel"
"text": "JLabel:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label1"
"text": "enabled"
"displayedMnemonic": 69
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label2"
"text": "disabled"
"displayedMnemonic": 68
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "buttonLabel"
"text": "JButton:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button1"
"text": "enabled"
"displayedMnemonicIndex": 0
"toolTipText": "This button is enabled."
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button2"
"text": "disabled"
"displayedMnemonicIndex": 0
"enabled": false
"toolTipText": "This button is disabled."
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 1"
} )
add( new FormComponent( "com.formdev.flatlaf.FlatComponentsTest$TestDefaultButton" ) {
name: "button5"
"text": "default"
"displayedMnemonicIndex": 0
"toolTipText": "Tool tip with\nmultiple\nlines."
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button3"
"text": "Help"
"$client.JButton.buttonType": "help"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button12"
"text": "Help"
"$client.JButton.buttonType": "help"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button13"
"icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "toggleButtonLabel"
"text": "JToggleButton:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "javax.swing.JToggleButton" ) {
name: "toggleButton1"
"text": "enabled"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JToggleButton" ) {
name: "toggleButton2"
"text": "disabled"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 2"
} )
add( new FormComponent( "javax.swing.JToggleButton" ) {
name: "toggleButton3"
"text": "selected"
"selected": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 2"
} )
add( new FormComponent( "javax.swing.JToggleButton" ) {
name: "toggleButton4"
"text": "selected disabled"
"enabled": false
"selected": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "checkBoxLabel"
"text": "JCheckBox"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "checkBox1"
"text": "enabled"
"mnemonic": 65
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "checkBox2"
"text": "disabled"
"enabled": false
"mnemonic": 68
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 3"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "checkBox3"
"text": "selected"
"selected": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 3"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "checkBox4"
"text": "selected disabled"
"selected": true
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 3"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "radioButtonLabel"
"text": "JRadioButton:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "radioButton1"
"text": "enabled"
"mnemonic": 78
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "radioButton2"
"text": "disabled"
"enabled": false
"mnemonic": 83
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 4"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "radioButton3"
"text": "selected"
"selected": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 4"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "radioButton4"
"text": "selected disabled"
"selected": true
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 4"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "comboBoxLabel"
"text": "JComboBox:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "comboBox1"
"editable": true
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "editable"
addElement( "editable" )
addElement( "a" )
addElement( "bb" )
addElement( "ccc" )
addElement( "dd" )
addElement( "e" )
addElement( "ff" )
addElement( "ggg" )
addElement( "hh" )
addElement( "i" )
addElement( "jj" )
addElement( "kkk" )
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5,growx"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "comboBox2"
"editable": true
"enabled": false
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "disabled"
addElement( "disabled" )
addElement( "a" )
addElement( "bb" )
addElement( "ccc" )
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 5,growx"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "comboBox3"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "not editable"
addElement( "not editable" )
addElement( "a" )
addElement( "bb" )
addElement( "ccc" )
addElement( "dd" )
addElement( "e" )
addElement( "ff" )
addElement( "ggg" )
addElement( "hh" )
addElement( "i" )
addElement( "jj" )
addElement( "kkk" )
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 5,growx"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "comboBox4"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "not editable disabled"
addElement( "not editable disabled" )
addElement( "a" )
addElement( "bb" )
addElement( "ccc" )
}
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 5,growx"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "comboBox5"
"prototypeDisplayValue": "12345"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "wide popup if text is longer"
addElement( "wide popup if text is longer" )
addElement( "aa" )
addElement( "bbb" )
addElement( "cccc" )
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 5,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "spinnerLabel"
"text": "JSpinner:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6"
} )
add( new FormComponent( "javax.swing.JSpinner" ) {
name: "spinner1"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 6,growx"
} )
add( new FormComponent( "javax.swing.JSpinner" ) {
name: "spinner2"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 6,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "textFieldLabel"
"text": "JTextField:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 7"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField1"
"text": "editable"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 7,growx"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField2"
"text": "disabled"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 7,growx"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField3"
"text": "not editable"
"editable": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 7,growx"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField4"
"text": "not editable disabled"
"enabled": false
"editable": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 7,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "formattedTextFieldLabel"
"text": "JFormattedTextField:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 8"
} )
add( new FormComponent( "javax.swing.JFormattedTextField" ) {
name: "formattedTextField1"
"text": "editable"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 8,growx"
} )
add( new FormComponent( "javax.swing.JFormattedTextField" ) {
name: "formattedTextField2"
"text": "disabled"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 8,growx"
} )
add( new FormComponent( "javax.swing.JFormattedTextField" ) {
name: "formattedTextField3"
"text": "not editable"
"editable": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 8,growx"
} )
add( new FormComponent( "javax.swing.JFormattedTextField" ) {
name: "formattedTextField4"
"text": "not editable disabled"
"enabled": false
"editable": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 8,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "passwordFieldLabel"
"text": "JPasswordField:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 9"
} )
add( new FormComponent( "javax.swing.JPasswordField" ) {
name: "passwordField1"
"text": "editable"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 9,growx"
} )
add( new FormComponent( "javax.swing.JPasswordField" ) {
name: "passwordField2"
"text": "disabled"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 9,growx"
} )
add( new FormComponent( "javax.swing.JPasswordField" ) {
name: "passwordField3"
"text": "not editable"
"editable": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 9,growx"
} )
add( new FormComponent( "javax.swing.JPasswordField" ) {
name: "passwordField4"
"text": "not editable disabled"
"enabled": false
"editable": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 9,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "textAreaLabel"
"text": "JTextArea:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 10"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane1"
"verticalScrollBarPolicy": 21
"horizontalScrollBarPolicy": 31
add( new FormComponent( "javax.swing.JTextArea" ) {
name: "textArea1"
"text": "editable"
"rows": 2
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 10,growx"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane2"
"verticalScrollBarPolicy": 21
"horizontalScrollBarPolicy": 31
add( new FormComponent( "javax.swing.JTextArea" ) {
name: "textArea2"
"text": "disabled"
"rows": 2
"enabled": false
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 10,growx"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane3"
"verticalScrollBarPolicy": 21
"horizontalScrollBarPolicy": 31
add( new FormComponent( "javax.swing.JTextArea" ) {
name: "textArea3"
"text": "not editable"
"rows": 2
"editable": false
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 10,growx"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane4"
"verticalScrollBarPolicy": 21
"horizontalScrollBarPolicy": 31
add( new FormComponent( "javax.swing.JTextArea" ) {
name: "textArea4"
"text": "not editable disabled"
"rows": 2
"editable": false
"enabled": false
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 10,growx"
} )
add( new FormComponent( "javax.swing.JTextArea" ) {
name: "textArea5"
"rows": 2
"text": "no scroll pane"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 10,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "editorPaneLabel"
"text": "JEditorPane"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 11"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane5"
"verticalScrollBarPolicy": 21
"horizontalScrollBarPolicy": 31
add( new FormComponent( "javax.swing.JEditorPane" ) {
name: "editorPane1"
"text": "editable"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 11,growx"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane6"
"verticalScrollBarPolicy": 21
"horizontalScrollBarPolicy": 31
add( new FormComponent( "javax.swing.JEditorPane" ) {
name: "editorPane2"
"text": "disabled"
"enabled": false
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 11,growx"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane7"
"verticalScrollBarPolicy": 21
"horizontalScrollBarPolicy": 31
add( new FormComponent( "javax.swing.JEditorPane" ) {
name: "editorPane3"
"text": "not editable"
"editable": false
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 11,growx"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane8"
"verticalScrollBarPolicy": 21
"horizontalScrollBarPolicy": 31
add( new FormComponent( "javax.swing.JEditorPane" ) {
name: "editorPane4"
"text": "not editable disabled"
"editable": false
"enabled": false
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 11,growx"
} )
add( new FormComponent( "javax.swing.JEditorPane" ) {
name: "editorPane5"
"text": "no scroll pane"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 11,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "textPaneLabel"
"text": "JTextPane:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 12"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane9"
"verticalScrollBarPolicy": 21
"horizontalScrollBarPolicy": 31
add( new FormComponent( "javax.swing.JTextPane" ) {
name: "textPane1"
"text": "editable"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 12,growx"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane10"
"verticalScrollBarPolicy": 21
"horizontalScrollBarPolicy": 31
add( new FormComponent( "javax.swing.JTextPane" ) {
name: "textPane2"
"text": "disabled"
"enabled": false
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 12,growx"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane11"
"verticalScrollBarPolicy": 21
"horizontalScrollBarPolicy": 31
add( new FormComponent( "javax.swing.JTextPane" ) {
name: "textPane3"
"text": "not editable"
"editable": false
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 12,growx"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane12"
"verticalScrollBarPolicy": 21
"horizontalScrollBarPolicy": 31
add( new FormComponent( "javax.swing.JTextPane" ) {
name: "textPane4"
"text": "not editable disabled"
"editable": false
"enabled": false
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 12,growx"
} )
add( new FormComponent( "javax.swing.JTextPane" ) {
name: "textPane5"
"text": "no scroll pane"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 12,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "scrollPaneLabel"
"text": "JScrollPane:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 13"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane13"
"horizontalScrollBarPolicy": 32
"verticalScrollBarPolicy": 22
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) {
name: "panel1"
"preferredSize": new java.awt.Dimension( 200, 200 )
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 13,grow,width 70,height 70"
} )
add( new FormComponent( "javax.swing.JScrollBar" ) {
name: "scrollBar2"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 13 1 4,growy"
} )
add( new FormComponent( "javax.swing.JScrollBar" ) {
name: "scrollBar3"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 13 1 4,growy"
} )
add( new FormComponent( "javax.swing.JSeparator" ) {
name: "separator2"
"orientation": 1
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 13 1 4,growy"
} )
add( new FormComponent( "javax.swing.JSlider" ) {
name: "slider2"
"orientation": 1
"value": 30
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 13 1 4,growy"
} )
add( new FormComponent( "javax.swing.JSlider" ) {
name: "slider4"
"minorTickSpacing": 10
"paintTicks": true
"majorTickSpacing": 50
"paintLabels": true
"orientation": 1
"value": 30
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 13 1 4,growy"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane14"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 13,grow"
} )
add( new FormComponent( "javax.swing.JProgressBar" ) {
name: "progressBar3"
"orientation": 1
"value": 50
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 13 1 4,growy"
} )
add( new FormComponent( "javax.swing.JProgressBar" ) {
name: "progressBar4"
"orientation": 1
"value": 55
"stringPainted": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 13 1 4,growy"
} )
add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) {
name: "toolBar2"
"orientation": 1
add( new FormComponent( "javax.swing.JButton" ) {
name: "button9"
"icon": &SwingIcon0 new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" )
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button10"
"icon": &SwingIcon1 new com.jformdesigner.model.SwingIcon( 2, "Tree.openIcon" )
} )
add( new FormComponent( "javax.swing.JToolBar$Separator" ) {
name: "separator5"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button11"
"icon": &SwingIcon2 new com.jformdesigner.model.SwingIcon( 2, "Tree.leafIcon" )
} )
add( new FormComponent( "javax.swing.JToggleButton" ) {
name: "toggleButton7"
"icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" )
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 13 1 4,growy"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "scrollBarLabel"
"text": "JScrollBar:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 14"
} )
add( new FormComponent( "javax.swing.JScrollBar" ) {
name: "scrollBar1"
"orientation": 0
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 14,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label4"
"text": "HTML:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 14"
} )
add( new FormComponent( "javax.swing.JScrollBar" ) {
name: "scrollBar4"
"orientation": 0
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 15,growx"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$columnConstraints": "[]"
"$rowConstraints": "[][][]"
"$layoutConstraints": "insets 0,hidemode 3,gap 5 5,ltr"
} ) {
name: "panel3"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label3"
"text": "<html>JLabel HTML<br>Sample <b>content</b><br> <u>text</u></html>"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane15"
add( new FormComponent( "javax.swing.JEditorPane" ) {
name: "editorPane6"
"contentType": "text/html"
"text": "JEditorPane HTML<br>Sample <b>content</b><br> <u>text</u>"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1,grow"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane16"
add( new FormComponent( "javax.swing.JTextPane" ) {
name: "textPane6"
"contentType": "text/html"
"text": "JTextPane HTML<br>Sample <b>content</b><br> <u>text</u>"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2,grow"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 15 1 7,aligny top,grow 100 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "separatorLabel"
"text": "JSeparator:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 16"
} )
add( new FormComponent( "javax.swing.JSeparator" ) {
name: "separator1"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 16,growx"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel2"
"border": new javax.swing.border.TitledBorder( "TitledBorder" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 16,grow"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "sliderLabel"
"text": "JSlider:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 17"
} )
add( new FormComponent( "javax.swing.JSlider" ) {
name: "slider1"
"value": 30
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 17 3 1,aligny top,grow 100 0"
} )
add( new FormComponent( "javax.swing.JSlider" ) {
name: "slider6"
"enabled": false
"value": 30
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 17 3 1,aligny top,growy 0"
} )
add( new FormComponent( "javax.swing.JSlider" ) {
name: "slider3"
"minorTickSpacing": 10
"paintTicks": true
"majorTickSpacing": 50
"paintLabels": true
"value": 30
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 18 3 1,aligny top,grow 100 0"
} )
add( new FormComponent( "javax.swing.JSlider" ) {
name: "slider5"
"minorTickSpacing": 10
"paintTicks": true
"majorTickSpacing": 50
"paintLabels": true
"enabled": false
"value": 30
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 18 3 1,aligny top,growy 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "progressBarLabel"
"text": "JProgressBar:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 19"
} )
add( new FormComponent( "javax.swing.JProgressBar" ) {
name: "progressBar1"
"value": 50
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 19 3 1,growx"
} )
add( new FormComponent( "javax.swing.JProgressBar" ) {
name: "progressBar2"
"stringPainted": true
"value": 55
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 19 3 1,growx"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "indeterminateCheckBox"
"text": "indeterminate"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "indeterminateCheckBoxActionPerformed", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 19"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "toolTipLabel"
"text": "JToolTip:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 20"
} )
add( new FormComponent( "javax.swing.JToolTip" ) {
name: "toolTip1"
"tipText": "Some text in tool tip."
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 20 3 1"
} )
add( new FormComponent( "javax.swing.JToolTip" ) {
name: "toolTip2"
"tipText": "Tool tip with\nmultiple\nlines."
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 20 3 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "toolBarLabel"
"text": "JToolBar:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 21"
} )
add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) {
name: "toolBar1"
add( new FormComponent( "javax.swing.JButton" ) {
name: "button4"
"icon": #SwingIcon0
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button6"
"icon": #SwingIcon1
} )
add( new FormComponent( "javax.swing.JToolBar$Separator" ) {
name: "separator3"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button7"
"icon": #SwingIcon2
} )
add( new FormComponent( "javax.swing.JToolBar$Separator" ) {
name: "separator4"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "button8"
"text": "Text"
"icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.expandedIcon" )
} )
add( new FormComponent( "javax.swing.JToggleButton" ) {
name: "toggleButton6"
"text": "Toggle"
"icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.leafIcon" )
"selected": true
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 21 3 1,growx"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 790, 750 )
} )
}
}

View File

@@ -0,0 +1,328 @@
/*
* Created by JFormDesigner on Tue Aug 27 21:47:02 CEST 2019
*/
package com.formdev.flatlaf;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import com.jgoodies.forms.layout.*;
import net.miginfocom.swing.*;
/**
* @author Karl Tauber
*/
public class FlatContainerTest
extends JPanel
{
public static void main( String[] args ) {
SwingUtilities.invokeLater( () -> {
FlatTestFrame frame = FlatTestFrame.create( args, "FlatContainerTest" );
frame.showFrame( new FlatContainerTest() );
} );
}
public FlatContainerTest() {
initComponents();
}
private void tabScrollChanged() {
int tabLayoutPolicy = tabScrollCheckBox.isSelected() ? JTabbedPane.SCROLL_TAB_LAYOUT : JTabbedPane.WRAP_TAB_LAYOUT;
tabbedPane1.setTabLayoutPolicy( tabLayoutPolicy );
tabbedPane2.setTabLayoutPolicy( tabLayoutPolicy );
tabbedPane3.setTabLayoutPolicy( tabLayoutPolicy );
tabbedPane4.setTabLayoutPolicy( tabLayoutPolicy );
}
private void hasFullBorderChanged() {
Boolean hasFullBorder = hasFullBorderCheckBox.isSelected() ? true : null;
tabbedPane1.putClientProperty( "JTabbedPane.hasFullBorder", hasFullBorder );
tabbedPane2.putClientProperty( "JTabbedPane.hasFullBorder", hasFullBorder );
tabbedPane3.putClientProperty( "JTabbedPane.hasFullBorder", hasFullBorder );
tabbedPane4.putClientProperty( "JTabbedPane.hasFullBorder", hasFullBorder );
}
private void moreTabsChanged() {
boolean moreTabs = moreTabsCheckBox.isSelected();
addRemoveMoreTabs( tabbedPane1, moreTabs );
addRemoveMoreTabs( tabbedPane2, moreTabs );
addRemoveMoreTabs( tabbedPane3, moreTabs );
addRemoveMoreTabs( tabbedPane4, moreTabs );
}
private void addRemoveMoreTabs( JTabbedPane tabbedPane, boolean add ) {
if( add ) {
tabbedPane.addTab( "Tab 4", new JLabel( "tab 4" ) );
tabbedPane.addTab( "Tab 5", new JLabel( "tab 5" ) );
} else {
int tabCount = tabbedPane.getTabCount();
if( tabCount > 3 ) {
for( int i = 0; i < 2; i++ )
tabbedPane.removeTabAt( tabbedPane.getTabCount() - 1 );
}
}
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JPanel panel9 = new JPanel();
JLabel splitPaneLabel = new JLabel();
JSplitPane splitPane3 = new JSplitPane();
JSplitPane splitPane1 = new JSplitPane();
JPanel panel10 = new JPanel();
JPanel panel11 = new JPanel();
JSplitPane splitPane2 = new JSplitPane();
JPanel panel12 = new JPanel();
JPanel panel13 = new JPanel();
JLabel tabbedPaneLabel = new JLabel();
tabbedPane1 = new JTabbedPane();
JPanel panel1 = new JPanel();
JLabel label1 = new JLabel();
JPanel panel2 = new JPanel();
JLabel label2 = new JLabel();
tabbedPane3 = new JTabbedPane();
JPanel panel5 = new JPanel();
JLabel label5 = new JLabel();
JPanel panel6 = new JPanel();
JLabel label6 = new JLabel();
tabbedPane2 = new JTabbedPane();
JPanel panel3 = new JPanel();
JLabel label3 = new JLabel();
JPanel panel4 = new JPanel();
JLabel label4 = new JLabel();
tabbedPane4 = new JTabbedPane();
JPanel panel7 = new JPanel();
JLabel label7 = new JLabel();
JPanel panel8 = new JPanel();
JLabel label8 = new JLabel();
JPanel panel14 = new JPanel();
moreTabsCheckBox = new JCheckBox();
tabScrollCheckBox = new JCheckBox();
hasFullBorderCheckBox = new JCheckBox();
CellConstraints cc = new CellConstraints();
//======== this ========
setLayout(new MigLayout(
"insets 0,hidemode 3",
// columns
"[grow,fill]",
// rows
"[grow,fill]"));
//======== panel9 ========
{
panel9.setLayout(new FormLayout(
"70dlu:grow, $lcgap, 70dlu:grow",
"default, $lgap, fill:70dlu, $lgap, pref, 2*($lgap, fill:70dlu:grow), $lgap, pref"));
//---- splitPaneLabel ----
splitPaneLabel.setText("JSplitPane:");
panel9.add(splitPaneLabel, cc.xy(1, 1));
//======== splitPane3 ========
{
splitPane3.setResizeWeight(0.5);
//======== splitPane1 ========
{
splitPane1.setResizeWeight(0.5);
splitPane1.setOneTouchExpandable(true);
//======== panel10 ========
{
panel10.setBackground(Color.orange);
panel10.setLayout(new FlowLayout());
}
splitPane1.setLeftComponent(panel10);
//======== panel11 ========
{
panel11.setBackground(Color.magenta);
panel11.setLayout(new FlowLayout());
}
splitPane1.setRightComponent(panel11);
}
splitPane3.setLeftComponent(splitPane1);
//======== splitPane2 ========
{
splitPane2.setOrientation(JSplitPane.VERTICAL_SPLIT);
splitPane2.setResizeWeight(0.5);
splitPane2.setOneTouchExpandable(true);
//======== panel12 ========
{
panel12.setBackground(Color.orange);
panel12.setLayout(new FlowLayout());
}
splitPane2.setTopComponent(panel12);
//======== panel13 ========
{
panel13.setBackground(Color.magenta);
panel13.setLayout(new FlowLayout());
}
splitPane2.setBottomComponent(panel13);
}
splitPane3.setRightComponent(splitPane2);
}
panel9.add(splitPane3, cc.xywh(1, 3, 3, 1));
//---- tabbedPaneLabel ----
tabbedPaneLabel.setText("JTabbedPane:");
panel9.add(tabbedPaneLabel, cc.xy(1, 5));
//======== tabbedPane1 ========
{
//======== panel1 ========
{
panel1.setLayout(new FlowLayout());
//---- label1 ----
label1.setText("TOP");
panel1.add(label1);
}
tabbedPane1.addTab("Tab 1", panel1);
//======== panel2 ========
{
panel2.setBorder(new LineBorder(Color.magenta));
panel2.setLayout(new FlowLayout());
}
tabbedPane1.addTab("Tab 2", panel2);
//---- label2 ----
label2.setText("text");
tabbedPane1.addTab("Tab 3", label2);
}
panel9.add(tabbedPane1, cc.xy(1, 7));
//======== tabbedPane3 ========
{
tabbedPane3.setTabPlacement(SwingConstants.LEFT);
//======== panel5 ========
{
panel5.setLayout(new FlowLayout());
//---- label5 ----
label5.setText("LEFT");
panel5.add(label5);
}
tabbedPane3.addTab("Tab 1", panel5);
//======== panel6 ========
{
panel6.setBorder(new LineBorder(Color.magenta));
panel6.setLayout(new FlowLayout());
}
tabbedPane3.addTab("Tab 2", panel6);
//---- label6 ----
label6.setText("text");
tabbedPane3.addTab("Tab 3", label6);
}
panel9.add(tabbedPane3, cc.xy(3, 7));
//======== tabbedPane2 ========
{
tabbedPane2.setTabPlacement(SwingConstants.BOTTOM);
//======== panel3 ========
{
panel3.setLayout(new FlowLayout());
//---- label3 ----
label3.setText("BOTTOM");
panel3.add(label3);
}
tabbedPane2.addTab("Tab 1", panel3);
//======== panel4 ========
{
panel4.setBorder(new LineBorder(Color.magenta));
panel4.setLayout(new FlowLayout());
}
tabbedPane2.addTab("Tab 2", panel4);
tabbedPane2.setEnabledAt(1, false);
//---- label4 ----
label4.setText("text");
tabbedPane2.addTab("Tab 3", label4);
}
panel9.add(tabbedPane2, cc.xy(1, 9));
//======== tabbedPane4 ========
{
tabbedPane4.setTabPlacement(SwingConstants.RIGHT);
//======== panel7 ========
{
panel7.setLayout(new FlowLayout());
//---- label7 ----
label7.setText("RIGHT");
panel7.add(label7);
}
tabbedPane4.addTab("Tab 1", panel7);
//======== panel8 ========
{
panel8.setBorder(new LineBorder(Color.magenta));
panel8.setLayout(new FlowLayout());
}
tabbedPane4.addTab("Tab 2", panel8);
//---- label8 ----
label8.setText("text");
tabbedPane4.addTab("Tab 3", label8);
}
panel9.add(tabbedPane4, cc.xy(3, 9));
//======== panel14 ========
{
panel14.setLayout(new MigLayout(
"insets 0,hidemode 3",
// columns
"[]" +
"[]" +
"[]",
// rows
"[center]"));
//---- moreTabsCheckBox ----
moreTabsCheckBox.setText("more tabs");
moreTabsCheckBox.setMnemonic('M');
moreTabsCheckBox.addActionListener(e -> moreTabsChanged());
panel14.add(moreTabsCheckBox, "cell 0 0");
//---- tabScrollCheckBox ----
tabScrollCheckBox.setText("tabLayoutPolicy = SCROLL");
tabScrollCheckBox.setMnemonic('S');
tabScrollCheckBox.addActionListener(e -> tabScrollChanged());
panel14.add(tabScrollCheckBox, "cell 1 0,alignx left,growx 0");
//---- hasFullBorderCheckBox ----
hasFullBorderCheckBox.setText("JTabbedPane.hasFullBorder");
hasFullBorderCheckBox.setMnemonic('F');
hasFullBorderCheckBox.addActionListener(e -> hasFullBorderChanged());
panel14.add(hasFullBorderCheckBox, "cell 2 0,alignx left,growx 0");
}
panel9.add(panel14, cc.xywh(1, 11, 3, 1));
}
add(panel9, "cell 0 0");
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JTabbedPane tabbedPane1;
private JTabbedPane tabbedPane3;
private JTabbedPane tabbedPane2;
private JTabbedPane tabbedPane4;
private JCheckBox moreTabsCheckBox;
private JCheckBox tabScrollCheckBox;
private JCheckBox hasFullBorderCheckBox;
// JFormDesigner - End of variables declaration //GEN-END:variables
}

View File

@@ -0,0 +1,251 @@
JFDML JFormDesigner: "7.0.0.0.194" Java: "11.0.2" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
root: new FormRoot {
auxiliary() {
"JavaCodeGenerator.defaultVariableLocal": true
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 0,hidemode 3"
"$columnConstraints": "[grow,fill]"
"$rowConstraints": "[grow,fill]"
} ) {
name: "this"
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class com.jgoodies.forms.layout.FormLayout ) {
"$columnSpecs": "70dlu:grow, labelcompgap, 70dlu:grow"
"$rowSpecs": "default, linegap, fill:70dlu, linegap, pref, linegap, fill:70dlu:grow, linegap, fill:70dlu:grow, linegap, pref"
} ) {
name: "panel9"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "splitPaneLabel"
"text": "JSplitPane:"
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) )
add( new FormContainer( "javax.swing.JSplitPane", new FormLayoutManager( class javax.swing.JSplitPane ) ) {
name: "splitPane3"
"resizeWeight": 0.5
add( new FormContainer( "javax.swing.JSplitPane", new FormLayoutManager( class javax.swing.JSplitPane ) ) {
name: "splitPane1"
"resizeWeight": 0.5
"oneTouchExpandable": true
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel10"
"background": sfield java.awt.Color orange
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "left"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel11"
"background": sfield java.awt.Color magenta
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "right"
} )
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "left"
} )
add( new FormContainer( "javax.swing.JSplitPane", new FormLayoutManager( class javax.swing.JSplitPane ) ) {
name: "splitPane2"
"orientation": 0
"resizeWeight": 0.5
"oneTouchExpandable": true
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel12"
"background": sfield java.awt.Color orange
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "left"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel13"
"background": sfield java.awt.Color magenta
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "right"
} )
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "right"
} )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridY": 3
"gridWidth": 3
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "tabbedPaneLabel"
"text": "JTabbedPane:"
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridX": 1
"gridY": 5
} )
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
name: "tabbedPane1"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel1"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label1"
"text": "TOP"
} )
}, new FormLayoutConstraints( null ) {
"title": "Tab 1"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel2"
"border": &LineBorder0 new javax.swing.border.LineBorder( sfield java.awt.Color magenta, 1, false )
}, new FormLayoutConstraints( null ) {
"title": "Tab 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label2"
"text": "text"
}, new FormLayoutConstraints( null ) {
"title": "Tab 3"
} )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridX": 1
"gridY": 7
} )
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
name: "tabbedPane3"
"tabPlacement": 2
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel5"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label5"
"text": "LEFT"
} )
}, new FormLayoutConstraints( null ) {
"title": "Tab 1"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel6"
"border": #LineBorder0
}, new FormLayoutConstraints( null ) {
"title": "Tab 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label6"
"text": "text"
}, new FormLayoutConstraints( null ) {
"title": "Tab 3"
} )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridX": 3
"gridY": 7
} )
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
name: "tabbedPane2"
"tabPlacement": 3
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel3"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label3"
"text": "BOTTOM"
} )
}, new FormLayoutConstraints( null ) {
"title": "Tab 1"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel4"
"border": #LineBorder0
}, new FormLayoutConstraints( null ) {
"title": "Tab 2"
"enabled": false
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label4"
"text": "text"
}, new FormLayoutConstraints( null ) {
"title": "Tab 3"
} )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridY": 9
} )
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
name: "tabbedPane4"
"tabPlacement": 4
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel7"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label7"
"text": "RIGHT"
} )
}, new FormLayoutConstraints( null ) {
"title": "Tab 1"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "panel8"
"border": #LineBorder0
}, new FormLayoutConstraints( null ) {
"title": "Tab 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label8"
"text": "text"
}, new FormLayoutConstraints( null ) {
"title": "Tab 3"
} )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridX": 3
"gridY": 9
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 0,hidemode 3"
"$columnConstraints": "[][][]"
"$rowConstraints": "[center]"
} ) {
name: "panel14"
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "moreTabsCheckBox"
"text": "more tabs"
"mnemonic": 77
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "moreTabsChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "tabScrollCheckBox"
"text": "tabLayoutPolicy = SCROLL"
"mnemonic": 83
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabScrollChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0,alignx left,growx 0"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "hasFullBorderCheckBox"
"text": "JTabbedPane.hasFullBorder"
"mnemonic": 70
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "hasFullBorderChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0,alignx left,growx 0"
} )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridY": 11
"gridWidth": 3
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 500, 515 )
} )
}
}

View File

@@ -0,0 +1,287 @@
/*
* 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;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.lang.reflect.Field;
import javax.swing.AbstractButton;
import javax.swing.JComponent;
import javax.swing.JMenuBar;
import javax.swing.JRootPane;
import javax.swing.JToolBar;
import javax.swing.JToolTip;
import javax.swing.SwingUtilities;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import javax.swing.plaf.UIResource;
import javax.swing.text.JTextComponent;
import com.formdev.flatlaf.ui.FlatToolTipUI;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.formdev.flatlaf.util.UIScale;
/**
* @author Karl Tauber
*/
public class FlatInspector
{
private static final Integer HIGHLIGHT_LAYER = 401;
private static final Integer TOOLTIP_LAYER = 402;
private final JRootPane rootPane;
private Component lastComponent;
private int lastX;
private int lastY;
private JComponent highlightFigure;
private JToolTip tip;
public FlatInspector( JRootPane rootPane ) {
this.rootPane = rootPane;
rootPane.getGlassPane().addMouseMotionListener( new MouseMotionAdapter() {
@Override
public void mouseMoved( MouseEvent e ) {
lastX = e.getX();
lastY = e.getY();
inspect( lastX, lastY );
}
} );
}
public void setEnabled( boolean enabled ) {
rootPane.getGlassPane().setVisible( enabled );
if( !enabled ) {
lastComponent = null;
if( highlightFigure != null )
highlightFigure.getParent().remove( highlightFigure );
highlightFigure = null;
if( tip != null )
tip.getParent().remove( tip );
tip = null;
}
}
public void update() {
if( !rootPane.getGlassPane().isVisible() )
return;
EventQueue.invokeLater( () -> {
setEnabled( false );
setEnabled( true );
inspect( lastX, lastY );
} );
}
private void inspect( int x, int y ) {
Container contentPane = rootPane.getContentPane();
Component c = SwingUtilities.getDeepestComponentAt( contentPane, x, y );
if( c == contentPane || (c != null && c.getParent() == contentPane) )
c = null;
if( c == lastComponent )
return;
lastComponent = c;
highlight( c );
showToolTip( c, x, y );
}
private void highlight( Component c ) {
if( highlightFigure == null ) {
highlightFigure = createHighlightFigure();
rootPane.getLayeredPane().add( highlightFigure, HIGHLIGHT_LAYER );
}
highlightFigure.setVisible( c != null );
if( c != null ) {
Rectangle bounds = c.getBounds();
Rectangle highlightBounds = SwingUtilities.convertRectangle( c.getParent(), bounds, rootPane );
highlightFigure.setBounds( highlightBounds );
}
}
private JComponent createHighlightFigure() {
JComponent c = new JComponent() {
@Override
protected void paintComponent( Graphics g ) {
g.setColor( getBackground() );
g.fillRect( 0, 0, getWidth(), getHeight() );
}
@Override
protected void paintBorder( Graphics g ) {
FlatUIUtils.setRenderingHints( (Graphics2D) g );
super.paintBorder( g );
}
};
c.setBackground( new Color( 255, 0, 0, 32 ) );
c.setBorder( new LineBorder( Color.red ) );
return c;
}
private void showToolTip( Component c, int x, int y ) {
if( c == null ) {
if( tip != null )
tip.setVisible( false );
return;
}
if( tip == null ) {
tip = new JToolTip() {
@Override
public void updateUI() {
setUI( FlatToolTipUI.createUI( this ) );
}
};
rootPane.getLayeredPane().add( tip, TOOLTIP_LAYER );
} else
tip.setVisible( true );
tip.setTipText( buildToolTipText( c ) );
int tx = x + UIScale.scale( 8 );
int ty = y + UIScale.scale( 16 );
Dimension size = tip.getPreferredSize();
// position the tip in the visible area
Rectangle visibleRect = rootPane.getVisibleRect();
if( tx + size.width > visibleRect.x + visibleRect.width )
tx = visibleRect.x + visibleRect.width - size.width;
if( ty + size.height > visibleRect.y + visibleRect.height )
ty = visibleRect.y + visibleRect.height - size.height;
if( tx < visibleRect.x )
tx = visibleRect.x;
if( ty < visibleRect.y )
ty = visibleRect.y;
tip.setBounds( tx, ty, size.width, size.height );
tip.repaint();
}
private String buildToolTipText( Component c ) {
String text =
"Class: " + c.getClass().getSimpleName() + " (" + c.getClass().getPackage().getName() + ")\n" +
"Size: " + c.getWidth() + ',' + c.getHeight() + " @ " + c.getX() + ',' + c.getY() + '\n';
if( c instanceof Container )
text += "Insets: " + toString( ((Container)c).getInsets() ) + '\n';
Insets margin = null;
if( c instanceof AbstractButton )
margin = ((AbstractButton) c).getMargin();
else if( c instanceof JTextComponent )
margin = ((JTextComponent) c).getMargin();
else if( c instanceof JMenuBar )
margin = ((JMenuBar) c).getMargin();
else if( c instanceof JToolBar )
margin = ((JToolBar) c).getMargin();
if( margin != null )
text += "Margin: " + toString( margin ) + '\n';
Dimension prefSize = c.getPreferredSize();
Dimension minSize = c.getMinimumSize();
Dimension maxSize = c.getMaximumSize();
text += "Pref size: " + prefSize.width + ',' + prefSize.height + '\n' +
"Min size: " + minSize.width + ',' + minSize.height + '\n' +
"Max size: " + maxSize.width + ',' + maxSize.height + '\n';
if( c instanceof JComponent )
text += "Border: " + toString( ((JComponent)c).getBorder() ) + '\n';
text += "Background: " + toString( c.getBackground() ) + '\n' +
"Foreground: " + toString( c.getForeground() ) + '\n' +
"Font: " + toString( c.getFont() ) + '\n';
if( c instanceof JComponent ) {
try {
Field f = JComponent.class.getDeclaredField( "ui" );
f.setAccessible( true );
Object ui = f.get( c );
text += "UI: " + (ui != null ? ui.getClass().getName() : "null") + '\n';
} catch( NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex ) {
// ignore
}
}
text += "Enabled: " + c.isEnabled() + '\n';
text += "Opaque: " + c.isOpaque() + '\n';
text += "Focusable: " + c.isFocusable() + '\n';
text += "Left-to-right: " + c.getComponentOrientation().isLeftToRight() + '\n';
text += "Parent: " + c.getParent().getClass().getName();
return text;
}
private static String toString( Insets insets ) {
if( insets == null )
return "null";
return insets.top + "," + insets.left + ',' + insets.bottom + ',' + insets.right;
}
private static String toString( Color c ) {
if( c == null )
return "null";
String s = Long.toString( c.getRGB() & 0xffffffffl, 16 );
if( c instanceof UIResource )
s += " UI";
return s;
}
private static String toString( Font f ) {
if( f == null )
return "null";
return f.getFamily() + " " + f.getSize() + " " + f.getStyle()
+ (f instanceof UIResource ? " UI" : "");
}
private static String toString( Border b ) {
if( b == null )
return "null";
String s = b.getClass().getName();
if( b instanceof EmptyBorder )
s += '(' + toString( ((EmptyBorder)b).getBorderInsets() ) + ')';
if( b instanceof UIResource )
s += " UI";
return s;
}
}

View File

@@ -0,0 +1,405 @@
/*
* 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;
import java.awt.Component;
import java.awt.Container;
import java.awt.event.*;
import javax.swing.*;
import net.miginfocom.swing.*;
/**
* @author Karl Tauber
*/
public class FlatMenusTest
extends JPanel
{
public static void main( String[] args ) {
SwingUtilities.invokeLater( () -> {
FlatTestFrame frame = FlatTestFrame.create( args, "FlatMenusTest" );
frame.showFrame( new FlatMenusTest() );
} );
}
FlatMenusTest() {
initComponents();
}
private void armedChanged() {
boolean armed = armedCheckBox.isSelected();
arm( this, armed );
}
private void arm( Container container, boolean armed ) {
for( Component c : container.getComponents() ) {
if( c instanceof JMenuItem )
((JMenuItem)c).setArmed( armed );
if( c instanceof Container )
arm( (Container) c, armed );
}
}
private void showPopupMenuButtonActionPerformed(ActionEvent e) {
Component invoker = (Component) e.getSource();
PopupMenu popupMenu = new PopupMenu();
popupMenu.applyComponentOrientation( getComponentOrientation() );
popupMenu.show( invoker, 0, invoker.getHeight() );
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JLabel menuBarLabel = new JLabel();
JMenuBar menuBar1 = new JMenuBar();
JMenu menu5 = new JMenu();
JMenuItem menuItem7 = new JMenuItem();
JMenuItem menuItem8 = new JMenuItem();
JMenu menu6 = new JMenu();
JMenuItem menuItem5 = new JMenuItem();
JMenuItem menuItem6 = new JMenuItem();
JPanel panel1 = new JPanel();
JLabel menuLabel = new JLabel();
JMenu menu1 = new JMenu();
JLabel menuItemLabel = new JLabel();
JMenuItem menuItem1 = new JMenuItem();
JLabel checkBoxMenuItemLabel = new JLabel();
JCheckBoxMenuItem checkBoxMenuItem1 = new JCheckBoxMenuItem();
JLabel radioButtonMenuItemLabel = new JLabel();
JRadioButtonMenuItem radioButtonMenuItem1 = new JRadioButtonMenuItem();
JLabel popupMenuSeparatorLabel = new JLabel();
JPopupMenu.Separator separator1 = new JPopupMenu.Separator();
JPanel panel2 = new JPanel();
JMenu menu2 = new JMenu();
JMenuItem menuItem2 = new JMenuItem();
JCheckBoxMenuItem checkBoxMenuItem2 = new JCheckBoxMenuItem();
JRadioButtonMenuItem radioButtonMenuItem2 = new JRadioButtonMenuItem();
JPanel panel3 = new JPanel();
JMenu menu3 = new JMenu();
JMenuItem menuItem3 = new JMenuItem();
JCheckBoxMenuItem checkBoxMenuItem3 = new JCheckBoxMenuItem();
JRadioButtonMenuItem radioButtonMenuItem3 = new JRadioButtonMenuItem();
JPanel panel4 = new JPanel();
JMenu menu4 = new JMenu();
JMenuItem menuItem4 = new JMenuItem();
JCheckBoxMenuItem checkBoxMenuItem4 = new JCheckBoxMenuItem();
JRadioButtonMenuItem radioButtonMenuItem4 = new JRadioButtonMenuItem();
JLabel popupMenuLabel = new JLabel();
JButton showPopupMenuButton = new JButton();
armedCheckBox = new JCheckBox();
//======== this ========
setLayout(new MigLayout(
"insets 0,hidemode 3,gap 5 5,ltr",
// columns
"[125]" +
"[]" +
"[]" +
"[]" +
"[]",
// rows
"[]" +
"[top]" +
"[]" +
"[]"));
//---- menuBarLabel ----
menuBarLabel.setText("JMenuBar:");
add(menuBarLabel, "cell 0 0");
//======== menuBar1 ========
{
//======== menu5 ========
{
menu5.setText("text");
//---- menuItem7 ----
menuItem7.setText("text");
menu5.add(menuItem7);
//---- menuItem8 ----
menuItem8.setText("text");
menu5.add(menuItem8);
}
menuBar1.add(menu5);
//======== menu6 ========
{
menu6.setText("text");
//---- menuItem5 ----
menuItem5.setText("text");
menu6.add(menuItem5);
//---- menuItem6 ----
menuItem6.setText("text");
menu6.add(menuItem6);
}
menuBar1.add(menu6);
}
add(menuBar1, "cell 1 0 4 1,growx");
//======== panel1 ========
{
panel1.setLayout(new MigLayout(
"insets 0,hidemode 3,gap 5 5,ltr",
// columns
"[125,left]" +
"[fill]",
// rows
"[]" +
"[]" +
"[]" +
"[]" +
"[]"));
//---- menuLabel ----
menuLabel.setText("JMenu:");
panel1.add(menuLabel, "cell 0 0");
//======== menu1 ========
{
menu1.setText("enabled");
}
panel1.add(menu1, "cell 1 0");
//---- menuItemLabel ----
menuItemLabel.setText("JMenuItem:");
panel1.add(menuItemLabel, "cell 0 1");
//---- menuItem1 ----
menuItem1.setText("enabled");
menuItem1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_MASK));
panel1.add(menuItem1, "cell 1 1");
//---- checkBoxMenuItemLabel ----
checkBoxMenuItemLabel.setText("JCheckBoxMenuItem:");
panel1.add(checkBoxMenuItemLabel, "cell 0 2");
//---- checkBoxMenuItem1 ----
checkBoxMenuItem1.setText("enabled");
checkBoxMenuItem1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
panel1.add(checkBoxMenuItem1, "cell 1 2");
//---- radioButtonMenuItemLabel ----
radioButtonMenuItemLabel.setText("JRadioButtonMenuItem:");
panel1.add(radioButtonMenuItemLabel, "cell 0 3");
//---- radioButtonMenuItem1 ----
radioButtonMenuItem1.setText("enabled");
radioButtonMenuItem1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
panel1.add(radioButtonMenuItem1, "cell 1 3");
//---- popupMenuSeparatorLabel ----
popupMenuSeparatorLabel.setText("JPopupMenu.Separator:");
panel1.add(popupMenuSeparatorLabel, "cell 0 4");
panel1.add(separator1, "cell 1 4");
}
add(panel1, "cell 0 1 2 1");
//======== panel2 ========
{
panel2.setLayout(new MigLayout(
"insets 0,gap 5 5",
// columns
"[fill]",
// rows
"[]" +
"[]" +
"[]" +
"[]" +
"[]"));
//======== menu2 ========
{
menu2.setText("disabled");
menu2.setEnabled(false);
}
panel2.add(menu2, "cell 0 0");
//---- menuItem2 ----
menuItem2.setText("disabled");
menuItem2.setEnabled(false);
menuItem2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, KeyEvent.ALT_MASK|KeyEvent.SHIFT_MASK));
panel2.add(menuItem2, "cell 0 1");
//---- checkBoxMenuItem2 ----
checkBoxMenuItem2.setText("disabled");
checkBoxMenuItem2.setEnabled(false);
checkBoxMenuItem2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
panel2.add(checkBoxMenuItem2, "cell 0 2");
//---- radioButtonMenuItem2 ----
radioButtonMenuItem2.setText("disabled");
radioButtonMenuItem2.setEnabled(false);
radioButtonMenuItem2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
panel2.add(radioButtonMenuItem2, "cell 0 3");
}
add(panel2, "cell 2 1");
//======== panel3 ========
{
panel3.setLayout(new MigLayout(
"insets 0,gap 5 5",
// columns
"[fill]",
// rows
"[]" +
"[]" +
"[]" +
"[]"));
//======== menu3 ========
{
menu3.setText("text");
menu3.setVisible(false);
}
panel3.add(menu3, "cell 0 0");
//---- menuItem3 ----
menuItem3.setText("selected");
menuItem3.setSelected(true);
menuItem3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
panel3.add(menuItem3, "cell 0 1");
//---- checkBoxMenuItem3 ----
checkBoxMenuItem3.setText("selected");
checkBoxMenuItem3.setSelected(true);
checkBoxMenuItem3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
panel3.add(checkBoxMenuItem3, "cell 0 2");
//---- radioButtonMenuItem3 ----
radioButtonMenuItem3.setText("selected");
radioButtonMenuItem3.setSelected(true);
radioButtonMenuItem3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
panel3.add(radioButtonMenuItem3, "cell 0 3");
}
add(panel3, "cell 3 1");
//======== panel4 ========
{
panel4.setLayout(new MigLayout(
"insets 0,gap 5 5",
// columns
"[fill]",
// rows
"[]" +
"[]" +
"[]" +
"[]"));
//======== menu4 ========
{
menu4.setText("text");
menu4.setVisible(false);
}
panel4.add(menu4, "cell 0 0");
//---- menuItem4 ----
menuItem4.setText("selected disabled");
menuItem4.setSelected(true);
menuItem4.setEnabled(false);
menuItem4.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
panel4.add(menuItem4, "cell 0 1");
//---- checkBoxMenuItem4 ----
checkBoxMenuItem4.setText("selected disabled");
checkBoxMenuItem4.setEnabled(false);
checkBoxMenuItem4.setSelected(true);
checkBoxMenuItem4.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
panel4.add(checkBoxMenuItem4, "cell 0 2");
//---- radioButtonMenuItem4 ----
radioButtonMenuItem4.setText("selected disabled");
radioButtonMenuItem4.setEnabled(false);
radioButtonMenuItem4.setSelected(true);
radioButtonMenuItem4.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
panel4.add(radioButtonMenuItem4, "cell 0 3");
}
add(panel4, "cell 4 1");
//---- popupMenuLabel ----
popupMenuLabel.setText("JPopupMenu:");
add(popupMenuLabel, "cell 0 2");
//---- showPopupMenuButton ----
showPopupMenuButton.setText("show JPopupMenu");
showPopupMenuButton.addActionListener(e -> showPopupMenuButtonActionPerformed(e));
add(showPopupMenuButton, "cell 1 2");
//---- armedCheckBox ----
armedCheckBox.setText("armed");
armedCheckBox.setMnemonic('A');
armedCheckBox.addActionListener(e -> armedChanged());
add(armedCheckBox, "cell 0 3");
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JCheckBox armedCheckBox;
// JFormDesigner - End of variables declaration //GEN-END:variables
private class PopupMenu extends JPopupMenu {
private PopupMenu() {
initComponents();
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JMenuItem menuItem9 = new JMenuItem();
JMenuItem menuItem10 = new JMenuItem();
JCheckBoxMenuItem checkBoxMenuItem5 = new JCheckBoxMenuItem();
JMenu menu7 = new JMenu();
JMenuItem menuItem11 = new JMenuItem();
JMenuItem menuItem12 = new JMenuItem();
//======== this ========
//---- menuItem9 ----
menuItem9.setText("text");
add(menuItem9);
//---- menuItem10 ----
menuItem10.setText("text");
add(menuItem10);
addSeparator();
//---- checkBoxMenuItem5 ----
checkBoxMenuItem5.setText("text");
checkBoxMenuItem5.setSelected(true);
add(checkBoxMenuItem5);
//======== menu7 ========
{
menu7.setText("text");
//---- menuItem11 ----
menuItem11.setText("text");
menu7.add(menuItem11);
//---- menuItem12 ----
menuItem12.setText("text");
menu7.add(menuItem12);
}
add(menu7);
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
// JFormDesigner - End of variables declaration //GEN-END:variables
}
}

View File

@@ -0,0 +1,310 @@
JFDML JFormDesigner: "7.0.0.0.194" Java: "11.0.2" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
root: new FormRoot {
auxiliary() {
"JavaCodeGenerator.defaultVariableLocal": true
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 0,hidemode 3,gap 5 5,ltr"
"$columnConstraints": "[125][][][][]"
"$rowConstraints": "[][top][][]"
} ) {
name: "this"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "menuBarLabel"
"text": "JMenuBar:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormContainer( "javax.swing.JMenuBar", new FormLayoutManager( class javax.swing.JMenuBar ) ) {
name: "menuBar1"
add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) {
name: "menu5"
"text": "text"
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem7"
"text": "text"
} )
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem8"
"text": "text"
} )
} )
add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) {
name: "menu6"
"text": "text"
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem5"
"text": "text"
} )
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem6"
"text": "text"
} )
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0 4 1,growx"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$columnConstraints": "[125,left][fill]"
"$rowConstraints": "[][][][][]"
"$layoutConstraints": "insets 0,hidemode 3,gap 5 5,ltr"
} ) {
name: "panel1"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "menuLabel"
"text": "JMenu:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) {
name: "menu1"
"text": "enabled"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "menuItemLabel"
"text": "JMenuItem:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem1"
"text": "enabled"
"accelerator": static javax.swing.KeyStroke getKeyStroke( 65, 130, false )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "checkBoxMenuItemLabel"
"text": "JCheckBoxMenuItem:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) {
name: "checkBoxMenuItem1"
"text": "enabled"
"accelerator": &KeyStroke0 static javax.swing.KeyStroke getKeyStroke( 112, 0, false )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "radioButtonMenuItemLabel"
"text": "JRadioButtonMenuItem:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
add( new FormComponent( "javax.swing.JRadioButtonMenuItem" ) {
name: "radioButtonMenuItem1"
"text": "enabled"
"accelerator": #KeyStroke0
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "popupMenuSeparatorLabel"
"text": "JPopupMenu.Separator:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
} )
add( new FormComponent( "javax.swing.JPopupMenu$Separator" ) {
name: "separator1"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1 2 1"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$columnConstraints": "[fill]"
"$rowConstraints": "[][][][][]"
"$layoutConstraints": "insets 0,gap 5 5"
} ) {
name: "panel2"
add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) {
name: "menu2"
"text": "disabled"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem2"
"text": "disabled"
"enabled": false
"accelerator": static javax.swing.KeyStroke getKeyStroke( 68, 585, false )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) {
name: "checkBoxMenuItem2"
"text": "disabled"
"enabled": false
"accelerator": #KeyStroke0
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "javax.swing.JRadioButtonMenuItem" ) {
name: "radioButtonMenuItem2"
"text": "disabled"
"enabled": false
"accelerator": #KeyStroke0
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 1"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$columnConstraints": "[fill]"
"$rowConstraints": "[][][][]"
"$layoutConstraints": "insets 0,gap 5 5"
} ) {
name: "panel3"
add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) {
name: "menu3"
"text": "text"
"visible": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem3"
"text": "selected"
"selected": true
"accelerator": #KeyStroke0
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) {
name: "checkBoxMenuItem3"
"text": "selected"
"selected": true
"accelerator": #KeyStroke0
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "javax.swing.JRadioButtonMenuItem" ) {
name: "radioButtonMenuItem3"
"text": "selected"
"selected": true
"accelerator": #KeyStroke0
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 1"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$columnConstraints": "[fill]"
"$rowConstraints": "[][][][]"
"$layoutConstraints": "insets 0,gap 5 5"
} ) {
name: "panel4"
add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) {
name: "menu4"
"text": "text"
"visible": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem4"
"text": "selected disabled"
"selected": true
"enabled": false
"accelerator": #KeyStroke0
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) {
name: "checkBoxMenuItem4"
"text": "selected disabled"
"enabled": false
"selected": true
"accelerator": #KeyStroke0
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "javax.swing.JRadioButtonMenuItem" ) {
name: "radioButtonMenuItem4"
"text": "selected disabled"
"enabled": false
"selected": true
"accelerator": #KeyStroke0
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "popupMenuLabel"
"text": "JPopupMenu:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "showPopupMenuButton"
"text": "show JPopupMenu"
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showPopupMenuButtonActionPerformed", true ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "armedCheckBox"
"text": "armed"
"mnemonic": 65
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "armedChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 790, 380 )
} )
add( new FormContainer( "javax.swing.JPopupMenu", new FormLayoutManager( class javax.swing.JPopupMenu ) ) {
name: "popupMenu1"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
"JavaCodeGenerator.className": "PopupMenu"
}
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem9"
"text": "text"
} )
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem10"
"text": "text"
} )
add( new FormComponent( "javax.swing.JPopupMenu$Separator" ) {
name: "separator2"
} )
add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) {
name: "checkBoxMenuItem5"
"text": "text"
"selected": true
} )
add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) {
name: "menu7"
"text": "text"
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem11"
"text": "text"
} )
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem12"
"text": "text"
} )
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 430 )
} )
}
}

View File

@@ -0,0 +1,350 @@
/*
* 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;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.*;
import javax.swing.border.*;
import net.miginfocom.swing.*;
/**
* @author Karl Tauber
*/
public class FlatOptionPaneTest
extends JPanel
{
public static void main( String[] args ) {
SwingUtilities.invokeLater( () -> {
FlatTestFrame frame = FlatTestFrame.create( args, "FlatOptionPaneTest" );
frame.showFrame( new FlatOptionPaneTest() );
} );
}
FlatOptionPaneTest() {
initComponents();
customOptionPane.setMessage( new Object[] {
"string",
"multi-\nline string",
new JCheckBox( "check box" ),
new JTextField( "text field" ),
"more text",
} );
customOptionPane.setOptions( new Object[] {
new JCheckBox( "check me" ),
"OK",
"Cancel",
} );
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JLabel plainLabel = new JLabel();
JPanel panel1 = new JPanel();
JOptionPane plainOptionPane = new JOptionPane();
plainShowDialogLabel = new FlatOptionPaneTest.ShowDialogLinkLabel();
JLabel errorLabel = new JLabel();
JPanel panel2 = new JPanel();
JOptionPane errorOptionPane = new JOptionPane();
errorShowDialogLabel = new FlatOptionPaneTest.ShowDialogLinkLabel();
JLabel informationLabel = new JLabel();
JPanel panel3 = new JPanel();
JOptionPane informationOptionPane = new JOptionPane();
informationShowDialogLabel = new FlatOptionPaneTest.ShowDialogLinkLabel();
JLabel questionLabel = new JLabel();
JPanel panel4 = new JPanel();
JOptionPane questionOptionPane = new JOptionPane();
FlatOptionPaneTest.ShowDialogLinkLabel questionShowDialogLabel = new FlatOptionPaneTest.ShowDialogLinkLabel();
JLabel warningLabel = new JLabel();
JPanel panel5 = new JPanel();
JOptionPane warningOptionPane = new JOptionPane();
FlatOptionPaneTest.ShowDialogLinkLabel warningShowDialogLabel = new FlatOptionPaneTest.ShowDialogLinkLabel();
JLabel inputLabel = new JLabel();
JPanel panel7 = new JPanel();
JOptionPane inputOptionPane = new JOptionPane();
FlatOptionPaneTest.ShowDialogLinkLabel inputShowDialogLabel = new FlatOptionPaneTest.ShowDialogLinkLabel();
JLabel inputIconLabel = new JLabel();
JPanel panel8 = new JPanel();
JOptionPane inputIconOptionPane = new JOptionPane();
FlatOptionPaneTest.ShowDialogLinkLabel inputIconShowDialogLabel = new FlatOptionPaneTest.ShowDialogLinkLabel();
JLabel customLabel = new JLabel();
JPanel panel6 = new JPanel();
customOptionPane = new JOptionPane();
FlatOptionPaneTest.ShowDialogLinkLabel customShowDialogLabel = new FlatOptionPaneTest.ShowDialogLinkLabel();
//======== this ========
setLayout(new MigLayout(
"flowy,ltr,insets 0,hidemode 3,gap 5 5",
// columns
"[]" +
"[]" +
"[fill]",
// rows
"[top]" +
"[top]" +
"[top]" +
"[top]" +
"[top]" +
"[top]" +
"[top]" +
"[top]"));
//---- plainLabel ----
plainLabel.setText("Plain");
add(plainLabel, "cell 0 0");
//======== panel1 ========
{
panel1.setBorder(LineBorder.createGrayLineBorder());
panel1.setLayout(new BorderLayout());
//---- plainOptionPane ----
plainOptionPane.setMessage("Hello world.");
panel1.add(plainOptionPane, BorderLayout.CENTER);
}
add(panel1, "cell 1 0");
//---- plainShowDialogLabel ----
plainShowDialogLabel.setOptionPane(plainOptionPane);
plainShowDialogLabel.setTitleLabel(plainLabel);
add(plainShowDialogLabel, "cell 2 0");
//---- errorLabel ----
errorLabel.setText("Error");
add(errorLabel, "cell 0 1");
//======== panel2 ========
{
panel2.setBorder(LineBorder.createGrayLineBorder());
panel2.setLayout(new BorderLayout());
//---- errorOptionPane ----
errorOptionPane.setMessageType(JOptionPane.ERROR_MESSAGE);
errorOptionPane.setOptionType(JOptionPane.OK_CANCEL_OPTION);
errorOptionPane.setMessage("Your PC ran into a problem. Buy a new one.");
panel2.add(errorOptionPane, BorderLayout.CENTER);
}
add(panel2, "cell 1 1");
//---- errorShowDialogLabel ----
errorShowDialogLabel.setTitleLabel(errorLabel);
errorShowDialogLabel.setOptionPane(errorOptionPane);
add(errorShowDialogLabel, "cell 2 1");
//---- informationLabel ----
informationLabel.setText("Information");
add(informationLabel, "cell 0 2");
//======== panel3 ========
{
panel3.setBorder(LineBorder.createGrayLineBorder());
panel3.setLayout(new BorderLayout());
//---- informationOptionPane ----
informationOptionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE);
informationOptionPane.setOptionType(JOptionPane.YES_NO_OPTION);
informationOptionPane.setMessage("Text with\nmultiple lines\n(use \\n to separate lines)");
panel3.add(informationOptionPane, BorderLayout.CENTER);
}
add(panel3, "cell 1 2");
//---- informationShowDialogLabel ----
informationShowDialogLabel.setOptionPane(informationOptionPane);
informationShowDialogLabel.setTitleLabel(informationLabel);
add(informationShowDialogLabel, "cell 2 2");
//---- questionLabel ----
questionLabel.setText("Question");
add(questionLabel, "cell 0 3");
//======== panel4 ========
{
panel4.setBorder(LineBorder.createGrayLineBorder());
panel4.setLayout(new BorderLayout());
//---- questionOptionPane ----
questionOptionPane.setMessageType(JOptionPane.QUESTION_MESSAGE);
questionOptionPane.setOptionType(JOptionPane.YES_NO_CANCEL_OPTION);
questionOptionPane.setMessage("Answer the question. What question? Don't know. Just writing useless text to make this longer than 80 characters.");
panel4.add(questionOptionPane, BorderLayout.CENTER);
}
add(panel4, "cell 1 3");
//---- questionShowDialogLabel ----
questionShowDialogLabel.setOptionPane(questionOptionPane);
questionShowDialogLabel.setTitleLabel(questionLabel);
add(questionShowDialogLabel, "cell 2 3");
//---- warningLabel ----
warningLabel.setText("Warning");
add(warningLabel, "cell 0 4");
//======== panel5 ========
{
panel5.setBorder(LineBorder.createGrayLineBorder());
panel5.setLayout(new BorderLayout());
//---- warningOptionPane ----
warningOptionPane.setMessageType(JOptionPane.WARNING_MESSAGE);
warningOptionPane.setOptionType(JOptionPane.OK_CANCEL_OPTION);
warningOptionPane.setMessage("<html>I like <b>bold</b>,<br> and I like <i>italic</i>,<br> and I like to have<br> many lines.<br> Lots of lines.");
panel5.add(warningOptionPane, BorderLayout.CENTER);
}
add(panel5, "cell 1 4");
//---- warningShowDialogLabel ----
warningShowDialogLabel.setOptionPane(warningOptionPane);
warningShowDialogLabel.setTitleLabel(warningLabel);
add(warningShowDialogLabel, "cell 2 4");
//---- inputLabel ----
inputLabel.setText("Input");
add(inputLabel, "cell 0 5");
//======== panel7 ========
{
panel7.setBorder(LineBorder.createGrayLineBorder());
panel7.setLayout(new BorderLayout());
//---- inputOptionPane ----
inputOptionPane.setWantsInput(true);
inputOptionPane.setOptionType(JOptionPane.OK_CANCEL_OPTION);
inputOptionPane.setMessage("Enter whatever you want:");
panel7.add(inputOptionPane, BorderLayout.CENTER);
}
add(panel7, "cell 1 5");
//---- inputShowDialogLabel ----
inputShowDialogLabel.setOptionPane(inputOptionPane);
inputShowDialogLabel.setTitleLabel(inputLabel);
add(inputShowDialogLabel, "cell 2 5");
//---- inputIconLabel ----
inputIconLabel.setText("Input + icon");
add(inputIconLabel, "cell 0 6");
//======== panel8 ========
{
panel8.setBorder(LineBorder.createGrayLineBorder());
panel8.setLayout(new BorderLayout());
//---- inputIconOptionPane ----
inputIconOptionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE);
inputIconOptionPane.setWantsInput(true);
inputIconOptionPane.setOptionType(JOptionPane.OK_CANCEL_OPTION);
inputIconOptionPane.setMessage("Enter something:");
panel8.add(inputIconOptionPane, BorderLayout.CENTER);
}
add(panel8, "cell 1 6");
//---- inputIconShowDialogLabel ----
inputIconShowDialogLabel.setTitleLabel(inputIconLabel);
inputIconShowDialogLabel.setOptionPane(inputIconOptionPane);
add(inputIconShowDialogLabel, "cell 2 6");
//---- customLabel ----
customLabel.setText("Custom");
add(customLabel, "cell 0 7");
//======== panel6 ========
{
panel6.setBorder(LineBorder.createGrayLineBorder());
panel6.setLayout(new BorderLayout());
//---- customOptionPane ----
customOptionPane.setIcon(UIManager.getIcon("Tree.leafIcon"));
panel6.add(customOptionPane, BorderLayout.CENTER);
}
add(panel6, "cell 1 7");
//---- customShowDialogLabel ----
customShowDialogLabel.setOptionPane(customOptionPane);
customShowDialogLabel.setTitleLabel(customLabel);
add(customShowDialogLabel, "cell 2 7");
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private FlatOptionPaneTest.ShowDialogLinkLabel plainShowDialogLabel;
private FlatOptionPaneTest.ShowDialogLinkLabel errorShowDialogLabel;
private FlatOptionPaneTest.ShowDialogLinkLabel informationShowDialogLabel;
private JOptionPane customOptionPane;
// JFormDesigner - End of variables declaration //GEN-END:variables
//---- class ShowDialogLinkLabel ------------------------------------------
private static class ShowDialogLinkLabel
extends JLabel
{
private JLabel titleLabel;
private JOptionPane optionPane;
ShowDialogLinkLabel() {
setText( "<html><a href=\"#\" color=\"#589df6\">Show dialog</a></html>" );
addMouseListener( new MouseAdapter() {
@Override
public void mouseClicked( MouseEvent e ) {
showDialog();
}
} );
}
private void showDialog() {
if( optionPane.getWantsInput() ) {
JOptionPane.showInputDialog(
getParent(),
optionPane.getMessage(),
titleLabel.getText() + " Title",
optionPane.getMessageType(),
optionPane.getIcon(),
null,
null );
} else {
JOptionPane.showOptionDialog(
getParent(),
optionPane.getMessage(),
titleLabel.getText() + " Title",
optionPane.getOptionType(),
optionPane.getMessageType(),
optionPane.getIcon(),
optionPane.getOptions(),
optionPane.getInitialValue() );
}
}
@SuppressWarnings( "unused" )
public JLabel getTitleLabel() {
return titleLabel;
}
public void setTitleLabel( JLabel titleLabel ) {
this.titleLabel = titleLabel;
}
@SuppressWarnings( "unused" )
public JOptionPane getOptionPane() {
return optionPane;
}
public void setOptionPane( JOptionPane optionPane ) {
this.optionPane = optionPane;
}
}
}

View File

@@ -0,0 +1,245 @@
JFDML JFormDesigner: "7.0.0.0.194" Java: "11.0.2" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
root: new FormRoot {
auxiliary() {
"JavaCodeGenerator.defaultVariableLocal": true
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "flowy,ltr,insets 0,hidemode 3,gap 5 5"
"$columnConstraints": "[][][fill]"
"$rowConstraints": "[top][top][top][top][top][top][top][top]"
} ) {
name: "this"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "plainLabel"
"text": "Plain"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) {
name: "panel1"
"border": &LineBorder0 new javax.swing.border.LineBorder( sfield java.awt.Color gray, 1, false )
add( new FormComponent( "javax.swing.JOptionPane" ) {
name: "plainOptionPane"
"message": "Hello world."
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "Center"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "com.formdev.flatlaf.FlatOptionPaneTest$ShowDialogLinkLabel" ) {
name: "plainShowDialogLabel"
"optionPane": new FormReference( "plainOptionPane" )
"titleLabel": new FormReference( "plainLabel" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "errorLabel"
"text": "Error"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) {
name: "panel2"
"border": #LineBorder0
add( new FormComponent( "javax.swing.JOptionPane" ) {
name: "errorOptionPane"
"messageType": 0
"optionType": 2
"message": "Your PC ran into a problem. Buy a new one."
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "Center"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
} )
add( new FormComponent( "com.formdev.flatlaf.FlatOptionPaneTest$ShowDialogLinkLabel" ) {
name: "errorShowDialogLabel"
"titleLabel": new FormReference( "errorLabel" )
"optionPane": new FormReference( "errorOptionPane" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "informationLabel"
"text": "Information"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) {
name: "panel3"
"border": #LineBorder0
add( new FormComponent( "javax.swing.JOptionPane" ) {
name: "informationOptionPane"
"messageType": 1
"optionType": 0
"message": "Text with\nmultiple lines\n(use \\n to separate lines)"
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "Center"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "com.formdev.flatlaf.FlatOptionPaneTest$ShowDialogLinkLabel" ) {
name: "informationShowDialogLabel"
"optionPane": new FormReference( "informationOptionPane" )
"titleLabel": new FormReference( "informationLabel" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "questionLabel"
"text": "Question"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) {
name: "panel4"
"border": #LineBorder0
add( new FormComponent( "javax.swing.JOptionPane" ) {
name: "questionOptionPane"
"messageType": 3
"optionType": 1
"message": "Answer the question. What question? Don't know. Just writing useless text to make this longer than 80 characters."
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "Center"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3"
} )
add( new FormComponent( "com.formdev.flatlaf.FlatOptionPaneTest$ShowDialogLinkLabel" ) {
name: "questionShowDialogLabel"
"optionPane": new FormReference( "questionOptionPane" )
"titleLabel": new FormReference( "questionLabel" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 3"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "warningLabel"
"text": "Warning"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) {
name: "panel5"
"border": #LineBorder0
add( new FormComponent( "javax.swing.JOptionPane" ) {
name: "warningOptionPane"
"messageType": 2
"optionType": 2
"message": "<html>I like <b>bold</b>,<br> and I like <i>italic</i>,<br> and I like to have<br> many lines.<br> Lots of lines."
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "Center"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4"
} )
add( new FormComponent( "com.formdev.flatlaf.FlatOptionPaneTest$ShowDialogLinkLabel" ) {
name: "warningShowDialogLabel"
"optionPane": new FormReference( "warningOptionPane" )
"titleLabel": new FormReference( "warningLabel" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 4"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "inputLabel"
"text": "Input"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) {
name: "panel7"
"border": #LineBorder0
add( new FormComponent( "javax.swing.JOptionPane" ) {
name: "inputOptionPane"
"wantsInput": true
"optionType": 2
"message": "Enter whatever you want:"
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "Center"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5"
} )
add( new FormComponent( "com.formdev.flatlaf.FlatOptionPaneTest$ShowDialogLinkLabel" ) {
name: "inputShowDialogLabel"
"optionPane": new FormReference( "inputOptionPane" )
"titleLabel": new FormReference( "inputLabel" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 5"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "inputIconLabel"
"text": "Input + icon"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) {
name: "panel8"
"border": #LineBorder0
add( new FormComponent( "javax.swing.JOptionPane" ) {
name: "inputIconOptionPane"
"messageType": 1
"wantsInput": true
"optionType": 2
"message": "Enter something:"
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "Center"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 6"
} )
add( new FormComponent( "com.formdev.flatlaf.FlatOptionPaneTest$ShowDialogLinkLabel" ) {
name: "inputIconShowDialogLabel"
"titleLabel": new FormReference( "inputIconLabel" )
"optionPane": new FormReference( "inputIconOptionPane" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 6"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "customLabel"
"text": "Custom"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 7"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) {
name: "panel6"
"border": #LineBorder0
add( new FormComponent( "javax.swing.JOptionPane" ) {
name: "customOptionPane"
"icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.leafIcon" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "Center"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 7"
} )
add( new FormComponent( "com.formdev.flatlaf.FlatOptionPaneTest$ShowDialogLinkLabel" ) {
name: "customShowDialogLabel"
"optionPane": new FormReference( "customOptionPane" )
"titleLabel": new FormReference( "customLabel" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 7"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 790, 840 )
} )
}
}

View File

@@ -0,0 +1,535 @@
/*
* 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;
import java.awt.*;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.function.BiConsumer;
import java.util.prefs.Preferences;
import javax.swing.*;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.formdev.flatlaf.util.SystemInfo;
import com.formdev.flatlaf.util.UIScale;
import net.miginfocom.swing.*;
/**
* @author Karl Tauber
*/
public class FlatTestFrame
extends JFrame
{
private static final String PREFS_ROOT_PATH = "/flatlaf-test";
private static final String KEY_LAF = "laf";
private static final String KEY_SCALE_FACTOR = "scaleFactor";
private final String title;
private JComponent content;
private FlatInspector inspector;
public boolean useApplyComponentOrientation;
public static FlatTestFrame create( String[] args, String title ) {
Preferences prefs = Preferences.userRoot().node( PREFS_ROOT_PATH );
// set scale factor
if( System.getProperty( "flatlaf.uiScale", System.getProperty( "sun.java2d.uiScale" ) ) == null ) {
String scaleFactor = prefs.get( KEY_SCALE_FACTOR, null );
if( scaleFactor != null )
System.setProperty( "flatlaf.uiScale", scaleFactor );
}
// set look and feel
try {
if( args.length > 0 )
UIManager.setLookAndFeel( args[0] );
else {
String lafClassName = prefs.get( KEY_LAF, FlatLightLaf.class.getName() );
UIManager.setLookAndFeel( lafClassName );
}
} catch( Exception ex ) {
ex.printStackTrace();
// fallback
FlatLightLaf.install();
}
// create frame
return new FlatTestFrame( title );
}
private FlatTestFrame( String title ) {
this.title = title;
initComponents();
// initialize look and feels combo box
DefaultComboBoxModel<LafInfo> lafModel = new DefaultComboBoxModel<>();
lafModel.addElement( new LafInfo( "Flat Light (F1)", FlatLightLaf.class.getName() ) );
lafModel.addElement( new LafInfo( "Flat Dark (F2)", FlatDarkLaf.class.getName() ) );
lafModel.addElement( new LafInfo( "Flat IntelliJ (F3)", FlatIntelliJLaf.class.getName() ) );
lafModel.addElement( new LafInfo( "Flat Darcula (F4)", FlatDarculaLaf.class.getName() ) );
lafModel.addElement( new LafInfo( "Flat Test (F8)", FlatTestLaf.class.getName() ) );
UIManager.LookAndFeelInfo[] lookAndFeels = UIManager.getInstalledLookAndFeels();
for( UIManager.LookAndFeelInfo lookAndFeel : lookAndFeels ) {
String name = lookAndFeel.getName();
String className = lookAndFeel.getClassName();
if( className.equals( "com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel" ) ||
className.equals( "com.sun.java.swing.plaf.motif.MotifLookAndFeel" ) )
continue;
if( (SystemInfo.IS_WINDOWS && className.equals( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" )) ||
(SystemInfo.IS_MAC && className.equals( "com.apple.laf.AquaLookAndFeel") ) ||
(SystemInfo.IS_LINUX && className.equals( "com.sun.java.swing.plaf.gtk.GTKLookAndFeel") ) )
name += " (F9)";
else if( className.equals( MetalLookAndFeel.class.getName() ) )
name += " (F10)";
else if( className.equals( NimbusLookAndFeel.class.getName() ) )
name += " (F11)";
lafModel.addElement( new LafInfo( 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 );
updateScaleFactorComboBox();
String scaleFactor = System.getProperty( "flatlaf.uiScale", System.getProperty( "sun.java2d.uiScale" ) );
if( scaleFactor != null )
scaleFactorComboBox.setSelectedItem( scaleFactor );
// register F1, F2, ... keys to switch to Light, Dark or other LaFs
registerSwitchToLookAndFeel( KeyEvent.VK_F1, FlatLightLaf.class.getName() );
registerSwitchToLookAndFeel( KeyEvent.VK_F2, FlatDarkLaf.class.getName() );
registerSwitchToLookAndFeel( KeyEvent.VK_F3, FlatIntelliJLaf.class.getName() );
registerSwitchToLookAndFeel( KeyEvent.VK_F4, FlatDarculaLaf.class.getName() );
registerSwitchToLookAndFeel( KeyEvent.VK_F8, FlatTestLaf.class.getName() );
if( SystemInfo.IS_WINDOWS )
registerSwitchToLookAndFeel( KeyEvent.VK_F9, "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" );
else if( SystemInfo.IS_MAC )
registerSwitchToLookAndFeel( KeyEvent.VK_F9, "com.apple.laf.AquaLookAndFeel" );
else if( SystemInfo.IS_LINUX )
registerSwitchToLookAndFeel( KeyEvent.VK_F9, "com.sun.java.swing.plaf.gtk.GTKLookAndFeel" );
registerSwitchToLookAndFeel( KeyEvent.VK_F10, MetalLookAndFeel.class.getName() );
registerSwitchToLookAndFeel( KeyEvent.VK_F11, NimbusLookAndFeel.class.getName() );
// register ESC key to close frame
((JComponent)getContentPane()).registerKeyboardAction(
e -> {
dispose();
},
KeyStroke.getKeyStroke( KeyEvent.VK_ESCAPE, 0, false ),
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
// close frame
closeButton.addActionListener(e -> dispose());
// update title
addWindowListener( new WindowAdapter() {
@Override
public void windowOpened( WindowEvent e ) {
updateTitle();
}
} );
// update title when moved to another screen
addComponentListener( new ComponentAdapter() {
@Override
public void componentMoved( ComponentEvent e ) {
updateTitle();
}
} );
UIManager.addPropertyChangeListener( e -> {
if( "lookAndFeel".equals( e.getPropertyName() ) ) {
EventQueue.invokeLater( () -> {
// update title because user scale factor may change
updateTitle();
// enable/disable scale factor combobox
updateScaleFactorComboBox();
} );
}
} );
}
private void updateTitle() {
double systemScaleFactor = UIScale.getSystemScaleFactor( getGraphicsConfiguration() );
float userScaleFactor = UIScale.getUserScaleFactor();
String newTitle = title + " (Java " + System.getProperty( "java.version" )
+ (systemScaleFactor != 1 ? ("; system scale factor " + systemScaleFactor) : "")
+ (userScaleFactor != 1 ? ("; user scale factor " + userScaleFactor) : "")
+ (systemScaleFactor == 1 && userScaleFactor == 1 ? "; no scaling" : "")
+ ")";
if( !newTitle.equals( getTitle() ) )
setTitle( newTitle );
}
private void registerSwitchToLookAndFeel( int keyCode, String lafClassName ) {
((JComponent)getContentPane()).registerKeyboardAction(
e -> {
selectLookAndFeel( lafClassName );
},
KeyStroke.getKeyStroke( keyCode, 0, false ),
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
}
public void showFrame( JComponent content ) {
this.content = content;
contentPanel.getContentPane().add( content );
pack();
setLocationRelativeTo( null );
setVisible( true );
EventQueue.invokeLater( () -> {
closeButton.requestFocusInWindow();
} );
}
private void selectLookAndFeel( String lafClassName ) {
DefaultComboBoxModel<LafInfo> lafModel = (DefaultComboBoxModel<LafInfo>) lookAndFeelComboBox.getModel();
int sel = lafModel.getIndexOf( new LafInfo( null, lafClassName ) );
if( sel >= 0 )
lookAndFeelComboBox.setSelectedIndex( sel );
}
private void lookAndFeelChanged() {
LafInfo newLaf = (LafInfo) lookAndFeelComboBox.getSelectedItem();
if( newLaf == null )
return;
if( newLaf.className.equals( UIManager.getLookAndFeel().getClass().getName() ) )
return;
// hide popup to avoid occasional StackOverflowError when updating UI
lookAndFeelComboBox.setPopupVisible( false );
Preferences.userRoot().node( PREFS_ROOT_PATH ).put( KEY_LAF, newLaf.className );
applyLookAndFeel( newLaf.className, false );
}
private void applyLookAndFeel( String lafClassName, boolean pack ) {
EventQueue.invokeLater( () -> {
try {
// change look and feel
UIManager.setLookAndFeel( lafClassName );
// update all components
FlatLaf.updateUI();
// increase size of frame if necessary
if( pack )
pack();
else {
int width = getWidth();
int height = getHeight();
Dimension prefSize = getPreferredSize();
if( prefSize.width > width || prefSize.height > height )
setSize( Math.max( prefSize.width, width ), Math.max( prefSize.height, height ) );
}
// limit frame size to screen size
Rectangle screenBounds = getGraphicsConfiguration().getBounds();
screenBounds = FlatUIUtils.subtractInsets( screenBounds, getToolkit().getScreenInsets( getGraphicsConfiguration() ) );
Dimension frameSize = getSize();
if( frameSize.width > screenBounds.width || frameSize.height > screenBounds.height )
setSize( Math.min( frameSize.width, screenBounds.width ), Math.min( frameSize.height, screenBounds.height ) );
// move frame to left/top if necessary
if( getX() + getWidth() > screenBounds.x + screenBounds.width ||
getY() + getHeight() > screenBounds.y + screenBounds.height )
{
setLocation( Math.min( getX(), screenBounds.x + screenBounds.width - getWidth() ),
Math.min( getY(), screenBounds.y + screenBounds.height - getHeight() ) );
}
if( inspector != null )
inspector.update();
} catch( Exception ex ) {
ex.printStackTrace();
}
} );
}
private void explicitColorsChanged() {
EventQueue.invokeLater( () -> {
boolean explicit = explicitColorsCheckBox.isSelected();
ColorUIResource restoreColor = new ColorUIResource( Color.white );
updateComponentsRecur( content, (c, type) -> {
if( type == "view" || type == "tab" ) {
c.setForeground( explicit ? Color.magenta : restoreColor );
c.setBackground( explicit ? Color.orange : restoreColor );
} else {
c.setForeground( explicit ? Color.blue : restoreColor );
c.setBackground( explicit ? Color.red : restoreColor );
}
} );
// because colors may depend on state (e.g. disabled JTextField)
// it is best to update all UI delegates to get correct result
if( !explicit )
SwingUtilities.updateComponentTreeUI( content );
} );
}
private void rightToLeftChanged() {
ComponentOrientation orientation = rightToLeftCheckBox.isSelected()
? ComponentOrientation.RIGHT_TO_LEFT
: ComponentOrientation.LEFT_TO_RIGHT;
if( useApplyComponentOrientation )
content.applyComponentOrientation( orientation );
else {
updateComponentsRecur( content, (c, type) -> {
c.setComponentOrientation( orientation );
} );
}
contentPanel.revalidate();
contentPanel.repaint();
}
private void enabledChanged() {
boolean enabled = enabledCheckBox.isSelected();
updateComponentsRecur( content, (c, type) -> {
c.setEnabled( enabled );
} );
}
private void inspectChanged() {
if( inspector == null )
inspector = new FlatInspector( contentPanel );
inspector.setEnabled( inspectCheckBox.isSelected() );
}
private void scaleFactorChanged() {
String scaleFactor = (String) scaleFactorComboBox.getSelectedItem();
if( "default".equals( scaleFactor ) )
scaleFactor = null;
// hide popup to avoid occasional StackOverflowError when updating UI
scaleFactorComboBox.setPopupVisible( false );
Preferences prefs = Preferences.userRoot().node( PREFS_ROOT_PATH );
if( scaleFactor != null ) {
System.setProperty( "flatlaf.uiScale", scaleFactor );
prefs.put( KEY_SCALE_FACTOR, scaleFactor );
} else {
System.clearProperty( "flatlaf.uiScale" );
prefs.remove( KEY_SCALE_FACTOR );
}
applyLookAndFeel( UIManager.getLookAndFeel().getClass().getName(), true );
}
private void updateScaleFactorComboBox() {
scaleFactorComboBox.setEnabled( !UIScale.isSystemScalingEnabled() && UIManager.getLookAndFeel() instanceof FlatLaf );
}
private void updateComponentsRecur( Container container, BiConsumer<Component, String> action ) {
for( Component c : container.getComponents() ) {
if( c instanceof JPanel ) {
updateComponentsRecur( (JPanel) c, action );
continue;
}
action.accept( c, null );
if( c instanceof JScrollPane ) {
Component view = ((JScrollPane)c).getViewport().getView();
if( view != null )
action.accept( view, "view" );
} else if( c instanceof JTabbedPane ) {
JTabbedPane tabPane = (JTabbedPane)c;
int tabCount = tabPane.getTabCount();
for( int i = 0; i < tabCount; i++ ) {
Component tab = tabPane.getComponentAt( i );
if( tab != null )
action.accept( tab, "tab" );
}
}
if( c instanceof JToolBar )
updateComponentsRecur( (JToolBar) c, action );
}
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
dialogPane = new JPanel();
contentPanel = new JRootPane();
buttonBar = new JPanel();
lookAndFeelComboBox = new JComboBox<>();
explicitColorsCheckBox = new JCheckBox();
rightToLeftCheckBox = new JCheckBox();
enabledCheckBox = new JCheckBox();
inspectCheckBox = new JCheckBox();
scaleFactorComboBox = new JComboBox<>();
closeButton = new JButton();
//======== this ========
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
//======== dialogPane ========
{
dialogPane.setLayout(new BorderLayout());
//======== contentPanel ========
{
Container contentPanelContentPane = contentPanel.getContentPane();
contentPanelContentPane.setLayout(new MigLayout(
"insets dialog,hidemode 3",
// columns
"[grow,fill]",
// rows
"[grow,fill]"));
}
dialogPane.add(contentPanel, BorderLayout.CENTER);
//======== buttonBar ========
{
buttonBar.setLayout(new MigLayout(
"insets dialog",
// columns
"[fill]" +
"[fill]" +
"[fill]" +
"[fill]" +
"[fill]" +
"[fill]" +
"[grow,fill]" +
"[button,fill]",
// rows
null));
//---- lookAndFeelComboBox ----
lookAndFeelComboBox.addActionListener(e -> lookAndFeelChanged());
buttonBar.add(lookAndFeelComboBox, "cell 0 0");
//---- explicitColorsCheckBox ----
explicitColorsCheckBox.setText("explicit colors");
explicitColorsCheckBox.setMnemonic('X');
explicitColorsCheckBox.addActionListener(e -> explicitColorsChanged());
buttonBar.add(explicitColorsCheckBox, "cell 1 0");
//---- rightToLeftCheckBox ----
rightToLeftCheckBox.setText("right-to-left");
rightToLeftCheckBox.setMnemonic('R');
rightToLeftCheckBox.addActionListener(e -> rightToLeftChanged());
buttonBar.add(rightToLeftCheckBox, "cell 2 0");
//---- enabledCheckBox ----
enabledCheckBox.setText("enabled");
enabledCheckBox.setMnemonic('E');
enabledCheckBox.setSelected(true);
enabledCheckBox.addActionListener(e -> enabledChanged());
buttonBar.add(enabledCheckBox, "cell 3 0");
//---- inspectCheckBox ----
inspectCheckBox.setText("inspect");
inspectCheckBox.setMnemonic('I');
inspectCheckBox.addActionListener(e -> inspectChanged());
buttonBar.add(inspectCheckBox, "cell 4 0");
//---- scaleFactorComboBox ----
scaleFactorComboBox.setModel(new DefaultComboBoxModel<>(new String[] {
"default",
"1",
"1.25",
"1.5",
"1.75",
"2.0",
"2.25",
"2.5",
"3",
"3.5",
"4"
}));
scaleFactorComboBox.setMaximumRowCount(20);
scaleFactorComboBox.addActionListener(e -> scaleFactorChanged());
buttonBar.add(scaleFactorComboBox, "cell 5 0");
//---- closeButton ----
closeButton.setText("Close");
buttonBar.add(closeButton, "cell 7 0");
}
dialogPane.add(buttonBar, BorderLayout.SOUTH);
}
contentPane.add(dialogPane, BorderLayout.CENTER);
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JPanel dialogPane;
private JRootPane contentPanel;
private JPanel buttonBar;
private JComboBox<LafInfo> lookAndFeelComboBox;
private JCheckBox explicitColorsCheckBox;
private JCheckBox rightToLeftCheckBox;
private JCheckBox enabledCheckBox;
private JCheckBox inspectCheckBox;
private JComboBox<String> scaleFactorComboBox;
private JButton closeButton;
// 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;
}
}
}

View File

@@ -0,0 +1,111 @@
JFDML JFormDesigner: "7.0.0.0.194" Java: "11.0.2" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
root: new FormRoot {
add( new FormWindow( "javax.swing.JFrame", new FormLayoutManager( class java.awt.BorderLayout ) ) {
name: "this"
"$locationPolicy": 2
"$sizePolicy": 2
"defaultCloseOperation": 2
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) {
name: "dialogPane"
add( new FormContainer( "javax.swing.JRootPane", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets dialog,hidemode 3"
"$columnConstraints": "[grow,fill]"
"$rowConstraints": "[grow,fill]"
} ) {
name: "contentPanel"
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "Center"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets dialog"
"$columnConstraints": "[fill][fill][fill][fill][fill][fill][grow,fill][button,fill]"
"$rowSpecs": "[fill]"
} ) {
name: "buttonBar"
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "lookAndFeelComboBox"
auxiliary() {
"JavaCodeGenerator.typeParameters": "LafInfo"
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "lookAndFeelChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "explicitColorsCheckBox"
"text": "explicit colors"
"mnemonic": 88
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "explicitColorsChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "rightToLeftCheckBox"
"text": "right-to-left"
"mnemonic": 82
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "rightToLeftChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "enabledCheckBox"
"text": "enabled"
"mnemonic": 69
"selected": true
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "enabledChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 0"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "inspectCheckBox"
"text": "inspect"
"mnemonic": 73
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "inspectChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 0"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "scaleFactorComboBox"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "default"
addElement( "default" )
addElement( "1" )
addElement( "1.25" )
addElement( "1.5" )
addElement( "1.75" )
addElement( "2.0" )
addElement( "2.25" )
addElement( "2.5" )
addElement( "3" )
addElement( "3.5" )
addElement( "4" )
}
"maximumRowCount": 20
auxiliary() {
"JavaCodeGenerator.typeParameters": "String"
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "scaleFactorChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 0"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "closeButton"
"text": "Close"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 7 0"
} )
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "South"
} )
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "Center"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 640, 300 )
} )
}
}

View File

@@ -0,0 +1,38 @@
/*
* 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;
/**
* A Flat LaF that has a test color scheme.
*
* Used to develop Flat LaF.
*
* @author Karl Tauber
*/
public class FlatTestLaf
extends FlatLaf
{
@Override
public String getName() {
return "Flat Test";
}
@Override
public String getDescription() {
return "Flat Test Look and Feel";
}
}

View File

@@ -0,0 +1,324 @@
/*
* 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.swingx;
import java.awt.*;
import java.util.Calendar;
import java.util.Date;
import javax.swing.*;
import net.miginfocom.swing.*;
import org.jdesktop.swingx.*;
import com.formdev.flatlaf.FlatTestFrame;
/**
* @author Karl Tauber
*/
public class FlatSwingXTest
extends JPanel
{
public static void main( String[] args ) {
SwingUtilities.invokeLater( () -> {
FlatTestFrame frame = FlatTestFrame.create( args, "FlatSwingXTest" );
frame.useApplyComponentOrientation = true;
frame.showFrame( new FlatSwingXTest() );
} );
}
FlatSwingXTest() {
initComponents();
Calendar calendar = Calendar.getInstance();
calendar.set( Calendar.DAY_OF_MONTH, 2 );
monthView1.setSelectionDate( calendar.getTime() );
calendar.set( Calendar.DAY_OF_MONTH, 9 );
monthView1.setFlaggedDates( calendar.getTime() );
calendar.set( Calendar.DAY_OF_MONTH, 16 );
monthView1.setUnselectableDates( calendar.getTime() );
}
private void busyChanged() {
boolean busy = busyCheckBox.isSelected();
xBusyLabel1.setBusy( busy );
xBusyLabel2.setBusy( busy );
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JLabel label1 = new JLabel();
JLabel label3 = new JLabel();
JLabel datePickerLabel = new JLabel();
JXDatePicker xDatePicker1 = new JXDatePicker();
JXDatePicker xDatePicker2 = new JXDatePicker();
JLabel label4 = new JLabel();
JLabel label5 = new JLabel();
JXDatePicker xDatePicker3 = new JXDatePicker();
JXDatePicker xDatePicker4 = new JXDatePicker();
JLabel monthViewLabel = new JLabel();
monthView1 = new JXMonthView();
monthView2 = new JXMonthView();
JLabel hyperlinkLabel = new JLabel();
JXHyperlink xHyperlink1 = new JXHyperlink();
JXHyperlink xHyperlink2 = new JXHyperlink();
JLabel label2 = new JLabel();
xBusyLabel1 = new JXBusyLabel();
xBusyLabel2 = new JXBusyLabel();
busyCheckBox = new JCheckBox();
JPanel panel2 = new JPanel();
JLabel taskPaneContainerLabel = new JLabel();
JLabel taskPaneLabel = new JLabel();
JScrollPane scrollPane1 = new JScrollPane();
JXTaskPaneContainer xTaskPaneContainer1 = new JXTaskPaneContainer();
JXTaskPane xTaskPane3 = new JXTaskPane();
JXHyperlink xHyperlink3 = new JXHyperlink();
JXHyperlink xHyperlink4 = new JXHyperlink();
JXHyperlink xHyperlink5 = new JXHyperlink();
JXTaskPane xTaskPane4 = new JXTaskPane();
JXHyperlink xHyperlink6 = new JXHyperlink();
JXHyperlink xHyperlink7 = new JXHyperlink();
JXTaskPane xTaskPane5 = new JXTaskPane();
JXHyperlink xHyperlink8 = new JXHyperlink();
JXTaskPane xTaskPane6 = new JXTaskPane();
JXHyperlink xHyperlink9 = new JXHyperlink();
JXHyperlink xHyperlink10 = new JXHyperlink();
JLabel headerLabel = new JLabel();
JXHeader xHeader1 = new JXHeader();
//======== this ========
setLayout(new MigLayout(
"hidemode 3,ltr",
// columns
"[left]" +
"[]" +
"[]" +
"[fill]",
// rows
"[]0" +
"[]" +
"[]0" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]"));
//---- label1 ----
label1.setText("enabled");
add(label1, "cell 1 0");
//---- label3 ----
label3.setText("disabled");
add(label3, "cell 2 0");
//---- datePickerLabel ----
datePickerLabel.setText("JXDatePicker:");
add(datePickerLabel, "cell 0 1");
add(xDatePicker1, "cell 1 1");
//---- xDatePicker2 ----
xDatePicker2.setEnabled(false);
add(xDatePicker2, "cell 2 1");
//---- label4 ----
label4.setText("not editable");
add(label4, "cell 1 2");
//---- label5 ----
label5.setText("not editable disabled");
add(label5, "cell 2 2");
//---- xDatePicker3 ----
xDatePicker3.setEditable(false);
add(xDatePicker3, "cell 1 3");
//---- xDatePicker4 ----
xDatePicker4.setEnabled(false);
xDatePicker4.setEditable(false);
add(xDatePicker4, "cell 2 3");
//---- monthViewLabel ----
monthViewLabel.setText("JXMonthView:");
add(monthViewLabel, "cell 0 4,aligny top,growy 0");
//---- monthView1 ----
monthView1.setTraversable(true);
monthView1.setShowingLeadingDays(true);
monthView1.setShowingTrailingDays(true);
monthView1.setShowingWeekNumber(true);
add(monthView1, "cell 1 4");
//---- monthView2 ----
monthView2.setTraversable(true);
monthView2.setShowingLeadingDays(true);
monthView2.setShowingTrailingDays(true);
monthView2.setShowingWeekNumber(true);
monthView2.setEnabled(false);
add(monthView2, "cell 2 4");
//---- hyperlinkLabel ----
hyperlinkLabel.setText("JXHyperlink:");
add(hyperlinkLabel, "cell 0 5");
//---- xHyperlink1 ----
xHyperlink1.setText("enabled");
add(xHyperlink1, "cell 1 5");
//---- xHyperlink2 ----
xHyperlink2.setText("disabled");
xHyperlink2.setEnabled(false);
add(xHyperlink2, "cell 2 5");
//---- label2 ----
label2.setText("JXBusyLabel:");
add(label2, "cell 0 6");
//---- xBusyLabel1 ----
xBusyLabel1.setText("enabled");
add(xBusyLabel1, "cell 1 6");
//---- xBusyLabel2 ----
xBusyLabel2.setText("disabled");
xBusyLabel2.setEnabled(false);
add(xBusyLabel2, "cell 2 6,growx");
//---- busyCheckBox ----
busyCheckBox.setText("busy");
busyCheckBox.setMnemonic('B');
busyCheckBox.addActionListener(e -> busyChanged());
add(busyCheckBox, "cell 2 6");
//======== panel2 ========
{
panel2.setLayout(new MigLayout(
"ltr,insets 0,hidemode 3",
// columns
"[fill]",
// rows
"[]" +
"[]" +
"[]"));
//---- taskPaneContainerLabel ----
taskPaneContainerLabel.setText("JXTaskPaneContainer:");
panel2.add(taskPaneContainerLabel, "cell 0 0");
//---- taskPaneLabel ----
taskPaneLabel.setText("JXTaskPane:");
panel2.add(taskPaneLabel, "cell 0 1");
//======== scrollPane1 ========
{
//======== xTaskPaneContainer1 ========
{
//======== xTaskPane3 ========
{
xTaskPane3.setTitle("Basic Tasks");
Container xTaskPane3ContentPane = xTaskPane3.getContentPane();
//---- xHyperlink3 ----
xHyperlink3.setText("New");
xTaskPane3ContentPane.add(xHyperlink3);
//---- xHyperlink4 ----
xHyperlink4.setText("Open");
xTaskPane3ContentPane.add(xHyperlink4);
//---- xHyperlink5 ----
xHyperlink5.setText("Save");
xTaskPane3ContentPane.add(xHyperlink5);
}
xTaskPaneContainer1.add(xTaskPane3);
//======== xTaskPane4 ========
{
xTaskPane4.setTitle("Other Tasks");
xTaskPane4.setIcon(UIManager.getIcon("Tree.closedIcon"));
Container xTaskPane4ContentPane = xTaskPane4.getContentPane();
//---- xHyperlink6 ----
xHyperlink6.setText("Duplicate");
xTaskPane4ContentPane.add(xHyperlink6);
//---- xHyperlink7 ----
xHyperlink7.setText("Delete");
xTaskPane4ContentPane.add(xHyperlink7);
}
xTaskPaneContainer1.add(xTaskPane4);
//======== xTaskPane5 ========
{
xTaskPane5.setTitle("Special Tasks");
xTaskPane5.setSpecial(true);
Container xTaskPane5ContentPane = xTaskPane5.getContentPane();
//---- xHyperlink8 ----
xHyperlink8.setText("Go to space");
xTaskPane5ContentPane.add(xHyperlink8);
}
xTaskPaneContainer1.add(xTaskPane5);
//======== xTaskPane6 ========
{
xTaskPane6.setTitle("Collapsed");
xTaskPane6.setCollapsed(true);
Container xTaskPane6ContentPane = xTaskPane6.getContentPane();
//---- xHyperlink9 ----
xHyperlink9.setText("text");
xTaskPane6ContentPane.add(xHyperlink9);
//---- xHyperlink10 ----
xHyperlink10.setText("text");
xTaskPane6ContentPane.add(xHyperlink10);
}
xTaskPaneContainer1.add(xTaskPane6);
}
scrollPane1.setViewportView(xTaskPaneContainer1);
}
panel2.add(scrollPane1, "cell 0 2,width 150,height 350");
}
add(panel2, "cell 3 0 1 8,aligny top,growy 0");
//---- headerLabel ----
headerLabel.setText("JXHeader:");
add(headerLabel, "cell 0 7,aligny top,growy 0");
//---- xHeader1 ----
xHeader1.setTitle("Title");
xHeader1.setDescription("Description\nMore description");
xHeader1.setIcon(new ImageIcon(getClass().getResource("/org/jdesktop/swingx/plaf/windows/resources/tipoftheday.png")));
add(xHeader1, "cell 1 7 2 1,width 200");
// JFormDesigner - End of component initialization //GEN-END:initComponents
xDatePicker1.setDate( new Date() );
xDatePicker2.setDate( new Date() );
xDatePicker3.setDate( new Date() );
xDatePicker4.setDate( new Date() );
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JXMonthView monthView1;
private JXMonthView monthView2;
private JXBusyLabel xBusyLabel1;
private JXBusyLabel xBusyLabel2;
private JCheckBox busyCheckBox;
// JFormDesigner - End of variables declaration //GEN-END:variables
}

View File

@@ -0,0 +1,254 @@
JFDML JFormDesigner: "7.0.0.0.194" Java: "11.0.2" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
root: new FormRoot {
auxiliary() {
"JavaCodeGenerator.defaultVariableLocal": true
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "hidemode 3,ltr"
"$columnConstraints": "[left][][][fill]"
"$rowConstraints": "[]0[][]0[][][][][]"
} ) {
name: "this"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label1"
"text": "enabled"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label3"
"text": "disabled"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "datePickerLabel"
"text": "JXDatePicker:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "org.jdesktop.swingx.JXDatePicker" ) {
name: "xDatePicker1"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
} )
add( new FormComponent( "org.jdesktop.swingx.JXDatePicker" ) {
name: "xDatePicker2"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label4"
"text": "not editable"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label5"
"text": "not editable disabled"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 2"
} )
add( new FormComponent( "org.jdesktop.swingx.JXDatePicker" ) {
name: "xDatePicker3"
"editable": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3"
} )
add( new FormComponent( "org.jdesktop.swingx.JXDatePicker" ) {
name: "xDatePicker4"
"enabled": false
"editable": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 3"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "monthViewLabel"
"text": "JXMonthView:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4,aligny top,growy 0"
} )
add( new FormComponent( "org.jdesktop.swingx.JXMonthView" ) {
name: "monthView1"
"traversable": true
"showingLeadingDays": true
"showingTrailingDays": true
"showingWeekNumber": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4"
} )
add( new FormComponent( "org.jdesktop.swingx.JXMonthView" ) {
name: "monthView2"
"traversable": true
"showingLeadingDays": true
"showingTrailingDays": true
"showingWeekNumber": true
"enabled": false
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 4"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "hyperlinkLabel"
"text": "JXHyperlink:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5"
} )
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
name: "xHyperlink1"
"text": "enabled"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5"
} )
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
name: "xHyperlink2"
"text": "disabled"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 5"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label2"
"text": "JXBusyLabel:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6"
} )
add( new FormComponent( "org.jdesktop.swingx.JXBusyLabel" ) {
name: "xBusyLabel1"
"text": "enabled"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 6"
} )
add( new FormComponent( "org.jdesktop.swingx.JXBusyLabel" ) {
name: "xBusyLabel2"
"text": "disabled"
"enabled": false
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 6,growx"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "busyCheckBox"
"text": "busy"
"mnemonic": 66
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "busyChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 6"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$columnConstraints": "[fill]"
"$rowConstraints": "[][][]"
"$layoutConstraints": "ltr,insets 0,hidemode 3"
} ) {
name: "panel2"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "taskPaneContainerLabel"
"text": "JXTaskPaneContainer:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "taskPaneLabel"
"text": "JXTaskPane:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane1"
add( new FormContainer( "org.jdesktop.swingx.JXTaskPaneContainer", new FormLayoutManager( class com.jformdesigner.runtime.GenericIndexLayout ) ) {
name: "xTaskPaneContainer1"
add( new FormContainer( "org.jdesktop.swingx.JXTaskPane", new FormLayoutManager( class com.jformdesigner.runtime.GenericIndexLayout ) ) {
name: "xTaskPane3"
"title": "Basic Tasks"
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
name: "xHyperlink3"
"text": "New"
} )
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
name: "xHyperlink4"
"text": "Open"
} )
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
name: "xHyperlink5"
"text": "Save"
} )
} )
add( new FormContainer( "org.jdesktop.swingx.JXTaskPane", new FormLayoutManager( class com.jformdesigner.runtime.GenericIndexLayout ) ) {
name: "xTaskPane4"
"title": "Other Tasks"
"icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" )
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
name: "xHyperlink6"
"text": "Duplicate"
} )
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
name: "xHyperlink7"
"text": "Delete"
} )
} )
add( new FormContainer( "org.jdesktop.swingx.JXTaskPane", new FormLayoutManager( class com.jformdesigner.runtime.GenericIndexLayout ) ) {
name: "xTaskPane5"
"title": "Special Tasks"
"special": true
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
name: "xHyperlink8"
"text": "Go to space"
} )
} )
add( new FormContainer( "org.jdesktop.swingx.JXTaskPane", new FormLayoutManager( class com.jformdesigner.runtime.GenericIndexLayout ) ) {
name: "xTaskPane6"
"title": "Collapsed"
"collapsed": true
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
name: "xHyperlink9"
"text": "text"
} )
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
name: "xHyperlink10"
"text": "text"
} )
} )
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2,width 150,height 350"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 0 1 8,aligny top,growy 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "headerLabel"
"text": "JXHeader:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 7,aligny top,growy 0"
} )
add( new FormComponent( "org.jdesktop.swingx.JXHeader" ) {
name: "xHeader1"
"title": "Title"
"description": "Description\nMore description"
"icon": new com.jformdesigner.model.SwingIcon( 0, "/org/jdesktop/swingx/plaf/windows/resources/tipoftheday.png" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 7 2 1,width 200"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 700, 600 )
} )
}
}

View File

@@ -0,0 +1,265 @@
#
# 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.
#
#---- variables ----
@background=ccffcc
@selectionBackground=00aa00
@selectionInactiveBackground=888888
@selectionInactiveForeground=ffffff
@disabledText=000088
@textComponentBackground=ffffff
@cellFocusColor=ff0000
@icon=afafaf
#---- globals ----
*.background=@background
*.foreground=ff0000
*.textBackground=ccffcc
*.textForeground=ff0000
*.caretForeground=0000ff
*.inactiveBackground=f0f0f0
*.inactiveForeground=000088
*.selectionBackground=@selectionBackground
*.selectionForeground=ffff00
*.disabledBackground=e0e0e0
*.disabledForeground=@disabledText
*.disabledText=@disabledText
*.acceleratorForeground=ff8888
*.acceleratorSelectionForeground=ffffff
#---- Button ----
Button.background=ffffff
Button.focusedBackground=00ffff
Button.hoverBackground=ffff00
Button.pressedBackground=FFC800
Button.borderColor=0000ff
Button.disabledBorderColor=000088
Button.focusedBorderColor=466d94
Button.hoverBorderColor=ff0000
Button.default.background=dddddd
Button.default.foreground=880000
Button.default.focusedBackground=00ffff
Button.default.hoverBackground=ffff00
Button.default.pressedBackground=FFC800
Button.default.borderColor=ff0000
Button.default.hoverBorderColor=ff0000
Button.default.focusedBorderColor=537699
Button.default.focusColor=ff0000
Button.toolbar.hoverBackground=ffffff
Button.toolbar.pressedBackground=eeeeee
#---- CheckBox ----
CheckBox.icon.borderColor=878787
CheckBox.icon.disabledBorderColor=BDBDBD
CheckBox.icon.selectedBorderColor=4982CC
CheckBox.icon.focusedBorderColor=7B9FC7
CheckBox.icon.hoverBorderColor=ff0000
CheckBox.icon.selectedFocusedBorderColor=ACCFF7
CheckBox.icon.background=FFFFFF
CheckBox.icon.disabledBackground=F2F2F2
CheckBox.icon.focusedBackground=00ffff
CheckBox.icon.hoverBackground=ffff00
CheckBox.icon.pressedBackground=FFC800
CheckBox.icon.selectedBackground=4D89C9
CheckBox.icon.checkmarkColor=FFFFFF
CheckBox.icon.disabledCheckmarkColor=ABABAB
#---- ComboBox ----
ComboBox.background=ffffff
ComboBox.buttonBackground=f0f0f0
ComboBox.buttonEditableBackground=cccccc
ComboBox.buttonArrowColor=666666
ComboBox.buttonDisabledArrowColor=ABABAB
ComboBox.buttonHoverArrowColor=ff0000
#---- Component ----
Component.borderColor=ff0000
Component.disabledBorderColor=000088
Component.focusedBorderColor=466d94
Component.focusColor=97c3f3
#Component.focusWidth=5
#Component.arc=8
#---- HelpButton ----
HelpButton.questionMarkColor=0000ff
#---- Label ----
Label.foreground=008800
Label.disabledForeground=000088
#---- List ----
List.background=f0ffff
List.cellNoFocusBorder=1,6,1,6
List.focusSelectedCellHighlightBorder=1,6,1,6,880000
List.focusCellHighlightBorder=1,6,1,6,880000
#---- Menu ----
Menu.icon.arrowColor=4D89C9
Menu.icon.disabledArrowColor=ABABAB
#---- MenuBar ----
MenuBar.borderColor=4444ff
#---- MenuItemCheckBox ----
MenuItemCheckBox.icon.checkmarkColor=4D89C9
MenuItemCheckBox.icon.disabledCheckmarkColor=ABABAB
#---- OptionPane ----
OptionPane.icon.errorColor=ff0000
OptionPane.icon.informationColor=00ff00
OptionPane.icon.questionColor=0000ff
OptionPane.icon.warningColor=ffcc00
OptionPane.icon.foreground=ffffff
#---- PopupMenu ----
PopupMenu.borderColor=0000ff
#---- PopupMenuSeparator ----
PopupMenuSeparator.height=30
PopupMenuSeparator.stripeWidth=3
PopupMenuSeparator.stripeIndent=1
#---- ProgressBar ----
ProgressBar.background=88ff88
ProgressBar.foreground=33737373
ProgressBar.selectionForeground=ff0000
ProgressBar.selectionBackground=000088
ProgressBar.cycleTime=10000
#---- ScrollBar ----
ScrollBar.track=88ff88
ScrollBar.thumb=33737373
ScrollBar.hoverTrackColor=00ff00
ScrollBar.hoverThumbColor=ff0000
#---- Separator ----
Separator.foreground=00bb00
Separator.height=20
Separator.stripeWidth=10
Separator.stripeIndent=5
#---- Slider ----
Slider.trackColor=00bb00
Slider.thumbColor=880000
Slider.tickColor=ff0000
Slider.focusedColor=@@Component.focusColor
Slider.hoverColor=0000ff
Slider.disabledForeground=000088
#---- SplitPane ----
SplitPaneDivider.draggingColor=880000
SplitPaneDivider.oneTouchArrowColor=00ff00
SplitPaneDivider.oneTouchHoverArrowColor=ff0000
#---- TabbedPane ----
TabbedPane.disabledForeground=777777
TabbedPane.underlineColor=4A88C7
TabbedPane.disabledUnderlineColor=7a7a7a
TabbedPane.hoverColor=eeeeee
TabbedPane.focusColor=dddddd
TabbedPane.contentAreaColor=bbbbbb
#---- Table ----
Table.rowHeight=25
Table.background=fffff0
Table.sortIconColor=ffff00
Table.gridColor=00ffff
#---- TableHeader ----
TableHeader.background=4444ff
TableHeader.foreground=ffffff
TableHeader.separatorColor=00ff00
TableHeader.bottomSeparatorColor=00ff00
#---- TitledBorder ----
TitledBorder.titleColor=ff00ff
TitledBorder.border=1,1,1,1,ff00ff
#---- ToggleButton ----
ToggleButton.background=ddddff
ToggleButton.selectedBackground=44ff44
ToggleButton.selectedForeground=000000
ToggleButton.disabledSelectedBackground=44dd44
ToggleButton.focusedBackground=00ffff
ToggleButton.hoverBackground=ffff00
ToggleButton.pressedBackground=FFC800
ToggleButton.toolbar.selectedBackground=dddddd
#---- ToolTip ----
ToolTip.background=eeeeff
#---- Tree ----
Tree.background=fff0ff
Tree.paintLines=true
Tree.hash=ff0000

View File

@@ -0,0 +1,71 @@
#
# 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.
#
#---- BusyLabel ----
JXBusyLabel.baseColor=00ff00
JXBusyLabel.highlightColor=ff0000
#---- Header ----
JXHeader.background=ff8888
JXHeader.startBackground=ffcccc
JXHeader.titleForeground=0000ff
JXHeader.descriptionForeground=ff0000
#---- Hyperlink ----
Hyperlink.linkColor=ff0000
Hyperlink.visitedColor=0000ff
Hyperlink.disabledText=000088
#---- MonthView ----
JXMonthView.background=@textComponentBackground
JXMonthView.monthStringBackground=00ff00
JXMonthView.monthStringForeground=0000ff
JXMonthView.daysOfTheWeekForeground=00ff00
JXMonthView.weekOfTheYearForeground=0000ff
JXMonthView.unselectableDayForeground=0000ff
JXMonthView.selectedBackground=aaffaa
JXMonthView.flaggedDayForeground=00ffff
JXMonthView.leadingDayForeground=c0c0c0
JXMonthView.trailingDayForeground=c0c0c0
JXMonthView.arrowColor=0000ff
JXMonthView.disabledArrowColor=ABABAB
#---- TaskPaneContainer ----
TaskPaneContainer.background=ff8888
TaskPaneContainer.border=10,10,10,10
#---- TaskPane ----
TaskPane.background=00ff00
TaskPane.borderColor=0000ff
TaskPane.contentInsets=10,10,10,10
TaskPane.titleBackgroundGradientStart=ffff00
TaskPane.titleForeground=ff00ff
TaskPane.titleOver=0000aa
TaskPane.specialTitleBackground=00ffff
TaskPane.specialTitleForeground=444444
TaskPane.specialTitleOver=dd0000