Merge PR #988: System File Chooser

This commit is contained in:
Karl Tauber
2025-10-27 19:16:50 +01:00
56 changed files with 8559 additions and 76 deletions

View File

@@ -41,6 +41,7 @@ dependencies {
implementation( libs.jide.oss )
implementation( libs.glazedlists )
implementation( libs.netbeans.api.awt )
implementation( libs.nativejfilechooser )
components.all<TargetJvmVersion8Rule>()
}

View File

@@ -0,0 +1,382 @@
/*
* Copyright 2025 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.testing;
import static com.formdev.flatlaf.ui.FlatNativeLinuxLibrary.*;
import java.awt.EventQueue;
import java.awt.SecondaryLoop;
import java.awt.Toolkit;
import java.awt.Window;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicInteger;
import javax.swing.*;
import com.formdev.flatlaf.extras.components.*;
import com.formdev.flatlaf.extras.components.FlatTriStateCheckBox.State;
import com.formdev.flatlaf.testing.FlatSystemFileChooserTest.DummyModalDialog;
import com.formdev.flatlaf.ui.FlatNativeLinuxLibrary;
import net.miginfocom.swing.*;
/**
* @author Karl Tauber
*/
public class FlatSystemFileChooserLinuxTest
extends FlatTestPanel
{
public static void main( String[] args ) {
SwingUtilities.invokeLater( () -> {
if( !FlatNativeLinuxLibrary.isLoaded() ) {
JOptionPane.showMessageDialog( null, "FlatLaf native library not loaded" );
return;
}
FlatTestFrame frame = FlatTestFrame.create( args, "FlatSystemFileChooserLinuxTest" );
FlatSystemFileChooserTest.addListeners( frame );
frame.showFrame( FlatSystemFileChooserLinuxTest::new );
} );
}
FlatSystemFileChooserLinuxTest() {
initComponents();
fileTypesField.setSelectedItem( null );
}
private void open() {
openOrSave( true, false );
}
private void save() {
openOrSave( false, false );
}
private void openDirect() {
openOrSave( true, true );
}
private void saveDirect() {
openOrSave( false, true );
}
private void openOrSave( boolean open, boolean direct ) {
Window frame = SwingUtilities.windowForComponent( this );
if( ownerFrameRadioButton.isSelected() )
openOrSave( open, direct, frame );
else if( ownerDialogRadioButton.isSelected() )
new DummyModalDialog( frame, owner -> openOrSave( open, direct, owner ) ).setVisible( true );
else
openOrSave( open, direct, null );
}
private void openOrSave( boolean open, boolean direct, Window owner ) {
String title = n( titleField.getText() );
String okButtonLabel = n( okButtonLabelField.getText() );
String currentName = n( currentNameField.getText() );
String currentFolder = n( currentFolderField.getText() );
AtomicInteger optionsSet = new AtomicInteger();
AtomicInteger optionsClear = new AtomicInteger();
o( FC_select_folder, select_folderCheckBox, optionsSet, optionsClear );
o( FC_select_multiple, select_multipleCheckBox, optionsSet, optionsClear );
o( FC_show_hidden, show_hiddenCheckBox, optionsSet, optionsClear );
o( FC_local_only, local_onlyCheckBox, optionsSet, optionsClear );
o( FC_do_overwrite_confirmation, do_overwrite_confirmationCheckBox, optionsSet, optionsClear );
o( FC_create_folders, create_foldersCheckBox, optionsSet, optionsClear );
String fileTypesStr = n( (String) fileTypesField.getSelectedItem() );
String[] fileTypes = {};
if( fileTypesStr != null ) {
if( !fileTypesStr.endsWith( ",null" ) )
fileTypesStr += ",null";
fileTypes = fileTypesStr.trim().split( "[,]+" );
for( int i = 0; i < fileTypes.length; i++ ) {
if( "null".equals( fileTypes[i] ) )
fileTypes[i] = null;
}
}
int fileTypeIndex = fileTypeIndexSlider.getValue();
FlatNativeLinuxLibrary.FileChooserCallback callback = (files, hwndFileDialog) -> {
System.out.println( " -- callback " + hwndFileDialog + " " + Arrays.toString( files ) );
if( showMessageDialogOnOKCheckBox.isSelected() ) {
System.out.println( FlatNativeLinuxLibrary.showMessageDialog( hwndFileDialog,
JOptionPane.INFORMATION_MESSAGE,
"primary text", "secondary text", 1, "Yes", "No" ) );
}
return true;
};
System.out.println( FlatNativeLinuxLibrary.isGtk3Available() );
if( direct ) {
String[] files = FlatNativeLinuxLibrary.showFileChooser( owner, open,
title, okButtonLabel, currentName, currentFolder,
optionsSet.get(), optionsClear.get(), callback, fileTypeIndex, fileTypes );
filesField.setText( (files != null) ? Arrays.toString( files ).replace( ',', '\n' ) : "null" );
} else {
SecondaryLoop secondaryLoop = Toolkit.getDefaultToolkit().getSystemEventQueue().createSecondaryLoop();
String[] fileTypes2 = fileTypes;
new Thread( () -> {
String[] files = FlatNativeLinuxLibrary.showFileChooser( owner, open,
title, okButtonLabel, currentName, currentFolder,
optionsSet.get(), optionsClear.get(), callback, fileTypeIndex, fileTypes2 );
System.out.println( " secondaryLoop.exit() returned " + secondaryLoop.exit() );
EventQueue.invokeLater( () -> {
filesField.setText( (files != null) ? Arrays.toString( files ).replace( ',', '\n' ) : "null" );
} );
} ).start();
System.out.println( "---- enter secondary loop ----" );
System.out.println( "---- secondary loop exited (secondaryLoop.enter() returned " + secondaryLoop.enter() + ") ----" );
}
}
private static String n( String s ) {
return s != null && !s.isEmpty() ? s : null;
}
private static void o( int option, FlatTriStateCheckBox checkBox, AtomicInteger optionsSet, AtomicInteger optionsClear ) {
if( checkBox.getState() == State.SELECTED )
optionsSet.set( optionsSet.get() | option );
else if( checkBox.getState() == State.UNSELECTED )
optionsClear.set( optionsClear.get() | option );
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JLabel ownerLabel = new JLabel();
ownerFrameRadioButton = new JRadioButton();
ownerDialogRadioButton = new JRadioButton();
ownerNullRadioButton = new JRadioButton();
JPanel ownerSpacer = new JPanel(null);
JLabel titleLabel = new JLabel();
titleField = new JTextField();
JPanel panel1 = new JPanel();
select_folderCheckBox = new FlatTriStateCheckBox();
select_multipleCheckBox = new FlatTriStateCheckBox();
do_overwrite_confirmationCheckBox = new FlatTriStateCheckBox();
create_foldersCheckBox = new FlatTriStateCheckBox();
show_hiddenCheckBox = new FlatTriStateCheckBox();
local_onlyCheckBox = new FlatTriStateCheckBox();
JLabel okButtonLabelLabel = new JLabel();
okButtonLabelField = new JTextField();
JLabel currentNameLabel = new JLabel();
currentNameField = new JTextField();
JLabel currentFolderLabel = new JLabel();
currentFolderField = new JTextField();
JLabel fileTypesLabel = new JLabel();
fileTypesField = new JComboBox<>();
JLabel fileTypeIndexLabel = new JLabel();
fileTypeIndexSlider = new JSlider();
JButton openButton = new JButton();
JButton saveButton = new JButton();
JButton openDirectButton = new JButton();
JButton saveDirectButton = new JButton();
showMessageDialogOnOKCheckBox = new JCheckBox();
JScrollPane filesScrollPane = new JScrollPane();
filesField = new JTextArea();
//======== this ========
setLayout(new MigLayout(
"ltr,insets dialog,hidemode 3",
// columns
"[left]" +
"[grow,fill]" +
"[fill]",
// rows
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[grow,fill]"));
//---- ownerLabel ----
ownerLabel.setText("owner");
add(ownerLabel, "cell 0 0");
//---- ownerFrameRadioButton ----
ownerFrameRadioButton.setText("JFrame");
ownerFrameRadioButton.setSelected(true);
add(ownerFrameRadioButton, "cell 1 0");
//---- ownerDialogRadioButton ----
ownerDialogRadioButton.setText("JDialog");
add(ownerDialogRadioButton, "cell 1 0");
//---- ownerNullRadioButton ----
ownerNullRadioButton.setText("null");
add(ownerNullRadioButton, "cell 1 0");
add(ownerSpacer, "cell 1 0,growx");
//---- titleLabel ----
titleLabel.setText("title");
add(titleLabel, "cell 0 1");
add(titleField, "cell 1 1");
//======== panel1 ========
{
panel1.setLayout(new MigLayout(
"insets 2,hidemode 3",
// columns
"[left]",
// rows
"[]0" +
"[]0" +
"[]0" +
"[]0" +
"[]0" +
"[]"));
//---- select_folderCheckBox ----
select_folderCheckBox.setText("select_folder");
select_folderCheckBox.setAllowIndeterminate(false);
select_folderCheckBox.setState(FlatTriStateCheckBox.State.UNSELECTED);
panel1.add(select_folderCheckBox, "cell 0 0");
//---- select_multipleCheckBox ----
select_multipleCheckBox.setText("select_multiple");
select_multipleCheckBox.setState(FlatTriStateCheckBox.State.UNSELECTED);
select_multipleCheckBox.setAllowIndeterminate(false);
panel1.add(select_multipleCheckBox, "cell 0 1");
//---- do_overwrite_confirmationCheckBox ----
do_overwrite_confirmationCheckBox.setText("do_overwrite_confirmation");
panel1.add(do_overwrite_confirmationCheckBox, "cell 0 2");
//---- create_foldersCheckBox ----
create_foldersCheckBox.setText("create_folders");
panel1.add(create_foldersCheckBox, "cell 0 3");
//---- show_hiddenCheckBox ----
show_hiddenCheckBox.setText("show_hidden");
panel1.add(show_hiddenCheckBox, "cell 0 4");
//---- local_onlyCheckBox ----
local_onlyCheckBox.setText("local_only");
panel1.add(local_onlyCheckBox, "cell 0 5");
}
add(panel1, "cell 2 1 1 6,aligny top,growy 0");
//---- okButtonLabelLabel ----
okButtonLabelLabel.setText("okButtonLabel");
add(okButtonLabelLabel, "cell 0 2");
add(okButtonLabelField, "cell 1 2");
//---- currentNameLabel ----
currentNameLabel.setText("currentName");
add(currentNameLabel, "cell 0 3");
add(currentNameField, "cell 1 3");
//---- currentFolderLabel ----
currentFolderLabel.setText("currentFolder");
add(currentFolderLabel, "cell 0 4");
add(currentFolderField, "cell 1 4");
//---- fileTypesLabel ----
fileTypesLabel.setText("fileTypes");
add(fileTypesLabel, "cell 0 5");
//---- fileTypesField ----
fileTypesField.setEditable(true);
fileTypesField.setModel(new DefaultComboBoxModel<>(new String[] {
"Text Files,*.txt,null",
"All Files,*,null",
"Text Files,*.txt,null,PDF Files,*.pdf,null,All Files,*,null",
"Text and PDF Files,*.txt,*.pdf,null"
}));
add(fileTypesField, "cell 1 5");
//---- fileTypeIndexLabel ----
fileTypeIndexLabel.setText("fileTypeIndex");
add(fileTypeIndexLabel, "cell 0 6");
//---- fileTypeIndexSlider ----
fileTypeIndexSlider.setMaximum(10);
fileTypeIndexSlider.setMajorTickSpacing(1);
fileTypeIndexSlider.setValue(0);
fileTypeIndexSlider.setPaintLabels(true);
fileTypeIndexSlider.setSnapToTicks(true);
add(fileTypeIndexSlider, "cell 1 6");
//---- openButton ----
openButton.setText("Open...");
openButton.addActionListener(e -> open());
add(openButton, "cell 0 7 3 1");
//---- saveButton ----
saveButton.setText("Save...");
saveButton.addActionListener(e -> save());
add(saveButton, "cell 0 7 3 1");
//---- openDirectButton ----
openDirectButton.setText("Open (no-thread)...");
openDirectButton.addActionListener(e -> openDirect());
add(openDirectButton, "cell 0 7 3 1");
//---- saveDirectButton ----
saveDirectButton.setText("Save (no-thread)...");
saveDirectButton.addActionListener(e -> saveDirect());
add(saveDirectButton, "cell 0 7 3 1");
//---- showMessageDialogOnOKCheckBox ----
showMessageDialogOnOKCheckBox.setText("show message dialog on OK");
add(showMessageDialogOnOKCheckBox, "cell 0 7 3 1");
//======== filesScrollPane ========
{
//---- filesField ----
filesField.setRows(8);
filesScrollPane.setViewportView(filesField);
}
add(filesScrollPane, "cell 0 8 3 1,growx");
//---- ownerButtonGroup ----
ButtonGroup ownerButtonGroup = new ButtonGroup();
ownerButtonGroup.add(ownerFrameRadioButton);
ownerButtonGroup.add(ownerDialogRadioButton);
ownerButtonGroup.add(ownerNullRadioButton);
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JRadioButton ownerFrameRadioButton;
private JRadioButton ownerDialogRadioButton;
private JRadioButton ownerNullRadioButton;
private JTextField titleField;
private FlatTriStateCheckBox select_folderCheckBox;
private FlatTriStateCheckBox select_multipleCheckBox;
private FlatTriStateCheckBox do_overwrite_confirmationCheckBox;
private FlatTriStateCheckBox create_foldersCheckBox;
private FlatTriStateCheckBox show_hiddenCheckBox;
private FlatTriStateCheckBox local_onlyCheckBox;
private JTextField okButtonLabelField;
private JTextField currentNameField;
private JTextField currentFolderField;
private JComboBox<String> fileTypesField;
private JSlider fileTypeIndexSlider;
private JCheckBox showMessageDialogOnOKCheckBox;
private JTextArea filesField;
// JFormDesigner - End of variables declaration //GEN-END:variables
}

View File

@@ -0,0 +1,280 @@
JFDML JFormDesigner: "8.2.2.0.9999" Java: "21.0.1" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
root: new FormRoot {
auxiliary() {
"JavaCodeGenerator.defaultVariableLocal": true
}
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "ltr,insets dialog,hidemode 3"
"$columnConstraints": "[left][grow,fill][fill]"
"$rowConstraints": "[][][][][][][][][grow,fill]"
} ) {
name: "this"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "ownerLabel"
"text": "owner"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "ownerFrameRadioButton"
"text": "JFrame"
"$buttonGroup": new FormReference( "ownerButtonGroup" )
"selected": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "ownerDialogRadioButton"
"text": "JDialog"
"$buttonGroup": new FormReference( "ownerButtonGroup" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "ownerNullRadioButton"
"text": "null"
"$buttonGroup": new FormReference( "ownerButtonGroup" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "com.jformdesigner.designer.wrapper.HSpacer" ) {
name: "ownerSpacer"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "titleLabel"
"text": "title"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "titleField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 2,hidemode 3"
"$columnConstraints": "[left]"
"$rowConstraints": "[]0[]0[]0[]0[]0[]"
} ) {
name: "panel1"
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "select_folderCheckBox"
"text": "select_folder"
"allowIndeterminate": false
"state": enum com.formdev.flatlaf.extras.components.FlatTriStateCheckBox$State UNSELECTED
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "select_multipleCheckBox"
"text": "select_multiple"
"state": enum com.formdev.flatlaf.extras.components.FlatTriStateCheckBox$State UNSELECTED
"allowIndeterminate": false
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "do_overwrite_confirmationCheckBox"
"text": "do_overwrite_confirmation"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "create_foldersCheckBox"
"text": "create_folders"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "show_hiddenCheckBox"
"text": "show_hidden"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "local_onlyCheckBox"
"text": "local_only"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 1 1 6,aligny top,growy 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "okButtonLabelLabel"
"text": "okButtonLabel"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "okButtonLabelField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "currentNameLabel"
"text": "currentName"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "currentNameField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "currentFolderLabel"
"text": "currentFolder"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "currentFolderField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "fileTypesLabel"
"text": "fileTypes"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "fileTypesField"
"editable": true
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "Text Files,*.txt,null"
addElement( "Text Files,*.txt,null" )
addElement( "All Files,*,null" )
addElement( "Text Files,*.txt,null,PDF Files,*.pdf,null,All Files,*,null" )
addElement( "Text and PDF Files,*.txt,*.pdf,null" )
}
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "fileTypeIndexLabel"
"text": "fileTypeIndex"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6"
} )
add( new FormComponent( "javax.swing.JSlider" ) {
name: "fileTypeIndexSlider"
"maximum": 10
"majorTickSpacing": 1
"value": 0
"paintLabels": true
"snapToTicks": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 6"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "openButton"
"text": "Open..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "open", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 7 3 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "saveButton"
"text": "Save..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "save", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 7 3 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "openDirectButton"
"text": "Open (no-thread)..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "openDirect", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 7 3 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "saveDirectButton"
"text": "Save (no-thread)..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "saveDirect", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 7 3 1"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "showMessageDialogOnOKCheckBox"
"text": "show message dialog on OK"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 7 3 1"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "filesScrollPane"
add( new FormComponent( "javax.swing.JTextArea" ) {
name: "filesField"
"rows": 8
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 8 3 1,growx"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 690, 630 )
} )
add( new FormNonVisual( "javax.swing.ButtonGroup" ) {
name: "ownerButtonGroup"
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 640 )
} )
}
}

View File

@@ -0,0 +1,564 @@
/*
* Copyright 2024 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.testing;
import static com.formdev.flatlaf.ui.FlatNativeMacLibrary.*;
import java.awt.SecondaryLoop;
import java.awt.Toolkit;
import java.awt.Window;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicInteger;
import javax.swing.*;
import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.extras.components.*;
import com.formdev.flatlaf.extras.components.FlatTriStateCheckBox.State;
import com.formdev.flatlaf.testing.FlatSystemFileChooserTest.DummyModalDialog;
import com.formdev.flatlaf.ui.FlatNativeMacLibrary;
import com.formdev.flatlaf.util.SystemInfo;
import net.miginfocom.swing.*;
/**
* @author Karl Tauber
*/
public class FlatSystemFileChooserMacTest
extends FlatTestPanel
{
public static void main( String[] args ) {
// macOS (see https://www.formdev.com/flatlaf/macos/)
if( SystemInfo.isMacOS ) {
// enable screen menu bar
// (moves menu bar from JFrame window to top of screen)
System.setProperty( "apple.laf.useScreenMenuBar", "true" );
// appearance of window title bars
// possible values:
// - "system": use current macOS appearance (light or dark)
// - "NSAppearanceNameAqua": use light appearance
// - "NSAppearanceNameDarkAqua": use dark appearance
// (needs to be set on main thread; setting it on AWT thread does not work)
System.setProperty( "apple.awt.application.appearance", "system" );
}
SwingUtilities.invokeLater( () -> {
if( !FlatNativeMacLibrary.isLoaded() ) {
JOptionPane.showMessageDialog( null, "FlatLaf native library not loaded" );
return;
}
FlatTestFrame frame = FlatTestFrame.create( args, "FlatSystemFileChooserMacTest" );
FlatSystemFileChooserTest.addListeners( frame );
frame.showFrame( FlatSystemFileChooserMacTest::new );
frame.setJMenuBar( menuBar1 );
} );
}
FlatSystemFileChooserMacTest() {
initComponents();
fileTypesField.setSelectedItem( null );
}
private void open() {
openOrSave( true, false );
}
private void save() {
openOrSave( false, false );
}
private void openDirect() {
openOrSave( true, true );
}
private void saveDirect() {
openOrSave( false, true );
}
private void openOrSave( boolean open, boolean direct ) {
Window frame = SwingUtilities.windowForComponent( this );
if( ownerFrameRadioButton.isSelected() )
openOrSave( open, direct, frame );
else if( ownerDialogRadioButton.isSelected() )
new DummyModalDialog( frame, owner -> openOrSave( open, direct, owner ) ).setVisible( true );
else
openOrSave( open, direct, null );
}
private void openOrSave( boolean open, boolean direct, Window owner ) {
String title = n( titleField.getText() );
String prompt = n( promptField.getText() );
String message = n( messageField.getText() );
String filterFieldLabel = n( filterFieldLabelField.getText() );
String nameFieldLabel = n( nameFieldLabelField.getText() );
String nameFieldStringValue = n( nameFieldStringValueField.getText() );
String directoryURL = n( directoryURLField.getText() );
AtomicInteger optionsSet = new AtomicInteger();
AtomicInteger optionsClear = new AtomicInteger();
// NSOpenPanel
if( canChooseFilesCheckBox.isSelected() )
optionsSet.set( optionsSet.get() | FC_canChooseFiles );
if( canChooseDirectoriesCheckBox.isSelected() )
optionsSet.set( optionsSet.get() | FC_canChooseDirectories );
o( FC_resolvesAliases, resolvesAliasesCheckBox, optionsSet, optionsClear );
o( FC_allowsMultipleSelection, allowsMultipleSelectionCheckBox, optionsSet, optionsClear );
if( accessoryViewDisclosedCheckBox.isSelected() )
optionsSet.set( optionsSet.get() | FC_accessoryViewDisclosed );
// NSSavePanel
o( FC_showsTagField, showsTagFieldCheckBox, optionsSet, optionsClear );
o( FC_canCreateDirectories, canCreateDirectoriesCheckBox, optionsSet, optionsClear );
o( FC_canSelectHiddenExtension, canSelectHiddenExtensionCheckBox, optionsSet, optionsClear );
o( FC_showsHiddenFiles, showsHiddenFilesCheckBox, optionsSet, optionsClear );
o( FC_extensionHidden, extensionHiddenCheckBox, optionsSet, optionsClear );
o( FC_allowsOtherFileTypes, allowsOtherFileTypesCheckBox, optionsSet, optionsClear );
o( FC_treatsFilePackagesAsDirectories, treatsFilePackagesAsDirectoriesCheckBox, optionsSet, optionsClear );
// custom
if( showSingleFilterFieldCheckBox.isSelected() )
optionsSet.set( optionsSet.get() | FC_showSingleFilterField );
String fileTypesStr = n( (String) fileTypesField.getSelectedItem() );
String[] fileTypes = {};
if( fileTypesStr != null ) {
if( !fileTypesStr.endsWith( ",null" ) )
fileTypesStr += ",null";
fileTypes = fileTypesStr.trim().split( "[,]+" );
for( int i = 0; i < fileTypes.length; i++ ) {
if( "null".equals( fileTypes[i] ) )
fileTypes[i] = null;
}
}
int fileTypeIndex = fileTypeIndexSlider.getValue();
FlatNativeMacLibrary.FileChooserCallback callback = (files, hwndFileDialog) -> {
System.out.println( " -- callback " + hwndFileDialog + " " + Arrays.toString( files ) );
if( showMessageDialogOnOKCheckBox.isSelected() ) {
int result = FlatNativeMacLibrary.showMessageDialog( hwndFileDialog,
JOptionPane.INFORMATION_MESSAGE,
"primary text", "secondary text", 0, "Yes", "No" );
System.out.println( " result " + result );
if( result != 0 )
return false;
}
return true;
};
int dark = FlatLaf.isLafDark() ? 1 : 0;
if( direct ) {
String[] files = FlatNativeMacLibrary.showFileChooser( owner, dark, open,
title, prompt, message, filterFieldLabel,
nameFieldLabel, nameFieldStringValue, directoryURL,
optionsSet.get(), optionsClear.get(), callback, fileTypeIndex, fileTypes );
filesField.setText( (files != null) ? Arrays.toString( files ).replace( ',', '\n' ) : "null" );
} else {
SecondaryLoop secondaryLoop = Toolkit.getDefaultToolkit().getSystemEventQueue().createSecondaryLoop();
String[] fileTypes2 = fileTypes;
new Thread( () -> {
String[] files = FlatNativeMacLibrary.showFileChooser( owner, dark, open,
title, prompt, message, filterFieldLabel,
nameFieldLabel, nameFieldStringValue, directoryURL,
optionsSet.get(), optionsClear.get(), callback, fileTypeIndex, fileTypes2 );
System.out.println( " secondaryLoop.exit() returned " + secondaryLoop.exit() );
SwingUtilities.invokeLater( () -> {
filesField.setText( (files != null) ? Arrays.toString( files ).replace( ',', '\n' ) : "null" );
} );
} ).start();
System.out.println( "---- enter secondary loop ----" );
System.out.println( "---- secondary loop exited (secondaryLoop.enter() returned " + secondaryLoop.enter() + ") ----" );
}
}
private static String n( String s ) {
return s != null && !s.isEmpty() ? s : null;
}
private static void o( int option, FlatTriStateCheckBox checkBox, AtomicInteger optionsSet, AtomicInteger optionsClear ) {
if( checkBox.getState() == State.SELECTED )
optionsSet.set( optionsSet.get() | option );
else if( checkBox.getState() == State.UNSELECTED )
optionsClear.set( optionsClear.get() | option );
}
private void menuItemAction() {
System.out.println( "menu item action" );
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JLabel ownerLabel = new JLabel();
ownerFrameRadioButton = new JRadioButton();
ownerDialogRadioButton = new JRadioButton();
ownerNullRadioButton = new JRadioButton();
JPanel ownerSpacer = new JPanel(null);
JLabel titleLabel = new JLabel();
titleField = new JTextField();
JPanel panel1 = new JPanel();
JLabel options1Label = new JLabel();
canChooseFilesCheckBox = new JCheckBox();
canChooseDirectoriesCheckBox = new JCheckBox();
resolvesAliasesCheckBox = new FlatTriStateCheckBox();
allowsMultipleSelectionCheckBox = new FlatTriStateCheckBox();
accessoryViewDisclosedCheckBox = new JCheckBox();
JLabel options2Label = new JLabel();
showsTagFieldCheckBox = new FlatTriStateCheckBox();
canCreateDirectoriesCheckBox = new FlatTriStateCheckBox();
canSelectHiddenExtensionCheckBox = new FlatTriStateCheckBox();
showsHiddenFilesCheckBox = new FlatTriStateCheckBox();
extensionHiddenCheckBox = new FlatTriStateCheckBox();
allowsOtherFileTypesCheckBox = new FlatTriStateCheckBox();
treatsFilePackagesAsDirectoriesCheckBox = new FlatTriStateCheckBox();
JLabel options3Label = new JLabel();
showSingleFilterFieldCheckBox = new JCheckBox();
JLabel promptLabel = new JLabel();
promptField = new JTextField();
JLabel messageLabel = new JLabel();
messageField = new JTextField();
JLabel filterFieldLabelLabel = new JLabel();
filterFieldLabelField = new JTextField();
JLabel nameFieldLabelLabel = new JLabel();
nameFieldLabelField = new JTextField();
JLabel nameFieldStringValueLabel = new JLabel();
nameFieldStringValueField = new JTextField();
JLabel directoryURLLabel = new JLabel();
directoryURLField = new JTextField();
JLabel fileTypesLabel = new JLabel();
fileTypesField = new JComboBox<>();
JLabel fileTypeIndexLabel = new JLabel();
fileTypeIndexSlider = new JSlider();
JButton openButton = new JButton();
JButton saveButton = new JButton();
JButton openDirectButton = new JButton();
JButton saveDirectButton = new JButton();
showMessageDialogOnOKCheckBox = new JCheckBox();
JScrollPane filesScrollPane = new JScrollPane();
filesField = new JTextArea();
menuBar1 = new JMenuBar();
JMenu menu1 = new JMenu();
JMenuItem menuItem1 = new JMenuItem();
JMenuItem menuItem2 = new JMenuItem();
JMenu menu2 = new JMenu();
JMenuItem menuItem3 = new JMenuItem();
JMenuItem menuItem4 = new JMenuItem();
//======== this ========
setLayout(new MigLayout(
"ltr,insets dialog,hidemode 3",
// columns
"[left]" +
"[grow,fill]" +
"[fill]",
// rows
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[grow,fill]"));
//---- ownerLabel ----
ownerLabel.setText("owner");
add(ownerLabel, "cell 0 0");
//---- ownerFrameRadioButton ----
ownerFrameRadioButton.setText("JFrame");
ownerFrameRadioButton.setSelected(true);
add(ownerFrameRadioButton, "cell 1 0");
//---- ownerDialogRadioButton ----
ownerDialogRadioButton.setText("JDialog");
add(ownerDialogRadioButton, "cell 1 0");
//---- ownerNullRadioButton ----
ownerNullRadioButton.setText("null");
add(ownerNullRadioButton, "cell 1 0");
add(ownerSpacer, "cell 1 0,growx");
//---- titleLabel ----
titleLabel.setText("title");
add(titleLabel, "cell 0 1");
add(titleField, "cell 1 1");
//======== panel1 ========
{
panel1.setLayout(new MigLayout(
"insets 2,hidemode 3",
// columns
"[left]",
// rows
"[]" +
"[]0" +
"[]0" +
"[]0" +
"[]0" +
"[]para" +
"[]" +
"[]0" +
"[]0" +
"[]0" +
"[]0" +
"[]0" +
"[]0" +
"[]para" +
"[]" +
"[]"));
//---- options1Label ----
options1Label.setText("NSOpenPanel options:");
panel1.add(options1Label, "cell 0 0");
//---- canChooseFilesCheckBox ----
canChooseFilesCheckBox.setText("canChooseFiles");
canChooseFilesCheckBox.setSelected(true);
panel1.add(canChooseFilesCheckBox, "cell 0 1");
//---- canChooseDirectoriesCheckBox ----
canChooseDirectoriesCheckBox.setText("canChooseDirectories");
panel1.add(canChooseDirectoriesCheckBox, "cell 0 2");
//---- resolvesAliasesCheckBox ----
resolvesAliasesCheckBox.setText("resolvesAliases");
resolvesAliasesCheckBox.setState(FlatTriStateCheckBox.State.SELECTED);
panel1.add(resolvesAliasesCheckBox, "cell 0 3");
//---- allowsMultipleSelectionCheckBox ----
allowsMultipleSelectionCheckBox.setText("allowsMultipleSelection");
panel1.add(allowsMultipleSelectionCheckBox, "cell 0 4");
//---- accessoryViewDisclosedCheckBox ----
accessoryViewDisclosedCheckBox.setText("accessoryViewDisclosed");
panel1.add(accessoryViewDisclosedCheckBox, "cell 0 5");
//---- options2Label ----
options2Label.setText("NSOpenPanel and NSSavePanel options:");
panel1.add(options2Label, "cell 0 6");
//---- showsTagFieldCheckBox ----
showsTagFieldCheckBox.setText("showsTagField");
panel1.add(showsTagFieldCheckBox, "cell 0 7");
//---- canCreateDirectoriesCheckBox ----
canCreateDirectoriesCheckBox.setText("canCreateDirectories");
panel1.add(canCreateDirectoriesCheckBox, "cell 0 8");
//---- canSelectHiddenExtensionCheckBox ----
canSelectHiddenExtensionCheckBox.setText("canSelectHiddenExtension");
panel1.add(canSelectHiddenExtensionCheckBox, "cell 0 9");
//---- showsHiddenFilesCheckBox ----
showsHiddenFilesCheckBox.setText("showsHiddenFiles");
panel1.add(showsHiddenFilesCheckBox, "cell 0 10");
//---- extensionHiddenCheckBox ----
extensionHiddenCheckBox.setText("extensionHidden");
panel1.add(extensionHiddenCheckBox, "cell 0 11");
//---- allowsOtherFileTypesCheckBox ----
allowsOtherFileTypesCheckBox.setText("allowsOtherFileTypes");
panel1.add(allowsOtherFileTypesCheckBox, "cell 0 12");
//---- treatsFilePackagesAsDirectoriesCheckBox ----
treatsFilePackagesAsDirectoriesCheckBox.setText("treatsFilePackagesAsDirectories");
panel1.add(treatsFilePackagesAsDirectoriesCheckBox, "cell 0 13");
//---- options3Label ----
options3Label.setText("Custom options:");
panel1.add(options3Label, "cell 0 14");
//---- showSingleFilterFieldCheckBox ----
showSingleFilterFieldCheckBox.setText("showSingleFilterField");
panel1.add(showSingleFilterFieldCheckBox, "cell 0 15");
}
add(panel1, "cell 2 1 1 10,aligny top,growy 0");
//---- promptLabel ----
promptLabel.setText("prompt");
add(promptLabel, "cell 0 2");
add(promptField, "cell 1 2");
//---- messageLabel ----
messageLabel.setText("message");
add(messageLabel, "cell 0 3");
add(messageField, "cell 1 3");
//---- filterFieldLabelLabel ----
filterFieldLabelLabel.setText("filterFieldLabel");
add(filterFieldLabelLabel, "cell 0 4");
add(filterFieldLabelField, "cell 1 4");
//---- nameFieldLabelLabel ----
nameFieldLabelLabel.setText("nameFieldLabel");
add(nameFieldLabelLabel, "cell 0 5");
add(nameFieldLabelField, "cell 1 5");
//---- nameFieldStringValueLabel ----
nameFieldStringValueLabel.setText("nameFieldStringValue");
add(nameFieldStringValueLabel, "cell 0 6");
add(nameFieldStringValueField, "cell 1 6");
//---- directoryURLLabel ----
directoryURLLabel.setText("directoryURL");
add(directoryURLLabel, "cell 0 7");
add(directoryURLField, "cell 1 7");
//---- fileTypesLabel ----
fileTypesLabel.setText("fileTypes");
add(fileTypesLabel, "cell 0 8");
//---- fileTypesField ----
fileTypesField.setEditable(true);
fileTypesField.setModel(new DefaultComboBoxModel<>(new String[] {
"Text Files,txt,null",
"All Files,*,null",
"Text Files,txt,null,PDF Files,pdf,null,All Files,*,null",
"Text and PDF Files,txt,pdf,null",
"Compressed,zip,gz,null,Disk Images,dmg,null"
}));
add(fileTypesField, "cell 1 8");
//---- fileTypeIndexLabel ----
fileTypeIndexLabel.setText("fileTypeIndex");
add(fileTypeIndexLabel, "cell 0 9");
//---- fileTypeIndexSlider ----
fileTypeIndexSlider.setMaximum(10);
fileTypeIndexSlider.setMajorTickSpacing(1);
fileTypeIndexSlider.setValue(0);
fileTypeIndexSlider.setPaintLabels(true);
fileTypeIndexSlider.setSnapToTicks(true);
add(fileTypeIndexSlider, "cell 1 9");
//---- openButton ----
openButton.setText("Open...");
openButton.addActionListener(e -> open());
add(openButton, "cell 0 11 3 1");
//---- saveButton ----
saveButton.setText("Save...");
saveButton.addActionListener(e -> save());
add(saveButton, "cell 0 11 3 1");
//---- openDirectButton ----
openDirectButton.setText("Open (no-thread)...");
openDirectButton.addActionListener(e -> openDirect());
add(openDirectButton, "cell 0 11 3 1");
//---- saveDirectButton ----
saveDirectButton.setText("Save (no-thread)...");
saveDirectButton.addActionListener(e -> saveDirect());
add(saveDirectButton, "cell 0 11 3 1");
//---- showMessageDialogOnOKCheckBox ----
showMessageDialogOnOKCheckBox.setText("show message dialog on OK");
add(showMessageDialogOnOKCheckBox, "cell 0 11 3 1");
//======== filesScrollPane ========
{
//---- filesField ----
filesField.setRows(8);
filesScrollPane.setViewportView(filesField);
}
add(filesScrollPane, "cell 0 12 3 1,growx");
//======== menuBar1 ========
{
//======== menu1 ========
{
menu1.setText("text");
//---- menuItem1 ----
menuItem1.setText("text");
menuItem1.addActionListener(e -> menuItemAction());
menu1.add(menuItem1);
//---- menuItem2 ----
menuItem2.setText("text");
menuItem2.addActionListener(e -> menuItemAction());
menu1.add(menuItem2);
}
menuBar1.add(menu1);
//======== menu2 ========
{
menu2.setText("text");
//---- menuItem3 ----
menuItem3.setText("text");
menuItem3.addActionListener(e -> menuItemAction());
menu2.add(menuItem3);
//---- menuItem4 ----
menuItem4.setText("text");
menuItem4.addActionListener(e -> menuItemAction());
menu2.add(menuItem4);
}
menuBar1.add(menu2);
}
//---- ownerButtonGroup ----
ButtonGroup ownerButtonGroup = new ButtonGroup();
ownerButtonGroup.add(ownerFrameRadioButton);
ownerButtonGroup.add(ownerDialogRadioButton);
ownerButtonGroup.add(ownerNullRadioButton);
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JRadioButton ownerFrameRadioButton;
private JRadioButton ownerDialogRadioButton;
private JRadioButton ownerNullRadioButton;
private JTextField titleField;
private JCheckBox canChooseFilesCheckBox;
private JCheckBox canChooseDirectoriesCheckBox;
private FlatTriStateCheckBox resolvesAliasesCheckBox;
private FlatTriStateCheckBox allowsMultipleSelectionCheckBox;
private JCheckBox accessoryViewDisclosedCheckBox;
private FlatTriStateCheckBox showsTagFieldCheckBox;
private FlatTriStateCheckBox canCreateDirectoriesCheckBox;
private FlatTriStateCheckBox canSelectHiddenExtensionCheckBox;
private FlatTriStateCheckBox showsHiddenFilesCheckBox;
private FlatTriStateCheckBox extensionHiddenCheckBox;
private FlatTriStateCheckBox allowsOtherFileTypesCheckBox;
private FlatTriStateCheckBox treatsFilePackagesAsDirectoriesCheckBox;
private JCheckBox showSingleFilterFieldCheckBox;
private JTextField promptField;
private JTextField messageField;
private JTextField filterFieldLabelField;
private JTextField nameFieldLabelField;
private JTextField nameFieldStringValueField;
private JTextField directoryURLField;
private JComboBox<String> fileTypesField;
private JSlider fileTypeIndexSlider;
private JCheckBox showMessageDialogOnOKCheckBox;
private JTextArea filesField;
private static JMenuBar menuBar1;
// JFormDesigner - End of variables declaration //GEN-END:variables
}

View File

@@ -0,0 +1,440 @@
JFDML JFormDesigner: "8.2.2.0.9999" Java: "21.0.1" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
root: new FormRoot {
auxiliary() {
"JavaCodeGenerator.defaultVariableLocal": true
}
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "ltr,insets dialog,hidemode 3"
"$columnConstraints": "[left][grow,fill][fill]"
"$rowConstraints": "[][][][][][][][][][][][][grow,fill]"
} ) {
name: "this"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "ownerLabel"
"text": "owner"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "ownerFrameRadioButton"
"text": "JFrame"
"$buttonGroup": new FormReference( "ownerButtonGroup" )
"selected": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "ownerDialogRadioButton"
"text": "JDialog"
"$buttonGroup": new FormReference( "ownerButtonGroup" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "ownerNullRadioButton"
"text": "null"
"$buttonGroup": new FormReference( "ownerButtonGroup" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "com.jformdesigner.designer.wrapper.HSpacer" ) {
name: "ownerSpacer"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "titleLabel"
"text": "title"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "titleField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 2,hidemode 3"
"$columnConstraints": "[left]"
"$rowConstraints": "[][]0[]0[]0[]0[]para[][]0[]0[]0[]0[]0[]0[]para[][]"
} ) {
name: "panel1"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "options1Label"
"text": "NSOpenPanel options:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "canChooseFilesCheckBox"
"text": "canChooseFiles"
"selected": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "canChooseDirectoriesCheckBox"
"text": "canChooseDirectories"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "resolvesAliasesCheckBox"
"text": "resolvesAliases"
"state": enum com.formdev.flatlaf.extras.components.FlatTriStateCheckBox$State SELECTED
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "allowsMultipleSelectionCheckBox"
"text": "allowsMultipleSelection"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "accessoryViewDisclosedCheckBox"
"text": "accessoryViewDisclosed"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "options2Label"
"text": "NSOpenPanel and NSSavePanel options:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "showsTagFieldCheckBox"
"text": "showsTagField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 7"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "canCreateDirectoriesCheckBox"
"text": "canCreateDirectories"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 8"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "canSelectHiddenExtensionCheckBox"
"text": "canSelectHiddenExtension"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 9"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "showsHiddenFilesCheckBox"
"text": "showsHiddenFiles"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 10"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "extensionHiddenCheckBox"
"text": "extensionHidden"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 11"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "allowsOtherFileTypesCheckBox"
"text": "allowsOtherFileTypes"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 12"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "treatsFilePackagesAsDirectoriesCheckBox"
"text": "treatsFilePackagesAsDirectories"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 13"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "options3Label"
"text": "Custom options:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 14"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "showSingleFilterFieldCheckBox"
"text": "showSingleFilterField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 15"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 1 1 10,aligny top,growy 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "promptLabel"
"text": "prompt"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "promptField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "messageLabel"
"text": "message"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "messageField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "filterFieldLabelLabel"
"text": "filterFieldLabel"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "filterFieldLabelField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "nameFieldLabelLabel"
"text": "nameFieldLabel"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "nameFieldLabelField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "nameFieldStringValueLabel"
"text": "nameFieldStringValue"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "nameFieldStringValueField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 6"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "directoryURLLabel"
"text": "directoryURL"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 7"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "directoryURLField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 7"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "fileTypesLabel"
"text": "fileTypes"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 8"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "fileTypesField"
"editable": true
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "Text Files,txt,null"
addElement( "Text Files,txt,null" )
addElement( "All Files,*,null" )
addElement( "Text Files,txt,null,PDF Files,pdf,null,All Files,*,null" )
addElement( "Text and PDF Files,txt,pdf,null" )
addElement( "Compressed,zip,gz,null,Disk Images,dmg,null" )
}
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 8"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "fileTypeIndexLabel"
"text": "fileTypeIndex"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 9"
} )
add( new FormComponent( "javax.swing.JSlider" ) {
name: "fileTypeIndexSlider"
"maximum": 10
"majorTickSpacing": 1
"value": 0
"paintLabels": true
"snapToTicks": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 9"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "openButton"
"text": "Open..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "open", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 11 3 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "saveButton"
"text": "Save..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "save", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 11 3 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "openDirectButton"
"text": "Open (no-thread)..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "openDirect", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 11 3 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "saveDirectButton"
"text": "Save (no-thread)..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "saveDirect", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 11 3 1"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "showMessageDialogOnOKCheckBox"
"text": "show message dialog on OK"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 11 3 1"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "filesScrollPane"
add( new FormComponent( "javax.swing.JTextArea" ) {
name: "filesField"
"rows": 8
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 12 3 1,growx"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 750, 565 )
} )
add( new FormNonVisual( "javax.swing.ButtonGroup" ) {
name: "ownerButtonGroup"
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 575 )
} )
add( new FormContainer( "javax.swing.JMenuBar", new FormLayoutManager( class javax.swing.JMenuBar ) ) {
name: "menuBar1"
auxiliary() {
"JavaCodeGenerator.variableModifiers": 10
"JavaCodeGenerator.variableLocal": false
}
add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) {
name: "menu1"
"text": "text"
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem1"
"text": "text"
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemAction", false ) )
} )
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem2"
"text": "text"
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemAction", false ) )
} )
} )
add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) {
name: "menu2"
"text": "text"
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem3"
"text": "text"
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemAction", false ) )
} )
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem4"
"text": "text"
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemAction", false ) )
} )
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 630 )
"size": new java.awt.Dimension( 76, 24 )
} )
}
}

View File

@@ -0,0 +1,521 @@
JFDML JFormDesigner: "8.3" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
root: new FormRoot {
auxiliary() {
"JavaCodeGenerator.defaultVariableLocal": true
}
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "ltr,insets dialog,hidemode 3"
"$columnConstraints": "[left][grow,fill][fill]"
"$rowConstraints": "[][][][][][][][][][grow,fill]"
} ) {
name: "this"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "ownerLabel"
"text": "owner"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "ownerFrameRadioButton"
"text": "JFrame"
"selected": true
"$buttonGroup": new FormReference( "ownerButtonGroup" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "ownerDialogRadioButton"
"text": "JDialog"
"$buttonGroup": new FormReference( "ownerButtonGroup" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "ownerNullRadioButton"
"text": "null"
"$buttonGroup": new FormReference( "ownerButtonGroup" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "com.jformdesigner.designer.wrapper.HSpacer" ) {
name: "ownerSpacer"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "dialogTitleLabel"
"text": "dialogTitle"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "dialogTitleField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 2,hidemode 3"
"$columnConstraints": "[left]"
"$rowConstraints": "[]0[]0[][]para[][]"
} ) {
name: "panel1"
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "directorySelectionCheckBox"
"text": "directorySelection"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "multiSelectionEnabledCheckBox"
"text": "multiSelectionEnabled"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "useFileHidingCheckBox"
"text": "useFileHiding"
"selected": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "useSystemFileChooserCheckBox"
"text": "use SystemFileChooser"
"selected": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "persistStateCheckBox"
"text": "persist state"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "persistStateChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "stateStoreIDLabel"
"text": "ID:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "stateStoreIDField"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "abc"
addElement( "abc" )
addElement( "def" )
}
"editable": true
"selectedIndex": -1
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5,growx"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 1 1 7,aligny top,growy 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "approveButtonTextLabel"
"text": "approveButtonText"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "approveButtonTextField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "approveButtonMnemonicLabel"
"text": "approveButtonMnemonic"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "approveButtonMnemonicField"
"columns": 3
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "currentDirCheckBox"
"text": "current directory"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "currentDirChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "currentDirField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3,growx"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "currentDirChooseButton"
"text": "..."
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "chooseCurrentDir", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "selectedFileCheckBox"
"text": "selected file"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "selectedFileChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "selectedFileField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4,growx"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "selectedFileChooseButton"
"text": "..."
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "chooseSelectedFile", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "selectedFilesCheckBox"
"text": "selected files"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "selectedFilesChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "selectedFilesField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5,growx"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "selectedFilesChooseButton"
"text": "..."
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "chooseSelectedFiles", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "fileTypesLabel"
"text": "fileTypes"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "fileTypesField"
"editable": true
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "Text Files,txt"
addElement( "Text Files,txt" )
addElement( "All Files,*" )
addElement( "Text Files,txt,PDF Files,pdf,All Files,*" )
addElement( "Text and PDF Files,txt;pdf" )
}
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 6"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "fileTypeIndexLabel"
"text": "fileTypeIndex"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 7"
} )
add( new FormComponent( "javax.swing.JSlider" ) {
name: "fileTypeIndexSlider"
"maximum": 10
"majorTickSpacing": 1
"value": 0
"paintLabels": true
"snapToTicks": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 7,growx"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "useAcceptAllFileFilterCheckBox"
"text": "useAcceptAllFileFilter"
"selected": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 7"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "openButton"
"text": "Open..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "open", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 8 3 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "saveButton"
"text": "Save..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "save", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 8 3 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "swingOpenButton"
"text": "Swing Open..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "swingOpen", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 8 3 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "swingSaveButton"
"text": "Swing Save..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "swingSave", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 8 3 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "awtOpenButton"
"text": "AWT Open..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "awtOpen", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 8 3 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "awtSaveButton"
"text": "AWT Save..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "awtSave", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 8 3 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "javafxOpenButton"
"text": "JavaFX Open..."
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "javafxOpen", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 8 3 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "javafxSaveButton"
"text": "JavaFX Save..."
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "javafxSave", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 8 3 1"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "outputScrollPane"
add( new FormComponent( "javax.swing.JTextArea" ) {
name: "outputField"
"rows": 20
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 9 3 1,growx"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 825, 465 )
} )
add( new FormContainer( "javax.swing.JMenuBar", new FormLayoutManager( class javax.swing.JMenuBar ) ) {
name: "menuBar1"
auxiliary() {
"JavaCodeGenerator.variableModifiers": 10
"JavaCodeGenerator.variableLocal": false
}
add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) {
name: "menu1"
"text": "text"
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem1"
"text": "text"
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemAction", false ) )
} )
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem2"
"text": "text"
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemAction", false ) )
} )
} )
add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) {
name: "menu2"
"text": "text"
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem3"
"text": "text"
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemAction", false ) )
} )
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem4"
"text": "text"
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemAction", false ) )
} )
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 10, 570 )
} )
add( new FormWindow( "javax.swing.JDialog", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "hidemode 3"
"$columnConstraints": "[fill][fill]"
"$rowConstraints": "[]0[]0[]0[][]para[][198]"
} ) {
name: "dialog1"
"title": "Dummy Modal Dialog"
"modalityType": enum java.awt.Dialog$ModalityType APPLICATION_MODAL
"defaultCloseOperation": 2
auxiliary() {
"JavaCodeGenerator.className": "DummyModalDialog"
}
addEvent( new FormEvent( "java.awt.event.WindowListener", "windowOpened", "windowOpened", false ) )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label1"
"text": "Modality type:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "applicationRadioButton"
"text": "Application"
"selected": true
"$buttonGroup": new FormReference( "modalityTypeButtonGroup" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "modalityTypeChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "documentRadioButton"
"text": "Document"
"$buttonGroup": new FormReference( "modalityTypeButtonGroup" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "modalityTypeChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "toolkitRadioButton"
"text": "Toolkit"
"$buttonGroup": new FormReference( "modalityTypeButtonGroup" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "modalityTypeChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "modelessRadioButton"
"text": "modeless"
"$buttonGroup": new FormReference( "modalityTypeButtonGroup" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "modalityTypeChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "showModalDialogButton"
"text": "Show Modal Dialog..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showModalDialog", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4 2 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "showFileDialogButton"
"text": "Show File Dialog..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showFileDialog", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5 2 1"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 20, 635 )
"size": new java.awt.Dimension( 290, 465 )
} )
add( new FormNonVisual( "javax.swing.ButtonGroup" ) {
name: "ownerButtonGroup"
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 475 )
} )
add( new FormNonVisual( "javax.swing.ButtonGroup" ) {
name: "modalityTypeButtonGroup"
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 115, 575 )
} )
}
}

View File

@@ -0,0 +1,622 @@
/*
* Copyright 2024 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.testing;
import static com.formdev.flatlaf.ui.FlatNativeWindowsLibrary.*;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.SecondaryLoop;
import java.awt.Toolkit;
import java.awt.Window;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.prefs.Preferences;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import com.formdev.flatlaf.demo.DemoPrefs;
import com.formdev.flatlaf.extras.components.*;
import com.formdev.flatlaf.extras.components.FlatTriStateCheckBox.State;
import com.formdev.flatlaf.testing.FlatSystemFileChooserTest.DummyModalDialog;
import com.formdev.flatlaf.ui.FlatNativeWindowsLibrary;
import net.miginfocom.swing.*;
/**
* @author Karl Tauber
*/
public class FlatSystemFileChooserWindowsTest
extends FlatTestPanel
{
public static void main( String[] args ) {
SwingUtilities.invokeLater( () -> {
if( !FlatNativeWindowsLibrary.isLoaded() ) {
JOptionPane.showMessageDialog( null, "FlatLaf native library not loaded" );
return;
}
FlatTestFrame frame = FlatTestFrame.create( args, "FlatSystemFileChooserWindowsTest" );
FlatSystemFileChooserTest.addListeners( frame );
frame.showFrame( FlatSystemFileChooserWindowsTest::new );
} );
}
FlatSystemFileChooserWindowsTest() {
initComponents();
fileTypesField.setSelectedItem( null );
Preferences state = DemoPrefs.getState();
messageField.setText( state.get( "systemfilechooser.windows.message", "some message" ) );
buttonsField.setText( state.get( "systemfilechooser.windows.buttons", "OK" ) );
}
private void open() {
openOrSave( true, false );
}
private void save() {
openOrSave( false, false );
}
private void openDirect() {
openOrSave( true, true );
}
private void saveDirect() {
openOrSave( false, true );
}
private void openOrSave( boolean open, boolean direct ) {
Window frame = SwingUtilities.windowForComponent( this );
if( ownerFrameRadioButton.isSelected() )
openOrSave( open, direct, frame );
else if( ownerDialogRadioButton.isSelected() )
new DummyModalDialog( frame, owner -> openOrSave( open, direct, owner ) ).setVisible( true );
else
openOrSave( open, direct, null );
}
private void openOrSave( boolean open, boolean direct, Window owner ) {
String title = n( titleField.getText() );
String okButtonLabel = n( okButtonLabelField.getText() );
String fileNameLabel = n( fileNameLabelField.getText() );
String fileName = n( fileNameField.getText() );
String folder = n( folderField.getText() );
String saveAsItem = n( saveAsItemField.getText() );
String defaultFolder = n( defaultFolderField.getText() );
String defaultExtension = n( defaultExtensionField.getText() );
AtomicInteger optionsSet = new AtomicInteger();
AtomicInteger optionsClear = new AtomicInteger();
o( FOS_OVERWRITEPROMPT, overwritePromptCheckBox, optionsSet, optionsClear );
o( FOS_STRICTFILETYPES, strictFileTypesCheckBox, optionsSet, optionsClear );
o( FOS_NOCHANGEDIR, noChangeDirCheckBox, optionsSet, optionsClear );
o( FOS_PICKFOLDERS, pickFoldersCheckBox, optionsSet, optionsClear );
o( FOS_FORCEFILESYSTEM, forceFileSystemCheckBox, optionsSet, optionsClear );
o( FOS_ALLNONSTORAGEITEMS, allNonStorageItemsCheckBox, optionsSet, optionsClear );
o( FOS_NOVALIDATE, noValidateCheckBox, optionsSet, optionsClear );
o( FOS_ALLOWMULTISELECT, allowMultiSelectCheckBox, optionsSet, optionsClear );
o( FOS_PATHMUSTEXIST, pathMustExistCheckBox, optionsSet, optionsClear );
o( FOS_FILEMUSTEXIST, fileMustExistCheckBox, optionsSet, optionsClear );
o( FOS_CREATEPROMPT, createPromptCheckBox, optionsSet, optionsClear );
o( FOS_SHAREAWARE, shareAwareCheckBox, optionsSet, optionsClear );
o( FOS_NOREADONLYRETURN, noReadOnlyReturnCheckBox, optionsSet, optionsClear );
o( FOS_NOTESTFILECREATE, noTestFileCreateCheckBox, optionsSet, optionsClear );
o( FOS_HIDEMRUPLACES, hideMruPlacesCheckBox, optionsSet, optionsClear );
o( FOS_HIDEPINNEDPLACES, hidePinnedPlacesCheckBox, optionsSet, optionsClear );
o( FOS_NODEREFERENCELINKS, noDereferenceLinksCheckBox, optionsSet, optionsClear );
o( FOS_OKBUTTONNEEDSINTERACTION, okButtonNeedsInteractionCheckBox, optionsSet, optionsClear );
o( FOS_DONTADDTORECENT, dontAddToRecentCheckBox, optionsSet, optionsClear );
o( FOS_FORCESHOWHIDDEN, forceShowHiddenCheckBox, optionsSet, optionsClear );
o( FOS_DEFAULTNOMINIMODE, defaultNoMiniModeCheckBox, optionsSet, optionsClear );
o( FOS_FORCEPREVIEWPANEON, forcePreviewPaneonCheckBox, optionsSet, optionsClear );
o( FOS_SUPPORTSTREAMABLEITEMS, supportStreamableItemsCheckBox, optionsSet, optionsClear );
String fileTypesStr = n( (String) fileTypesField.getSelectedItem() );
String[] fileTypes = {};
if( fileTypesStr != null )
fileTypes = fileTypesStr.trim().split( "[,]+" );
int fileTypeIndex = fileTypeIndexSlider.getValue();
FlatNativeWindowsLibrary.FileChooserCallback callback = (files, hwndFileDialog) -> {
System.out.println( " -- callback " + hwndFileDialog + " " + Arrays.toString( files ) );
if( showMessageDialogOnOKCheckBox.isSelected() ) {
System.out.println( FlatNativeWindowsLibrary.showMessageDialog( hwndFileDialog,
JOptionPane.INFORMATION_MESSAGE,
null, "some text", 1, "Yes", "No" ) );
}
return true;
};
if( direct ) {
String[] files = FlatNativeWindowsLibrary.showFileChooser( owner, open,
title, okButtonLabel, fileNameLabel, fileName,
folder, saveAsItem, defaultFolder, defaultExtension,
optionsSet.get(), optionsClear.get(), callback, fileTypeIndex, fileTypes );
filesField.setText( (files != null) ? Arrays.toString( files ).replace( ',', '\n' ) : "null" );
} else {
SecondaryLoop secondaryLoop = Toolkit.getDefaultToolkit().getSystemEventQueue().createSecondaryLoop();
String[] fileTypes2 = fileTypes;
new Thread( () -> {
String[] files = FlatNativeWindowsLibrary.showFileChooser( owner, open,
title, okButtonLabel, fileNameLabel, fileName,
folder, saveAsItem, defaultFolder, defaultExtension,
optionsSet.get(), optionsClear.get(), callback, fileTypeIndex, fileTypes2 );
System.out.println( " secondaryLoop.exit() returned " + secondaryLoop.exit() );
EventQueue.invokeLater( () -> {
filesField.setText( (files != null) ? Arrays.toString( files ).replace( ',', '\n' ) : "null" );
} );
} ).start();
System.out.println( "---- enter secondary loop ----" );
System.out.println( "---- secondary loop exited (secondaryLoop.enter() returned " + secondaryLoop.enter() + ") ----" );
}
}
private static String n( String s ) {
return s != null && !s.isEmpty() ? s : null;
}
private static void o( int option, FlatTriStateCheckBox checkBox, AtomicInteger optionsSet, AtomicInteger optionsClear ) {
if( checkBox.getState() == State.SELECTED )
optionsSet.set( optionsSet.get() | option );
else if( checkBox.getState() == State.UNSELECTED )
optionsClear.set( optionsClear.get() | option );
}
private void messageDialog() {
long hwnd = getHWND( SwingUtilities.windowForComponent( this ) );
String message = messageField.getText();
String[] buttons = buttonsField.getText().trim().split( "[,]+" );
Preferences state = DemoPrefs.getState();
state.put( "systemfilechooser.windows.message", message );
state.put( "systemfilechooser.windows.buttons", buttonsField.getText() );
System.out.println( FlatNativeWindowsLibrary.showMessageDialog( hwnd,
JOptionPane.WARNING_MESSAGE, null, message, 1, buttons ) );
}
private void messageBox() {
long hwnd = getHWND( SwingUtilities.windowForComponent( this ) );
String message = messageField.getText();
System.out.println( FlatNativeWindowsLibrary.showMessageBox( hwnd, message, null,
/* MB_ICONINFORMATION */ 0x00000040 | /* MB_YESNO */ 0x00000004 ) );
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JLabel ownerLabel = new JLabel();
ownerFrameRadioButton = new JRadioButton();
ownerDialogRadioButton = new JRadioButton();
ownerNullRadioButton = new JRadioButton();
JPanel ownerSpacer = new JPanel(null);
JLabel titleLabel = new JLabel();
titleField = new JTextField();
JPanel panel1 = new JPanel();
overwritePromptCheckBox = new FlatTriStateCheckBox();
pathMustExistCheckBox = new FlatTriStateCheckBox();
noDereferenceLinksCheckBox = new FlatTriStateCheckBox();
strictFileTypesCheckBox = new FlatTriStateCheckBox();
fileMustExistCheckBox = new FlatTriStateCheckBox();
okButtonNeedsInteractionCheckBox = new FlatTriStateCheckBox();
noChangeDirCheckBox = new FlatTriStateCheckBox();
createPromptCheckBox = new FlatTriStateCheckBox();
dontAddToRecentCheckBox = new FlatTriStateCheckBox();
pickFoldersCheckBox = new FlatTriStateCheckBox();
shareAwareCheckBox = new FlatTriStateCheckBox();
forceShowHiddenCheckBox = new FlatTriStateCheckBox();
forceFileSystemCheckBox = new FlatTriStateCheckBox();
noReadOnlyReturnCheckBox = new FlatTriStateCheckBox();
defaultNoMiniModeCheckBox = new FlatTriStateCheckBox();
allNonStorageItemsCheckBox = new FlatTriStateCheckBox();
noTestFileCreateCheckBox = new FlatTriStateCheckBox();
forcePreviewPaneonCheckBox = new FlatTriStateCheckBox();
noValidateCheckBox = new FlatTriStateCheckBox();
hideMruPlacesCheckBox = new FlatTriStateCheckBox();
supportStreamableItemsCheckBox = new FlatTriStateCheckBox();
allowMultiSelectCheckBox = new FlatTriStateCheckBox();
hidePinnedPlacesCheckBox = new FlatTriStateCheckBox();
JPanel messageDialogPanel = new JPanel();
JLabel messageLabel = new JLabel();
JScrollPane messageScrollPane = new JScrollPane();
messageField = new JTextArea();
JLabel buttonsLabel = new JLabel();
buttonsField = new JTextField();
JLabel okButtonLabelLabel = new JLabel();
okButtonLabelField = new JTextField();
JLabel fileNameLabelLabel = new JLabel();
fileNameLabelField = new JTextField();
JLabel fileNameLabel = new JLabel();
fileNameField = new JTextField();
JLabel folderLabel = new JLabel();
folderField = new JTextField();
JLabel saveAsItemLabel = new JLabel();
saveAsItemField = new JTextField();
JLabel defaultFolderLabel = new JLabel();
defaultFolderField = new JTextField();
JLabel defaultExtensionLabel = new JLabel();
defaultExtensionField = new JTextField();
JLabel fileTypesLabel = new JLabel();
fileTypesField = new JComboBox<>();
JLabel fileTypeIndexLabel = new JLabel();
fileTypeIndexSlider = new JSlider();
JButton openButton = new JButton();
JButton saveButton = new JButton();
JButton openDirectButton = new JButton();
JButton saveDirectButton = new JButton();
showMessageDialogOnOKCheckBox = new JCheckBox();
JPanel hSpacer1 = new JPanel(null);
JButton messageDialogButton = new JButton();
JButton messageBoxButton = new JButton();
JScrollPane filesScrollPane = new JScrollPane();
filesField = new JTextArea();
//======== this ========
setLayout(new MigLayout(
"ltr,insets dialog,hidemode 3",
// columns
"[left]" +
"[grow,fill]" +
"[fill]",
// rows
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[grow,fill]"));
//---- ownerLabel ----
ownerLabel.setText("owner");
add(ownerLabel, "cell 0 0");
//---- ownerFrameRadioButton ----
ownerFrameRadioButton.setText("JFrame");
ownerFrameRadioButton.setSelected(true);
add(ownerFrameRadioButton, "cell 1 0");
//---- ownerDialogRadioButton ----
ownerDialogRadioButton.setText("JDialog");
add(ownerDialogRadioButton, "cell 1 0");
//---- ownerNullRadioButton ----
ownerNullRadioButton.setText("null");
add(ownerNullRadioButton, "cell 1 0");
add(ownerSpacer, "cell 1 0,growx");
//---- titleLabel ----
titleLabel.setText("title");
add(titleLabel, "cell 0 1");
add(titleField, "cell 1 1");
//======== panel1 ========
{
panel1.setLayout(new MigLayout(
"insets 2,hidemode 3",
// columns
"[left]para" +
"[left]para" +
"[left]",
// rows
"[]0" +
"[]0" +
"[]0" +
"[]" +
"[]0" +
"[]0" +
"[]0" +
"[]0" +
"[grow]"));
//---- overwritePromptCheckBox ----
overwritePromptCheckBox.setText("overwritePrompt");
panel1.add(overwritePromptCheckBox, "cell 0 0");
//---- pathMustExistCheckBox ----
pathMustExistCheckBox.setText("pathMustExist");
panel1.add(pathMustExistCheckBox, "cell 1 0");
//---- noDereferenceLinksCheckBox ----
noDereferenceLinksCheckBox.setText("noDereferenceLinks");
panel1.add(noDereferenceLinksCheckBox, "cell 2 0");
//---- strictFileTypesCheckBox ----
strictFileTypesCheckBox.setText("strictFileTypes");
panel1.add(strictFileTypesCheckBox, "cell 0 1");
//---- fileMustExistCheckBox ----
fileMustExistCheckBox.setText("fileMustExist");
panel1.add(fileMustExistCheckBox, "cell 1 1");
//---- okButtonNeedsInteractionCheckBox ----
okButtonNeedsInteractionCheckBox.setText("okButtonNeedsInteraction");
panel1.add(okButtonNeedsInteractionCheckBox, "cell 2 1");
//---- noChangeDirCheckBox ----
noChangeDirCheckBox.setText("noChangeDir");
panel1.add(noChangeDirCheckBox, "cell 0 2");
//---- createPromptCheckBox ----
createPromptCheckBox.setText("createPrompt");
panel1.add(createPromptCheckBox, "cell 1 2");
//---- dontAddToRecentCheckBox ----
dontAddToRecentCheckBox.setText("dontAddToRecent");
panel1.add(dontAddToRecentCheckBox, "cell 2 2");
//---- pickFoldersCheckBox ----
pickFoldersCheckBox.setText("pickFolders");
pickFoldersCheckBox.setFont(pickFoldersCheckBox.getFont().deriveFont(pickFoldersCheckBox.getFont().getStyle() | Font.BOLD));
panel1.add(pickFoldersCheckBox, "cell 0 3");
//---- shareAwareCheckBox ----
shareAwareCheckBox.setText("shareAware");
panel1.add(shareAwareCheckBox, "cell 1 3");
//---- forceShowHiddenCheckBox ----
forceShowHiddenCheckBox.setText("forceShowHidden");
forceShowHiddenCheckBox.setFont(forceShowHiddenCheckBox.getFont().deriveFont(forceShowHiddenCheckBox.getFont().getStyle() | Font.BOLD));
panel1.add(forceShowHiddenCheckBox, "cell 2 3");
//---- forceFileSystemCheckBox ----
forceFileSystemCheckBox.setText("forceFileSystem");
panel1.add(forceFileSystemCheckBox, "cell 0 4");
//---- noReadOnlyReturnCheckBox ----
noReadOnlyReturnCheckBox.setText("noReadOnlyReturn");
panel1.add(noReadOnlyReturnCheckBox, "cell 1 4");
//---- defaultNoMiniModeCheckBox ----
defaultNoMiniModeCheckBox.setText("defaultNoMiniMode");
panel1.add(defaultNoMiniModeCheckBox, "cell 2 4");
//---- allNonStorageItemsCheckBox ----
allNonStorageItemsCheckBox.setText("allNonStorageItems");
panel1.add(allNonStorageItemsCheckBox, "cell 0 5");
//---- noTestFileCreateCheckBox ----
noTestFileCreateCheckBox.setText("noTestFileCreate");
panel1.add(noTestFileCreateCheckBox, "cell 1 5");
//---- forcePreviewPaneonCheckBox ----
forcePreviewPaneonCheckBox.setText("forcePreviewPaneon");
panel1.add(forcePreviewPaneonCheckBox, "cell 2 5");
//---- noValidateCheckBox ----
noValidateCheckBox.setText("noValidate");
panel1.add(noValidateCheckBox, "cell 0 6");
//---- hideMruPlacesCheckBox ----
hideMruPlacesCheckBox.setText("hideMruPlaces");
panel1.add(hideMruPlacesCheckBox, "cell 1 6");
//---- supportStreamableItemsCheckBox ----
supportStreamableItemsCheckBox.setText("supportStreamableItems");
panel1.add(supportStreamableItemsCheckBox, "cell 2 6");
//---- allowMultiSelectCheckBox ----
allowMultiSelectCheckBox.setText("allowMultiSelect");
allowMultiSelectCheckBox.setFont(allowMultiSelectCheckBox.getFont().deriveFont(allowMultiSelectCheckBox.getFont().getStyle() | Font.BOLD));
panel1.add(allowMultiSelectCheckBox, "cell 0 7");
//---- hidePinnedPlacesCheckBox ----
hidePinnedPlacesCheckBox.setText("hidePinnedPlaces");
panel1.add(hidePinnedPlacesCheckBox, "cell 1 7");
//======== messageDialogPanel ========
{
messageDialogPanel.setBorder(new TitledBorder("MessageDialog"));
messageDialogPanel.setLayout(new MigLayout(
"hidemode 3",
// columns
"[fill]" +
"[grow,fill]",
// rows
"[grow,fill]" +
"[]"));
//---- messageLabel ----
messageLabel.setText("Message");
messageDialogPanel.add(messageLabel, "cell 0 0,aligny top,growy 0");
//======== messageScrollPane ========
{
//---- messageField ----
messageField.setColumns(40);
messageField.setRows(4);
messageScrollPane.setViewportView(messageField);
}
messageDialogPanel.add(messageScrollPane, "cell 1 0");
//---- buttonsLabel ----
buttonsLabel.setText("Buttons:");
messageDialogPanel.add(buttonsLabel, "cell 0 1");
messageDialogPanel.add(buttonsField, "cell 1 1");
}
panel1.add(messageDialogPanel, "cell 0 8 3 1,grow");
}
add(panel1, "cell 2 1 1 10,growy");
//---- okButtonLabelLabel ----
okButtonLabelLabel.setText("okButtonLabel");
add(okButtonLabelLabel, "cell 0 2");
add(okButtonLabelField, "cell 1 2");
//---- fileNameLabelLabel ----
fileNameLabelLabel.setText("fileNameLabel");
add(fileNameLabelLabel, "cell 0 3");
add(fileNameLabelField, "cell 1 3");
//---- fileNameLabel ----
fileNameLabel.setText("fileName");
add(fileNameLabel, "cell 0 4");
add(fileNameField, "cell 1 4");
//---- folderLabel ----
folderLabel.setText("folder");
add(folderLabel, "cell 0 5");
add(folderField, "cell 1 5");
//---- saveAsItemLabel ----
saveAsItemLabel.setText("saveAsItem");
add(saveAsItemLabel, "cell 0 6");
add(saveAsItemField, "cell 1 6");
//---- defaultFolderLabel ----
defaultFolderLabel.setText("defaultFolder");
add(defaultFolderLabel, "cell 0 7");
add(defaultFolderField, "cell 1 7");
//---- defaultExtensionLabel ----
defaultExtensionLabel.setText("defaultExtension");
add(defaultExtensionLabel, "cell 0 8");
add(defaultExtensionField, "cell 1 8");
//---- fileTypesLabel ----
fileTypesLabel.setText("fileTypes");
add(fileTypesLabel, "cell 0 9");
//---- fileTypesField ----
fileTypesField.setEditable(true);
fileTypesField.setModel(new DefaultComboBoxModel<>(new String[] {
"Text Files,*.txt",
"All Files,*.*",
"Text Files,*.txt,PDF Files,*.pdf,All Files,*.*",
"Text and PDF Files,*.txt;*.pdf"
}));
add(fileTypesField, "cell 1 9");
//---- fileTypeIndexLabel ----
fileTypeIndexLabel.setText("fileTypeIndex");
add(fileTypeIndexLabel, "cell 0 10");
//---- fileTypeIndexSlider ----
fileTypeIndexSlider.setMaximum(10);
fileTypeIndexSlider.setMajorTickSpacing(1);
fileTypeIndexSlider.setValue(0);
fileTypeIndexSlider.setPaintLabels(true);
fileTypeIndexSlider.setSnapToTicks(true);
add(fileTypeIndexSlider, "cell 1 10");
//---- openButton ----
openButton.setText("Open...");
openButton.addActionListener(e -> open());
add(openButton, "cell 0 11 3 1");
//---- saveButton ----
saveButton.setText("Save...");
saveButton.addActionListener(e -> save());
add(saveButton, "cell 0 11 3 1");
//---- openDirectButton ----
openDirectButton.setText("Open (no-thread)...");
openDirectButton.addActionListener(e -> openDirect());
add(openDirectButton, "cell 0 11 3 1");
//---- saveDirectButton ----
saveDirectButton.setText("Save (no-thread)...");
saveDirectButton.addActionListener(e -> saveDirect());
add(saveDirectButton, "cell 0 11 3 1");
//---- showMessageDialogOnOKCheckBox ----
showMessageDialogOnOKCheckBox.setText("show message dialog on OK");
add(showMessageDialogOnOKCheckBox, "cell 0 11 3 1");
add(hSpacer1, "cell 0 11 3 1,growx");
//---- messageDialogButton ----
messageDialogButton.setText("MessageDialog...");
messageDialogButton.addActionListener(e -> messageDialog());
add(messageDialogButton, "cell 0 11 3 1,alignx right,growx 0");
//---- messageBoxButton ----
messageBoxButton.setText("MessageBox...");
messageBoxButton.addActionListener(e -> messageBox());
add(messageBoxButton, "cell 0 11 3 1");
//======== filesScrollPane ========
{
//---- filesField ----
filesField.setRows(8);
filesScrollPane.setViewportView(filesField);
}
add(filesScrollPane, "cell 0 12 3 1,growx");
//---- ownerButtonGroup ----
ButtonGroup ownerButtonGroup = new ButtonGroup();
ownerButtonGroup.add(ownerFrameRadioButton);
ownerButtonGroup.add(ownerDialogRadioButton);
ownerButtonGroup.add(ownerNullRadioButton);
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JRadioButton ownerFrameRadioButton;
private JRadioButton ownerDialogRadioButton;
private JRadioButton ownerNullRadioButton;
private JTextField titleField;
private FlatTriStateCheckBox overwritePromptCheckBox;
private FlatTriStateCheckBox pathMustExistCheckBox;
private FlatTriStateCheckBox noDereferenceLinksCheckBox;
private FlatTriStateCheckBox strictFileTypesCheckBox;
private FlatTriStateCheckBox fileMustExistCheckBox;
private FlatTriStateCheckBox okButtonNeedsInteractionCheckBox;
private FlatTriStateCheckBox noChangeDirCheckBox;
private FlatTriStateCheckBox createPromptCheckBox;
private FlatTriStateCheckBox dontAddToRecentCheckBox;
private FlatTriStateCheckBox pickFoldersCheckBox;
private FlatTriStateCheckBox shareAwareCheckBox;
private FlatTriStateCheckBox forceShowHiddenCheckBox;
private FlatTriStateCheckBox forceFileSystemCheckBox;
private FlatTriStateCheckBox noReadOnlyReturnCheckBox;
private FlatTriStateCheckBox defaultNoMiniModeCheckBox;
private FlatTriStateCheckBox allNonStorageItemsCheckBox;
private FlatTriStateCheckBox noTestFileCreateCheckBox;
private FlatTriStateCheckBox forcePreviewPaneonCheckBox;
private FlatTriStateCheckBox noValidateCheckBox;
private FlatTriStateCheckBox hideMruPlacesCheckBox;
private FlatTriStateCheckBox supportStreamableItemsCheckBox;
private FlatTriStateCheckBox allowMultiSelectCheckBox;
private FlatTriStateCheckBox hidePinnedPlacesCheckBox;
private JTextArea messageField;
private JTextField buttonsField;
private JTextField okButtonLabelField;
private JTextField fileNameLabelField;
private JTextField fileNameField;
private JTextField folderField;
private JTextField saveAsItemField;
private JTextField defaultFolderField;
private JTextField defaultExtensionField;
private JComboBox<String> fileTypesField;
private JSlider fileTypeIndexSlider;
private JCheckBox showMessageDialogOnOKCheckBox;
private JTextArea filesField;
// JFormDesigner - End of variables declaration //GEN-END:variables
}

View File

@@ -0,0 +1,550 @@
JFDML JFormDesigner: "8.3" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
root: new FormRoot {
auxiliary() {
"JavaCodeGenerator.defaultVariableLocal": true
}
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "ltr,insets dialog,hidemode 3"
"$columnConstraints": "[left][grow,fill][fill]"
"$rowConstraints": "[][][][][][][][][][][][][grow,fill]"
} ) {
name: "this"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "ownerLabel"
"text": "owner"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "ownerFrameRadioButton"
"text": "JFrame"
"selected": true
"$buttonGroup": new FormReference( "ownerButtonGroup" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "ownerDialogRadioButton"
"text": "JDialog"
"$buttonGroup": new FormReference( "ownerButtonGroup" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "ownerNullRadioButton"
"text": "null"
"$buttonGroup": new FormReference( "ownerButtonGroup" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "com.jformdesigner.designer.wrapper.HSpacer" ) {
name: "ownerSpacer"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "titleLabel"
"text": "title"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "titleField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 2,hidemode 3"
"$columnConstraints": "[left]para[left]para[left]"
"$rowConstraints": "[]0[]0[]0[][]0[]0[]0[]0[grow]"
} ) {
name: "panel1"
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "overwritePromptCheckBox"
"text": "overwritePrompt"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "pathMustExistCheckBox"
"text": "pathMustExist"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "noDereferenceLinksCheckBox"
"text": "noDereferenceLinks"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "strictFileTypesCheckBox"
"text": "strictFileTypes"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "fileMustExistCheckBox"
"text": "fileMustExist"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "okButtonNeedsInteractionCheckBox"
"text": "okButtonNeedsInteraction"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 1"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "noChangeDirCheckBox"
"text": "noChangeDir"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "createPromptCheckBox"
"text": "createPrompt"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "dontAddToRecentCheckBox"
"text": "dontAddToRecent"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 2"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "pickFoldersCheckBox"
"text": "pickFolders"
"font": new com.jformdesigner.model.SwingDerivedFont( null, 1, 0, false )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "shareAwareCheckBox"
"text": "shareAware"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "forceShowHiddenCheckBox"
"text": "forceShowHidden"
"font": new com.jformdesigner.model.SwingDerivedFont( null, 1, 0, false )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 3"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "forceFileSystemCheckBox"
"text": "forceFileSystem"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "noReadOnlyReturnCheckBox"
"text": "noReadOnlyReturn"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "defaultNoMiniModeCheckBox"
"text": "defaultNoMiniMode"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 4"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "allNonStorageItemsCheckBox"
"text": "allNonStorageItems"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "noTestFileCreateCheckBox"
"text": "noTestFileCreate"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "forcePreviewPaneonCheckBox"
"text": "forcePreviewPaneon"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 5"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "noValidateCheckBox"
"text": "noValidate"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "hideMruPlacesCheckBox"
"text": "hideMruPlaces"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 6"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "supportStreamableItemsCheckBox"
"text": "supportStreamableItems"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 6"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "allowMultiSelectCheckBox"
"text": "allowMultiSelect"
"font": new com.jformdesigner.model.SwingDerivedFont( null, 1, 0, false )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 7"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "hidePinnedPlacesCheckBox"
"text": "hidePinnedPlaces"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 7"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "hidemode 3"
"$columnConstraints": "[fill][grow,fill]"
"$rowConstraints": "[grow,fill][]"
} ) {
name: "messageDialogPanel"
"border": new javax.swing.border.TitledBorder( "MessageDialog" )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "messageLabel"
"text": "Message"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0,aligny top,growy 0"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "messageScrollPane"
add( new FormComponent( "javax.swing.JTextArea" ) {
name: "messageField"
"columns": 40
"rows": 4
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "buttonsLabel"
"text": "Buttons:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "buttonsField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 8 3 1,grow"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 1 1 10,growy"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "okButtonLabelLabel"
"text": "okButtonLabel"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "okButtonLabelField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "fileNameLabelLabel"
"text": "fileNameLabel"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "fileNameLabelField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "fileNameLabel"
"text": "fileName"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "fileNameField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "folderLabel"
"text": "folder"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "folderField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "saveAsItemLabel"
"text": "saveAsItem"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "saveAsItemField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 6"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "defaultFolderLabel"
"text": "defaultFolder"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 7"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "defaultFolderField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 7"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "defaultExtensionLabel"
"text": "defaultExtension"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 8"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "defaultExtensionField"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 8"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "fileTypesLabel"
"text": "fileTypes"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 9"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "fileTypesField"
"editable": true
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "Text Files,*.txt"
addElement( "Text Files,*.txt" )
addElement( "All Files,*.*" )
addElement( "Text Files,*.txt,PDF Files,*.pdf,All Files,*.*" )
addElement( "Text and PDF Files,*.txt;*.pdf" )
}
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 9"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "fileTypeIndexLabel"
"text": "fileTypeIndex"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 10"
} )
add( new FormComponent( "javax.swing.JSlider" ) {
name: "fileTypeIndexSlider"
"maximum": 10
"majorTickSpacing": 1
"value": 0
"paintLabels": true
"snapToTicks": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 10"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "openButton"
"text": "Open..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "open", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 11 3 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "saveButton"
"text": "Save..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "save", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 11 3 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "openDirectButton"
"text": "Open (no-thread)..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "openDirect", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 11 3 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "saveDirectButton"
"text": "Save (no-thread)..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "saveDirect", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 11 3 1"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "showMessageDialogOnOKCheckBox"
"text": "show message dialog on OK"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 11 3 1"
} )
add( new FormComponent( "com.jformdesigner.designer.wrapper.HSpacer" ) {
name: "hSpacer1"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 11 3 1,growx"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "messageDialogButton"
"text": "MessageDialog..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "messageDialog", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 11 3 1,alignx right,growx 0"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "messageBoxButton"
"text": "MessageBox..."
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "messageBox", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 11 3 1"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "filesScrollPane"
add( new FormComponent( "javax.swing.JTextArea" ) {
name: "filesField"
"rows": 8
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 12 3 1,growx"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 890, 630 )
} )
add( new FormNonVisual( "javax.swing.ButtonGroup" ) {
name: "ownerButtonGroup"
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 640 )
} )
}
}

View File

@@ -245,6 +245,9 @@ public class FlatTestFrame
super.dispose();
FlatUIDefaultsInspector.hide();
if( getDefaultCloseOperation() == JFrame.EXIT_ON_CLOSE )
System.exit( 0 );
}
private void updateTitle() {