diff --git a/flatlaf-natives/flatlaf-natives-macos/src/main/objcpp/MacFileChooser.mm b/flatlaf-natives/flatlaf-natives-macos/src/main/objcpp/MacFileChooser.mm index 44d83fce..77ecd67e 100644 --- a/flatlaf-natives/flatlaf-natives-macos/src/main/objcpp/MacFileChooser.mm +++ b/flatlaf-natives/flatlaf-natives-macos/src/main/objcpp/MacFileChooser.mm @@ -33,7 +33,7 @@ static NSArray* getDialogURLs( NSSavePanel* dialog ); //---- class FileChooserDelegate ---------------------------------------------- -@interface FileChooserDelegate : NSObject { +@interface FileChooserDelegate : NSObject { NSArray* _filters; JavaVM* _jvm; @@ -43,15 +43,15 @@ static NSArray* getDialogURLs( NSSavePanel* dialog ); @property (nonatomic, assign) NSSavePanel* dialog; - - (void)initFilterAccessoryView: (NSMutableArray*)filters :(int)filterIndex + - (void) initFilterAccessoryView: (NSMutableArray*)filters :(int)filterIndex :(NSString*)filterFieldLabel :(bool)showSingleFilterField; - - (void)selectFormat: (id)sender; - - (void)selectFormatAtIndex: (int)index; + - (void) selectFormat: (id)sender; + - (void) selectFormatAtIndex: (int)index; @end @implementation FileChooserDelegate - - (void)initFilterAccessoryView: (NSMutableArray*)filters :(int)filterIndex + - (void) initFilterAccessoryView: (NSMutableArray*)filters :(int)filterIndex :(NSString*)filterFieldLabel :(bool)showSingleFilterField { _filters = filters; @@ -112,12 +112,12 @@ static NSArray* getDialogURLs( NSSavePanel* dialog ); [self selectFormatAtIndex:filterIndex]; } - - (void)selectFormat:(id)sender { + - (void) selectFormat: (id)sender { NSPopUpButton* popupButton = (NSPopUpButton*) sender; [self selectFormatAtIndex:popupButton.indexOfSelectedItem]; } - - (void)selectFormatAtIndex: (int)index { + - (void) selectFormatAtIndex: (int)index { index = MIN( MAX( index, 0 ), _filters.count - 1 ); NSArray* fileTypes = [_filters objectAtIndex:index]; @@ -129,14 +129,17 @@ static NSArray* getDialogURLs( NSSavePanel* dialog ); //---- NSOpenSavePanelDelegate ---- - - (void)initCallback: (JavaVM*)jvm :(jobject)callback { + - (void) initCallback: (JavaVM*)jvm :(jobject)callback { _jvm = jvm; _callback = callback; } - - (BOOL) panel:(id) sender validateURL:(NSURL*) url error:(NSError**) outError { + - (BOOL) panel: (id) sender validateURL:(NSURL*) url error:(NSError**) outError { JNI_COCOA_TRY() + if( _callback == NULL ) + return true; + NSArray* urls = getDialogURLs( sender ); // if multiple files are selected for opening, then the validateURL method @@ -174,6 +177,33 @@ static NSArray* getDialogURLs( NSSavePanel* dialog ); return true; } + //---- NSWindowDelegate ---- + + - (void) windowDidBecomeMain:(NSNotification *) notification { + JNI_COCOA_TRY() + + // Disable main menu bar because the file dialog is modal and it should be not possible + // to select any menu item. Otherwiese an action could show a Swing dialog, which would + // be shown under the file dialog. + // + // NOTE: It is not necessary to re-enable the main menu bar because Swing does this itself. + // When the file dialog is closed and a Swing window becomes active, + // macOS sends windowDidBecomeMain (and windowDidBecomeKey) message to AWTWindow, + // which invokes [self activateWindowMenuBar], + // which invokes [CMenuBar activate:menuBar modallyDisabled:isDisabled], + // which updates main menu bar. + NSMenu* mainMenu = [NSApp mainMenu]; + int count = [mainMenu numberOfItems]; + for( int i = 0; i < count; i++ ) { + NSMenuItem* menuItem = [mainMenu itemAtIndex:i]; + NSMenu *subenu = [menuItem submenu]; + if( [subenu isJavaMenu] ) + [menuItem setEnabled:NO]; + } + + JNI_COCOA_CATCH() + } + @end //---- helper ----------------------------------------------------------------- @@ -260,6 +290,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_formdev_flatlaf_ui_FlatNativeMacLibrary_ [FlatJNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ JNI_COCOA_TRY() + // create open/save panel NSSavePanel* dialog = open ? [NSOpenPanel openPanel] : [NSSavePanel savePanel]; // set appearance @@ -326,10 +357,11 @@ JNIEXPORT jobjectArray JNICALL Java_com_formdev_flatlaf_ui_FlatNativeMacLibrary_ } // initialize callback - if( callback != NULL ) { + if( callback != NULL ) [delegate initCallback :jvm :callback]; - dialog.delegate = delegate; - } + + // set file dialog delegate + dialog.delegate = delegate; // show dialog NSModalResponse response = [dialog runModal]; diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserLinuxTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserLinuxTest.java index df89e063..65c68b49 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserLinuxTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserLinuxTest.java @@ -17,21 +17,16 @@ package com.formdev.flatlaf.testing; import static com.formdev.flatlaf.ui.FlatNativeLinuxLibrary.*; -import java.awt.Dialog; import java.awt.EventQueue; import java.awt.SecondaryLoop; import java.awt.Toolkit; import java.awt.Window; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.event.WindowFocusListener; -import java.awt.event.WindowListener; -import java.awt.event.WindowStateListener; 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.*; @@ -49,7 +44,7 @@ public class FlatSystemFileChooserLinuxTest } FlatTestFrame frame = FlatTestFrame.create( args, "FlatSystemFileChooserLinuxTest" ); -// addListeners( frame ); + FlatSystemFileChooserTest.addListeners( frame ); frame.showFrame( FlatSystemFileChooserLinuxTest::new ); } ); } @@ -80,19 +75,9 @@ public class FlatSystemFileChooserLinuxTest Window frame = SwingUtilities.windowForComponent( this ); if( ownerFrameRadioButton.isSelected() ) openOrSave( open, direct, frame ); - else if( ownerDialogRadioButton.isSelected() ) { - JDialog dialog = new JDialog( frame, "Dummy Modal Dialog", Dialog.DEFAULT_MODALITY_TYPE ); - dialog.setDefaultCloseOperation( JDialog.DISPOSE_ON_CLOSE ); - dialog.addWindowListener( new WindowAdapter() { - @Override - public void windowOpened( WindowEvent e ) { - openOrSave( open, direct, dialog ); - } - } ); - dialog.setSize( 1200, 1000 ); - dialog.setLocationRelativeTo( this ); - dialog.setVisible( true ); - } else + else if( ownerDialogRadioButton.isSelected() ) + new DummyModalDialog( frame, owner -> openOrSave( open, direct, owner ) ).setVisible( true ); + else openOrSave( open, direct, null ); } @@ -174,94 +159,38 @@ public class FlatSystemFileChooserLinuxTest optionsClear.set( optionsClear.get() | option ); } - private static void addListeners( Window w ) { - w.addWindowListener( new WindowListener() { - @Override - public void windowOpened( WindowEvent e ) { - System.out.println( e ); - } - - @Override - public void windowIconified( WindowEvent e ) { - System.out.println( e ); - } - - @Override - public void windowDeiconified( WindowEvent e ) { - System.out.println( e ); - } - - @Override - public void windowDeactivated( WindowEvent e ) { - System.out.println( e ); - } - - @Override - public void windowClosing( WindowEvent e ) { - System.out.println( e ); - } - - @Override - public void windowClosed( WindowEvent e ) { - System.out.println( e ); - } - - @Override - public void windowActivated( WindowEvent e ) { - System.out.println( e ); - } - } ); - w.addWindowStateListener( new WindowStateListener() { - @Override - public void windowStateChanged( WindowEvent e ) { - System.out.println( e ); - } - } ); - w.addWindowFocusListener( new WindowFocusListener() { - @Override - public void windowLostFocus( WindowEvent e ) { - System.out.println( e ); - } - - @Override - public void windowGainedFocus( WindowEvent e ) { - System.out.println( e ); - } - } ); - } - private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents - ownerLabel = new JLabel(); + JLabel ownerLabel = new JLabel(); ownerFrameRadioButton = new JRadioButton(); ownerDialogRadioButton = new JRadioButton(); ownerNullRadioButton = new JRadioButton(); - ownerSpacer = new JPanel(null); - titleLabel = new JLabel(); + JPanel ownerSpacer = new JPanel(null); + JLabel titleLabel = new JLabel(); titleField = new JTextField(); - panel1 = new JPanel(); + 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(); - okButtonLabelLabel = new JLabel(); + JLabel okButtonLabelLabel = new JLabel(); okButtonLabelField = new JTextField(); - currentNameLabel = new JLabel(); + JLabel currentNameLabel = new JLabel(); currentNameField = new JTextField(); - currentFolderLabel = new JLabel(); + JLabel currentFolderLabel = new JLabel(); currentFolderField = new JTextField(); - fileTypesLabel = new JLabel(); + JLabel fileTypesLabel = new JLabel(); fileTypesField = new JComboBox<>(); - fileTypeIndexLabel = new JLabel(); + JLabel fileTypeIndexLabel = new JLabel(); fileTypeIndexSlider = new JSlider(); - openButton = new JButton(); - saveButton = new JButton(); - openDirectButton = new JButton(); - saveDirectButton = new JButton(); + JButton openButton = new JButton(); + JButton saveButton = new JButton(); + JButton openDirectButton = new JButton(); + JButton saveDirectButton = new JButton(); showMessageDialogOnOKCheckBox = new JCheckBox(); - filesScrollPane = new JScrollPane(); + JScrollPane filesScrollPane = new JScrollPane(); filesField = new JTextArea(); //======== this ======== @@ -432,36 +361,22 @@ public class FlatSystemFileChooserLinuxTest } // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables - private JLabel ownerLabel; private JRadioButton ownerFrameRadioButton; private JRadioButton ownerDialogRadioButton; private JRadioButton ownerNullRadioButton; - private JPanel ownerSpacer; - private JLabel titleLabel; private JTextField titleField; - private JPanel panel1; 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 JLabel okButtonLabelLabel; private JTextField okButtonLabelField; - private JLabel currentNameLabel; private JTextField currentNameField; - private JLabel currentFolderLabel; private JTextField currentFolderField; - private JLabel fileTypesLabel; private JComboBox fileTypesField; - private JLabel fileTypeIndexLabel; private JSlider fileTypeIndexSlider; - private JButton openButton; - private JButton saveButton; - private JButton openDirectButton; - private JButton saveDirectButton; private JCheckBox showMessageDialogOnOKCheckBox; - private JScrollPane filesScrollPane; private JTextArea filesField; // JFormDesigner - End of variables declaration //GEN-END:variables } diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserLinuxTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserLinuxTest.jfd index 3506768d..f3ebc996 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserLinuxTest.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserLinuxTest.jfd @@ -3,6 +3,9 @@ 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]" @@ -20,6 +23,9 @@ new FormModel { "text": "JFrame" "$buttonGroup": new FormReference( "ownerButtonGroup" ) "selected": true + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 0" } ) @@ -27,6 +33,9 @@ new FormModel { name: "ownerDialogRadioButton" "text": "JDialog" "$buttonGroup": new FormReference( "ownerButtonGroup" ) + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 0" } ) @@ -34,6 +43,9 @@ new FormModel { name: "ownerNullRadioButton" "text": "null" "$buttonGroup": new FormReference( "ownerButtonGroup" ) + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 0" } ) @@ -50,6 +62,9 @@ new FormModel { } ) add( new FormComponent( "javax.swing.JTextField" ) { name: "titleField" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 1" } ) @@ -64,6 +79,9 @@ new FormModel { "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" } ) @@ -72,30 +90,45 @@ new FormModel { "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" } ) @@ -110,6 +143,9 @@ new FormModel { } ) add( new FormComponent( "javax.swing.JTextField" ) { name: "okButtonLabelField" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 2" } ) @@ -121,6 +157,9 @@ new FormModel { } ) add( new FormComponent( "javax.swing.JTextField" ) { name: "currentNameField" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 3" } ) @@ -132,6 +171,9 @@ new FormModel { } ) add( new FormComponent( "javax.swing.JTextField" ) { name: "currentFolderField" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 4" } ) @@ -151,6 +193,9 @@ new FormModel { 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" } ) @@ -167,6 +212,9 @@ new FormModel { "value": 0 "paintLabels": true "snapToTicks": true + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 6" } ) @@ -201,6 +249,9 @@ new FormModel { 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" } ) @@ -209,6 +260,9 @@ new FormModel { 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" diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserMacTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserMacTest.java index 306e90b4..5c6c2a99 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserMacTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserMacTest.java @@ -17,20 +17,16 @@ package com.formdev.flatlaf.testing; import static com.formdev.flatlaf.ui.FlatNativeMacLibrary.*; -import java.awt.EventQueue; import java.awt.SecondaryLoop; import java.awt.Toolkit; import java.awt.Window; -import java.awt.event.WindowEvent; -import java.awt.event.WindowFocusListener; -import java.awt.event.WindowListener; -import java.awt.event.WindowStateListener; 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.*; @@ -44,6 +40,10 @@ public class FlatSystemFileChooserMacTest 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) @@ -60,8 +60,9 @@ public class FlatSystemFileChooserMacTest } FlatTestFrame frame = FlatTestFrame.create( args, "FlatSystemFileChooserMacTest" ); -// addListeners( frame ); + FlatSystemFileChooserTest.addListeners( frame ); frame.showFrame( FlatSystemFileChooserMacTest::new ); + frame.setJMenuBar( menuBar1 ); } ); } @@ -88,7 +89,16 @@ public class FlatSystemFileChooserMacTest } private void openOrSave( boolean open, boolean direct ) { - Window owner = SwingUtilities.windowForComponent( this ); + 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() ); @@ -168,7 +178,7 @@ public class FlatSystemFileChooserMacTest System.out.println( " secondaryLoop.exit() returned " + secondaryLoop.exit() ); - EventQueue.invokeLater( () -> { + SwingUtilities.invokeLater( () -> { filesField.setText( (files != null) ? Arrays.toString( files ).replace( ',', '\n' ) : "null" ); } ); } ).start(); @@ -189,75 +199,27 @@ public class FlatSystemFileChooserMacTest optionsClear.set( optionsClear.get() | option ); } - @SuppressWarnings( "unused" ) - private static void addListeners( Window w ) { - w.addWindowListener( new WindowListener() { - @Override - public void windowOpened( WindowEvent e ) { - System.out.println( e ); - } - - @Override - public void windowIconified( WindowEvent e ) { - System.out.println( e ); - } - - @Override - public void windowDeiconified( WindowEvent e ) { - System.out.println( e ); - } - - @Override - public void windowDeactivated( WindowEvent e ) { - System.out.println( e ); - } - - @Override - public void windowClosing( WindowEvent e ) { - System.out.println( e ); - } - - @Override - public void windowClosed( WindowEvent e ) { - System.out.println( e ); - } - - @Override - public void windowActivated( WindowEvent e ) { - System.out.println( e ); - } - } ); - w.addWindowStateListener( new WindowStateListener() { - @Override - public void windowStateChanged( WindowEvent e ) { - System.out.println( e ); - } - } ); - w.addWindowFocusListener( new WindowFocusListener() { - @Override - public void windowLostFocus( WindowEvent e ) { - System.out.println( e ); - } - - @Override - public void windowGainedFocus( WindowEvent e ) { - System.out.println( e ); - } - } ); + private void menuItemAction() { + System.out.println( "menu item action" ); } private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents - titleLabel = new JLabel(); + 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(); - panel1 = new JPanel(); - options1Label = new JLabel(); + JPanel panel1 = new JPanel(); + JLabel options1Label = new JLabel(); canChooseFilesCheckBox = new JCheckBox(); canChooseDirectoriesCheckBox = new JCheckBox(); resolvesAliasesCheckBox = new FlatTriStateCheckBox(); allowsMultipleSelectionCheckBox = new FlatTriStateCheckBox(); accessoryViewDisclosedCheckBox = new JCheckBox(); - options2Label = new JLabel(); + JLabel options2Label = new JLabel(); showsTagFieldCheckBox = new FlatTriStateCheckBox(); canCreateDirectoriesCheckBox = new FlatTriStateCheckBox(); canSelectHiddenExtensionCheckBox = new FlatTriStateCheckBox(); @@ -265,31 +227,38 @@ public class FlatSystemFileChooserMacTest extensionHiddenCheckBox = new FlatTriStateCheckBox(); allowsOtherFileTypesCheckBox = new FlatTriStateCheckBox(); treatsFilePackagesAsDirectoriesCheckBox = new FlatTriStateCheckBox(); - options3Label = new JLabel(); + JLabel options3Label = new JLabel(); showSingleFilterFieldCheckBox = new JCheckBox(); - promptLabel = new JLabel(); + JLabel promptLabel = new JLabel(); promptField = new JTextField(); - messageLabel = new JLabel(); + JLabel messageLabel = new JLabel(); messageField = new JTextField(); - filterFieldLabelLabel = new JLabel(); + JLabel filterFieldLabelLabel = new JLabel(); filterFieldLabelField = new JTextField(); - nameFieldLabelLabel = new JLabel(); + JLabel nameFieldLabelLabel = new JLabel(); nameFieldLabelField = new JTextField(); - nameFieldStringValueLabel = new JLabel(); + JLabel nameFieldStringValueLabel = new JLabel(); nameFieldStringValueField = new JTextField(); - directoryURLLabel = new JLabel(); + JLabel directoryURLLabel = new JLabel(); directoryURLField = new JTextField(); - fileTypesLabel = new JLabel(); + JLabel fileTypesLabel = new JLabel(); fileTypesField = new JComboBox<>(); - fileTypeIndexLabel = new JLabel(); + JLabel fileTypeIndexLabel = new JLabel(); fileTypeIndexSlider = new JSlider(); - openButton = new JButton(); - saveButton = new JButton(); - openDirectButton = new JButton(); - saveDirectButton = new JButton(); + JButton openButton = new JButton(); + JButton saveButton = new JButton(); + JButton openDirectButton = new JButton(); + JButton saveDirectButton = new JButton(); showMessageDialogOnOKCheckBox = new JCheckBox(); - filesScrollPane = new JScrollPane(); + 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( @@ -310,12 +279,31 @@ public class FlatSystemFileChooserMacTest "[]" + "[]" + "[]" + + "[]" + "[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 0"); - add(titleField, "cell 1 0"); + add(titleLabel, "cell 0 1"); + add(titleField, "cell 1 1"); //======== panel1 ======== { @@ -407,41 +395,41 @@ public class FlatSystemFileChooserMacTest showSingleFilterFieldCheckBox.setText("showSingleFilterField"); panel1.add(showSingleFilterFieldCheckBox, "cell 0 15"); } - add(panel1, "cell 2 0 1 10,aligny top,growy 0"); + add(panel1, "cell 2 1 1 10,aligny top,growy 0"); //---- promptLabel ---- promptLabel.setText("prompt"); - add(promptLabel, "cell 0 1"); - add(promptField, "cell 1 1"); + add(promptLabel, "cell 0 2"); + add(promptField, "cell 1 2"); //---- messageLabel ---- messageLabel.setText("message"); - add(messageLabel, "cell 0 2"); - add(messageField, "cell 1 2"); + add(messageLabel, "cell 0 3"); + add(messageField, "cell 1 3"); //---- filterFieldLabelLabel ---- filterFieldLabelLabel.setText("filterFieldLabel"); - add(filterFieldLabelLabel, "cell 0 3"); - add(filterFieldLabelField, "cell 1 3"); + add(filterFieldLabelLabel, "cell 0 4"); + add(filterFieldLabelField, "cell 1 4"); //---- nameFieldLabelLabel ---- nameFieldLabelLabel.setText("nameFieldLabel"); - add(nameFieldLabelLabel, "cell 0 4"); - add(nameFieldLabelField, "cell 1 4"); + add(nameFieldLabelLabel, "cell 0 5"); + add(nameFieldLabelField, "cell 1 5"); //---- nameFieldStringValueLabel ---- nameFieldStringValueLabel.setText("nameFieldStringValue"); - add(nameFieldStringValueLabel, "cell 0 5"); - add(nameFieldStringValueField, "cell 1 5"); + add(nameFieldStringValueLabel, "cell 0 6"); + add(nameFieldStringValueField, "cell 1 6"); //---- directoryURLLabel ---- directoryURLLabel.setText("directoryURL"); - add(directoryURLLabel, "cell 0 6"); - add(directoryURLField, "cell 1 6"); + add(directoryURLLabel, "cell 0 7"); + add(directoryURLField, "cell 1 7"); //---- fileTypesLabel ---- fileTypesLabel.setText("fileTypes"); - add(fileTypesLabel, "cell 0 7"); + add(fileTypesLabel, "cell 0 8"); //---- fileTypesField ---- fileTypesField.setEditable(true); @@ -452,11 +440,11 @@ public class FlatSystemFileChooserMacTest "Text and PDF Files,txt,pdf,null", "Compressed,zip,gz,null,Disk Images,dmg,null" })); - add(fileTypesField, "cell 1 7"); + add(fileTypesField, "cell 1 8"); //---- fileTypeIndexLabel ---- fileTypeIndexLabel.setText("fileTypeIndex"); - add(fileTypeIndexLabel, "cell 0 8"); + add(fileTypeIndexLabel, "cell 0 9"); //---- fileTypeIndexSlider ---- fileTypeIndexSlider.setMaximum(10); @@ -464,31 +452,31 @@ public class FlatSystemFileChooserMacTest fileTypeIndexSlider.setValue(0); fileTypeIndexSlider.setPaintLabels(true); fileTypeIndexSlider.setSnapToTicks(true); - add(fileTypeIndexSlider, "cell 1 8"); + add(fileTypeIndexSlider, "cell 1 9"); //---- openButton ---- openButton.setText("Open..."); openButton.addActionListener(e -> open()); - add(openButton, "cell 0 10 3 1"); + add(openButton, "cell 0 11 3 1"); //---- saveButton ---- saveButton.setText("Save..."); saveButton.addActionListener(e -> save()); - add(saveButton, "cell 0 10 3 1"); + add(saveButton, "cell 0 11 3 1"); //---- openDirectButton ---- openDirectButton.setText("Open (no-thread)..."); openDirectButton.addActionListener(e -> openDirect()); - add(openDirectButton, "cell 0 10 3 1"); + add(openDirectButton, "cell 0 11 3 1"); //---- saveDirectButton ---- saveDirectButton.setText("Save (no-thread)..."); saveDirectButton.addActionListener(e -> saveDirect()); - add(saveDirectButton, "cell 0 10 3 1"); + add(saveDirectButton, "cell 0 11 3 1"); //---- showMessageDialogOnOKCheckBox ---- showMessageDialogOnOKCheckBox.setText("show message dialog on OK"); - add(showMessageDialogOnOKCheckBox, "cell 0 10 3 1"); + add(showMessageDialogOnOKCheckBox, "cell 0 11 3 1"); //======== filesScrollPane ======== { @@ -497,21 +485,62 @@ public class FlatSystemFileChooserMacTest filesField.setRows(8); filesScrollPane.setViewportView(filesField); } - add(filesScrollPane, "cell 0 11 3 1,growx"); + 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 JLabel titleLabel; + private JRadioButton ownerFrameRadioButton; + private JRadioButton ownerDialogRadioButton; + private JRadioButton ownerNullRadioButton; private JTextField titleField; - private JPanel panel1; - private JLabel options1Label; private JCheckBox canChooseFilesCheckBox; private JCheckBox canChooseDirectoriesCheckBox; private FlatTriStateCheckBox resolvesAliasesCheckBox; private FlatTriStateCheckBox allowsMultipleSelectionCheckBox; private JCheckBox accessoryViewDisclosedCheckBox; - private JLabel options2Label; private FlatTriStateCheckBox showsTagFieldCheckBox; private FlatTriStateCheckBox canCreateDirectoriesCheckBox; private FlatTriStateCheckBox canSelectHiddenExtensionCheckBox; @@ -519,30 +548,17 @@ public class FlatSystemFileChooserMacTest private FlatTriStateCheckBox extensionHiddenCheckBox; private FlatTriStateCheckBox allowsOtherFileTypesCheckBox; private FlatTriStateCheckBox treatsFilePackagesAsDirectoriesCheckBox; - private JLabel options3Label; private JCheckBox showSingleFilterFieldCheckBox; - private JLabel promptLabel; private JTextField promptField; - private JLabel messageLabel; private JTextField messageField; - private JLabel filterFieldLabelLabel; private JTextField filterFieldLabelField; - private JLabel nameFieldLabelLabel; private JTextField nameFieldLabelField; - private JLabel nameFieldStringValueLabel; private JTextField nameFieldStringValueField; - private JLabel directoryURLLabel; private JTextField directoryURLField; - private JLabel fileTypesLabel; private JComboBox fileTypesField; - private JLabel fileTypeIndexLabel; private JSlider fileTypeIndexSlider; - private JButton openButton; - private JButton saveButton; - private JButton openDirectButton; - private JButton saveDirectButton; private JCheckBox showMessageDialogOnOKCheckBox; - private JScrollPane filesScrollPane; private JTextArea filesField; + private static JMenuBar menuBar1; // JFormDesigner - End of variables declaration //GEN-END:variables } diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserMacTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserMacTest.jfd index 83d73f63..33ffd50a 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserMacTest.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserMacTest.jfd @@ -3,22 +3,70 @@ 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]" + "$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 0" + "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 0" + "value": "cell 1 1" } ) add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "insets 2,hidemode 3" @@ -36,12 +84,18 @@ new FormModel { 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" } ) @@ -49,18 +103,27 @@ new FormModel { 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" } ) @@ -73,42 +136,63 @@ new FormModel { 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" } ) @@ -121,83 +205,104 @@ new FormModel { 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 0 1 10,aligny top,growy 0" + "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 1" + "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 1" + "value": "cell 1 2" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "messageLabel" "text": "message" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 2" + "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 2" + "value": "cell 1 3" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "filterFieldLabelLabel" "text": "filterFieldLabel" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 3" + "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 3" + "value": "cell 1 4" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "nameFieldLabelLabel" "text": "nameFieldLabel" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 4" + "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 4" + "value": "cell 1 5" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "nameFieldStringValueLabel" "text": "nameFieldStringValue" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 5" + "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 5" + "value": "cell 1 6" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "directoryURLLabel" "text": "directoryURL" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 6" + "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 6" + "value": "cell 1 7" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "fileTypesLabel" "text": "fileTypes" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 7" + "value": "cell 0 8" } ) add( new FormComponent( "javax.swing.JComboBox" ) { name: "fileTypesField" @@ -210,14 +315,17 @@ new FormModel { 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 7" + "value": "cell 1 8" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "fileTypeIndexLabel" "text": "fileTypeIndex" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 8" + "value": "cell 0 9" } ) add( new FormComponent( "javax.swing.JSlider" ) { name: "fileTypeIndexSlider" @@ -226,55 +334,107 @@ new FormModel { "value": 0 "paintLabels": true "snapToTicks": true + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 8" + "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 10 3 1" + "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 10 3 1" + "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 10 3 1" + "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 10 3 1" + "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 10 3 1" + "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 11 3 1,growx" + "value": "cell 0 12 3 1,growx" } ) }, new FormLayoutConstraints( null ) { "location": new java.awt.Point( 0, 0 ) - "size": new java.awt.Dimension( 750, 475 ) + "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 ) } ) } } diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserTest.java index 1a2d629e..d7fda240 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserTest.java @@ -16,9 +16,12 @@ package com.formdev.flatlaf.testing; +import java.awt.Component; +import java.awt.Container; import java.awt.Dialog; import java.awt.FileDialog; import java.awt.Frame; +import java.awt.Point; import java.awt.Window; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; @@ -49,6 +52,10 @@ public class FlatSystemFileChooserTest 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) @@ -63,6 +70,7 @@ public class FlatSystemFileChooserTest frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); // necessary because of JavaFX addListeners( frame ); frame.showFrame( FlatSystemFileChooserTest::new ); + frame.setJMenuBar( menuBar1 ); } ); } @@ -322,19 +330,9 @@ public class FlatSystemFileChooserTest Window frame = SwingUtilities.windowForComponent( this ); if( ownerFrameRadioButton.isSelected() ) showConsumer.accept( frame ); - else if( ownerDialogRadioButton.isSelected() ) { - JDialog dialog = new JDialog( frame, "Dummy Modal Dialog", Dialog.DEFAULT_MODALITY_TYPE ); - dialog.setDefaultCloseOperation( JDialog.DISPOSE_ON_CLOSE ); - dialog.addWindowListener( new WindowAdapter() { - @Override - public void windowOpened( WindowEvent e ) { - showConsumer.accept( dialog ); - } - } ); - dialog.setSize( 1200, 1000 ); - dialog.setLocationRelativeTo( this ); - dialog.setVisible( true ); - } else + else if( ownerDialogRadioButton.isSelected() ) + new DummyModalDialog( frame, showConsumer ).setVisible( true ); + else showConsumer.accept( null ); } @@ -423,79 +421,105 @@ public class FlatSystemFileChooserTest DemoPrefs.getState().put( key, value ); } - private static void addListeners( Window w ) { + private void menuItemAction() { + System.out.println( "menu item action" ); + } + + static void addListeners( Window w ) { w.addWindowListener( new WindowListener() { @Override public void windowOpened( WindowEvent e ) { - System.out.println( e ); + printWindowEvent( e ); } @Override public void windowIconified( WindowEvent e ) { - System.out.println( e ); + printWindowEvent( e ); } @Override public void windowDeiconified( WindowEvent e ) { - System.out.println( e ); + printWindowEvent( e ); } @Override public void windowDeactivated( WindowEvent e ) { - System.out.println( e ); + printWindowEvent( e ); } @Override public void windowClosing( WindowEvent e ) { - System.out.println( e ); + printWindowEvent( e ); } @Override public void windowClosed( WindowEvent e ) { - System.out.println( e ); + printWindowEvent( e ); } @Override public void windowActivated( WindowEvent e ) { - System.out.println( e ); + printWindowEvent( e ); } } ); w.addWindowStateListener( new WindowStateListener() { @Override public void windowStateChanged( WindowEvent e ) { - System.out.println( e ); + printWindowEvent( e ); } } ); w.addWindowFocusListener( new WindowFocusListener() { @Override public void windowLostFocus( WindowEvent e ) { - System.out.println( e ); + printWindowEvent( e ); } @Override public void windowGainedFocus( WindowEvent e ) { - System.out.println( e ); + printWindowEvent( e ); } } ); } + static void printWindowEvent( WindowEvent e ) { + String typeStr; + switch( e.getID() ) { + case WindowEvent.WINDOW_OPENED: typeStr = "WINDOW_OPENED "; break; + case WindowEvent.WINDOW_CLOSING: typeStr = "WINDOW_CLOSING "; break; + case WindowEvent.WINDOW_CLOSED: typeStr = "WINDOW_CLOSED "; break; + case WindowEvent.WINDOW_ICONIFIED: typeStr = "WINDOW_ICONIFIED "; break; + case WindowEvent.WINDOW_DEICONIFIED: typeStr = "WINDOW_DEICONIFIED "; break; + case WindowEvent.WINDOW_ACTIVATED: typeStr = "WINDOW_ACTIVATED "; break; + case WindowEvent.WINDOW_DEACTIVATED: typeStr = "WINDOW_DEACTIVATED "; break; + case WindowEvent.WINDOW_GAINED_FOCUS: typeStr = "WINDOW_GAINED_FOCUS "; break; + case WindowEvent.WINDOW_LOST_FOCUS: typeStr = "WINDOW_LOST_FOCUS "; break; + case WindowEvent.WINDOW_STATE_CHANGED: typeStr = "WINDOW_STATE_CHANGED"; break; + default: typeStr = "unknown type "; break; + } + Object source = e.getSource(); + Window opposite = e.getOppositeWindow(); + String sourceStr = (source instanceof Component) ? ((Component)source).getName() : String.valueOf( source ); + String oppositeStr = (opposite != null) ? opposite.getName() : null; + System.out.println( typeStr + " source " + sourceStr + " opposite " + oppositeStr ); + } + private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents - ownerLabel = new JLabel(); + JLabel ownerLabel = new JLabel(); ownerFrameRadioButton = new JRadioButton(); ownerDialogRadioButton = new JRadioButton(); ownerNullRadioButton = new JRadioButton(); - ownerSpacer = new JPanel(null); - dialogTitleLabel = new JLabel(); + JPanel ownerSpacer = new JPanel(null); + JLabel dialogTitleLabel = new JLabel(); dialogTitleField = new JTextField(); - panel1 = new JPanel(); + JPanel panel1 = new JPanel(); directorySelectionCheckBox = new JCheckBox(); multiSelectionEnabledCheckBox = new JCheckBox(); useFileHidingCheckBox = new JCheckBox(); useSystemFileChooserCheckBox = new JCheckBox(); - approveButtonTextLabel = new JLabel(); + JLabel approveButtonTextLabel = new JLabel(); approveButtonTextField = new JTextField(); - approveButtonMnemonicLabel = new JLabel(); + JLabel approveButtonMnemonicLabel = new JLabel(); approveButtonMnemonicField = new JTextField(); currentDirCheckBox = new JCheckBox(); currentDirField = new JTextField(); @@ -506,21 +530,28 @@ public class FlatSystemFileChooserTest selectedFilesCheckBox = new JCheckBox(); selectedFilesField = new JTextField(); selectedFilesChooseButton = new JButton(); - fileTypesLabel = new JLabel(); + JLabel fileTypesLabel = new JLabel(); fileTypesField = new JComboBox<>(); - fileTypeIndexLabel = new JLabel(); + JLabel fileTypeIndexLabel = new JLabel(); fileTypeIndexSlider = new JSlider(); useAcceptAllFileFilterCheckBox = new JCheckBox(); - openButton = new JButton(); - saveButton = new JButton(); - swingOpenButton = new JButton(); - swingSaveButton = new JButton(); - awtOpenButton = new JButton(); - awtSaveButton = new JButton(); + JButton openButton = new JButton(); + JButton saveButton = new JButton(); + JButton swingOpenButton = new JButton(); + JButton swingSaveButton = new JButton(); + JButton awtOpenButton = new JButton(); + JButton awtSaveButton = new JButton(); javafxOpenButton = new JButton(); javafxSaveButton = new JButton(); - outputScrollPane = new JScrollPane(); + JScrollPane outputScrollPane = new JScrollPane(); outputField = 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( @@ -722,6 +753,42 @@ public class FlatSystemFileChooserTest } add(outputScrollPane, "cell 0 9 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); @@ -731,21 +798,15 @@ public class FlatSystemFileChooserTest } // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables - private JLabel ownerLabel; private JRadioButton ownerFrameRadioButton; private JRadioButton ownerDialogRadioButton; private JRadioButton ownerNullRadioButton; - private JPanel ownerSpacer; - private JLabel dialogTitleLabel; private JTextField dialogTitleField; - private JPanel panel1; private JCheckBox directorySelectionCheckBox; private JCheckBox multiSelectionEnabledCheckBox; private JCheckBox useFileHidingCheckBox; private JCheckBox useSystemFileChooserCheckBox; - private JLabel approveButtonTextLabel; private JTextField approveButtonTextField; - private JLabel approveButtonMnemonicLabel; private JTextField approveButtonMnemonicField; private JCheckBox currentDirCheckBox; private JTextField currentDirField; @@ -756,20 +817,151 @@ public class FlatSystemFileChooserTest private JCheckBox selectedFilesCheckBox; private JTextField selectedFilesField; private JButton selectedFilesChooseButton; - private JLabel fileTypesLabel; private JComboBox fileTypesField; - private JLabel fileTypeIndexLabel; private JSlider fileTypeIndexSlider; private JCheckBox useAcceptAllFileFilterCheckBox; - private JButton openButton; - private JButton saveButton; - private JButton swingOpenButton; - private JButton swingSaveButton; - private JButton awtOpenButton; - private JButton awtSaveButton; private JButton javafxOpenButton; private JButton javafxSaveButton; - private JScrollPane outputScrollPane; private JTextArea outputField; + private static JMenuBar menuBar1; // JFormDesigner - End of variables declaration //GEN-END:variables + + //---- class DummyModalDialog --------------------------------------------- + + static class DummyModalDialog + extends JDialog + { + private final Consumer showConsumer; + + DummyModalDialog( Window owner, Consumer showConsumer ) { + super( owner ); + this.showConsumer = showConsumer; + initComponents(); + addListeners( this ); + ((JComponent)getContentPane()).registerKeyboardAction( + e -> dispose(), + KeyStroke.getKeyStroke( "ESCAPE" ), + JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ); + + if( owner != null ) { + Point pt = owner.getLocationOnScreen(); + setLocation( pt.x + (getWidth() / 2), pt.y + 40 ); + } else + setLocationRelativeTo( null ); + } + + private void modalityTypeChanged() { + if( applicationRadioButton.isSelected() ) + setModalityType( ModalityType.APPLICATION_MODAL ); + else if( documentRadioButton.isSelected() ) + setModalityType( ModalityType.DOCUMENT_MODAL ); + else if( toolkitRadioButton.isSelected() ) + setModalityType( ModalityType.TOOLKIT_MODAL ); + else + setModalityType( ModalityType.MODELESS ); + + setVisible( false ); + setVisible( true ); + } + + private void showModalDialog() { + new DummyModalDialog( this, showConsumer ).setVisible( true ); + } + + private void showFileDialog() { + showConsumer.accept( this ); + } + + private void windowOpened() { + showConsumer.accept( this ); + } + + private void initComponents() { + // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents @formatter:off + JLabel label1 = new JLabel(); + applicationRadioButton = new JRadioButton(); + documentRadioButton = new JRadioButton(); + toolkitRadioButton = new JRadioButton(); + modelessRadioButton = new JRadioButton(); + JButton showModalDialogButton = new JButton(); + JButton showFileDialogButton = new JButton(); + + //======== this ======== + setTitle("Dummy Modal Dialog"); + setModalityType(Dialog.ModalityType.APPLICATION_MODAL); + setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + addWindowListener(new WindowAdapter() { + @Override + public void windowOpened(WindowEvent e) { + DummyModalDialog.this.windowOpened(); + } + }); + Container contentPane = getContentPane(); + contentPane.setLayout(new MigLayout( + "hidemode 3", + // columns + "[fill]" + + "[fill]", + // rows + "[]0" + + "[]0" + + "[]0" + + "[]" + + "[]para" + + "[]" + + "[198]")); + + //---- label1 ---- + label1.setText("Modality type:"); + contentPane.add(label1, "cell 0 0"); + + //---- applicationRadioButton ---- + applicationRadioButton.setText("Application"); + applicationRadioButton.setSelected(true); + applicationRadioButton.addActionListener(e -> modalityTypeChanged()); + contentPane.add(applicationRadioButton, "cell 1 0"); + + //---- documentRadioButton ---- + documentRadioButton.setText("Document"); + documentRadioButton.addActionListener(e -> modalityTypeChanged()); + contentPane.add(documentRadioButton, "cell 1 1"); + + //---- toolkitRadioButton ---- + toolkitRadioButton.setText("Toolkit"); + toolkitRadioButton.addActionListener(e -> modalityTypeChanged()); + contentPane.add(toolkitRadioButton, "cell 1 2"); + + //---- modelessRadioButton ---- + modelessRadioButton.setText("modeless"); + modelessRadioButton.addActionListener(e -> modalityTypeChanged()); + contentPane.add(modelessRadioButton, "cell 1 3"); + + //---- showModalDialogButton ---- + showModalDialogButton.setText("Show Modal Dialog..."); + showModalDialogButton.addActionListener(e -> showModalDialog()); + contentPane.add(showModalDialogButton, "cell 0 4 2 1"); + + //---- showFileDialogButton ---- + showFileDialogButton.setText("Show File Dialog..."); + showFileDialogButton.addActionListener(e -> showFileDialog()); + contentPane.add(showFileDialogButton, "cell 0 5 2 1"); + pack(); + setLocationRelativeTo(getOwner()); + + //---- modalityTypeButtonGroup ---- + ButtonGroup modalityTypeButtonGroup = new ButtonGroup(); + modalityTypeButtonGroup.add(applicationRadioButton); + modalityTypeButtonGroup.add(documentRadioButton); + modalityTypeButtonGroup.add(toolkitRadioButton); + modalityTypeButtonGroup.add(modelessRadioButton); + // JFormDesigner - End of component initialization //GEN-END:initComponents @formatter:on + } + + // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables @formatter:off + private JRadioButton applicationRadioButton; + private JRadioButton documentRadioButton; + private JRadioButton toolkitRadioButton; + private JRadioButton modelessRadioButton; + // JFormDesigner - End of variables declaration //GEN-END:variables @formatter:on + } } diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserTest.jfd index 2aa7c66b..9031aa7c 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserTest.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserTest.jfd @@ -3,6 +3,9 @@ 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]" @@ -20,6 +23,9 @@ new FormModel { "text": "JFrame" "selected": true "$buttonGroup": new FormReference( "ownerButtonGroup" ) + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 0" } ) @@ -27,6 +33,9 @@ new FormModel { name: "ownerDialogRadioButton" "text": "JDialog" "$buttonGroup": new FormReference( "ownerButtonGroup" ) + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 0" } ) @@ -34,6 +43,9 @@ new FormModel { name: "ownerNullRadioButton" "text": "null" "$buttonGroup": new FormReference( "ownerButtonGroup" ) + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 0" } ) @@ -50,6 +62,9 @@ new FormModel { } ) add( new FormComponent( "javax.swing.JTextField" ) { name: "dialogTitleField" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 1" } ) @@ -62,12 +77,18 @@ new FormModel { 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" } ) @@ -75,6 +96,9 @@ new FormModel { name: "useFileHidingCheckBox" "text": "useFileHiding" "selected": true + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 2" } ) @@ -82,6 +106,9 @@ new FormModel { name: "useSystemFileChooserCheckBox" "text": "use SystemFileChooser" "selected": true + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 3" } ) @@ -96,6 +123,9 @@ new FormModel { } ) add( new FormComponent( "javax.swing.JTextField" ) { name: "approveButtonTextField" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 2,growx" } ) @@ -108,6 +138,9 @@ new FormModel { 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" } ) @@ -211,6 +244,9 @@ new FormModel { 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" } ) @@ -227,6 +263,9 @@ new FormModel { "value": 0 "paintLabels": true "snapToTicks": true + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 7,growx" } ) @@ -234,6 +273,9 @@ new FormModel { name: "useAcceptAllFileFilterCheckBox" "text": "useAcceptAllFileFilter" "selected": true + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 7" } ) @@ -304,6 +346,9 @@ new FormModel { 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" @@ -312,10 +357,134 @@ new FormModel { "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 ) + } ) } } diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserWindowsTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserWindowsTest.java index cc36e77b..b6ddbc4e 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserWindowsTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserWindowsTest.java @@ -17,17 +17,11 @@ package com.formdev.flatlaf.testing; import static com.formdev.flatlaf.ui.FlatNativeWindowsLibrary.*; -import java.awt.Dialog; import java.awt.EventQueue; import java.awt.Font; import java.awt.SecondaryLoop; import java.awt.Toolkit; import java.awt.Window; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.event.WindowFocusListener; -import java.awt.event.WindowListener; -import java.awt.event.WindowStateListener; import java.util.Arrays; import java.util.concurrent.atomic.AtomicInteger; import java.util.prefs.Preferences; @@ -36,6 +30,7 @@ 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.*; @@ -53,7 +48,7 @@ public class FlatSystemFileChooserWindowsTest } FlatTestFrame frame = FlatTestFrame.create( args, "FlatSystemFileChooserWindowsTest" ); -// addListeners( frame ); + FlatSystemFileChooserTest.addListeners( frame ); frame.showFrame( FlatSystemFileChooserWindowsTest::new ); } ); } @@ -88,19 +83,9 @@ public class FlatSystemFileChooserWindowsTest Window frame = SwingUtilities.windowForComponent( this ); if( ownerFrameRadioButton.isSelected() ) openOrSave( open, direct, frame ); - else if( ownerDialogRadioButton.isSelected() ) { - JDialog dialog = new JDialog( frame, "Dummy Modal Dialog", Dialog.DEFAULT_MODALITY_TYPE ); - dialog.setDefaultCloseOperation( JDialog.DISPOSE_ON_CLOSE ); - dialog.addWindowListener( new WindowAdapter() { - @Override - public void windowOpened( WindowEvent e ) { - openOrSave( open, direct, dialog ); - } - } ); - dialog.setSize( 1200, 1000 ); - dialog.setLocationRelativeTo( this ); - dialog.setVisible( true ); - } else + else if( ownerDialogRadioButton.isSelected() ) + new DummyModalDialog( frame, owner -> openOrSave( open, direct, owner ) ).setVisible( true ); + else openOrSave( open, direct, null ); } @@ -217,73 +202,16 @@ public class FlatSystemFileChooserWindowsTest /* MB_ICONINFORMATION */ 0x00000040 | /* MB_YESNO */ 0x00000004 ) ); } - @SuppressWarnings( "unused" ) - private static void addListeners( Window w ) { - w.addWindowListener( new WindowListener() { - @Override - public void windowOpened( WindowEvent e ) { - System.out.println( e ); - } - - @Override - public void windowIconified( WindowEvent e ) { - System.out.println( e ); - } - - @Override - public void windowDeiconified( WindowEvent e ) { - System.out.println( e ); - } - - @Override - public void windowDeactivated( WindowEvent e ) { - System.out.println( e ); - } - - @Override - public void windowClosing( WindowEvent e ) { - System.out.println( e ); - } - - @Override - public void windowClosed( WindowEvent e ) { - System.out.println( e ); - } - - @Override - public void windowActivated( WindowEvent e ) { - System.out.println( e ); - } - } ); - w.addWindowStateListener( new WindowStateListener() { - @Override - public void windowStateChanged( WindowEvent e ) { - System.out.println( e ); - } - } ); - w.addWindowFocusListener( new WindowFocusListener() { - @Override - public void windowLostFocus( WindowEvent e ) { - System.out.println( e ); - } - - @Override - public void windowGainedFocus( WindowEvent e ) { - System.out.println( e ); - } - } ); - } - private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents - ownerLabel = new JLabel(); + JLabel ownerLabel = new JLabel(); ownerFrameRadioButton = new JRadioButton(); ownerDialogRadioButton = new JRadioButton(); ownerNullRadioButton = new JRadioButton(); - ownerSpacer = new JPanel(null); - titleLabel = new JLabel(); + JPanel ownerSpacer = new JPanel(null); + JLabel titleLabel = new JLabel(); titleField = new JTextField(); - panel1 = new JPanel(); + JPanel panel1 = new JPanel(); overwritePromptCheckBox = new FlatTriStateCheckBox(); pathMustExistCheckBox = new FlatTriStateCheckBox(); noDereferenceLinksCheckBox = new FlatTriStateCheckBox(); @@ -307,39 +235,39 @@ public class FlatSystemFileChooserWindowsTest supportStreamableItemsCheckBox = new FlatTriStateCheckBox(); allowMultiSelectCheckBox = new FlatTriStateCheckBox(); hidePinnedPlacesCheckBox = new FlatTriStateCheckBox(); - messageDialogPanel = new JPanel(); - messageLabel = new JLabel(); - messageScrollPane = new JScrollPane(); + JPanel messageDialogPanel = new JPanel(); + JLabel messageLabel = new JLabel(); + JScrollPane messageScrollPane = new JScrollPane(); messageField = new JTextArea(); - buttonsLabel = new JLabel(); + JLabel buttonsLabel = new JLabel(); buttonsField = new JTextField(); - okButtonLabelLabel = new JLabel(); + JLabel okButtonLabelLabel = new JLabel(); okButtonLabelField = new JTextField(); - fileNameLabelLabel = new JLabel(); + JLabel fileNameLabelLabel = new JLabel(); fileNameLabelField = new JTextField(); - fileNameLabel = new JLabel(); + JLabel fileNameLabel = new JLabel(); fileNameField = new JTextField(); - folderLabel = new JLabel(); + JLabel folderLabel = new JLabel(); folderField = new JTextField(); - saveAsItemLabel = new JLabel(); + JLabel saveAsItemLabel = new JLabel(); saveAsItemField = new JTextField(); - defaultFolderLabel = new JLabel(); + JLabel defaultFolderLabel = new JLabel(); defaultFolderField = new JTextField(); - defaultExtensionLabel = new JLabel(); + JLabel defaultExtensionLabel = new JLabel(); defaultExtensionField = new JTextField(); - fileTypesLabel = new JLabel(); + JLabel fileTypesLabel = new JLabel(); fileTypesField = new JComboBox<>(); - fileTypeIndexLabel = new JLabel(); + JLabel fileTypeIndexLabel = new JLabel(); fileTypeIndexSlider = new JSlider(); - openButton = new JButton(); - saveButton = new JButton(); - openDirectButton = new JButton(); - saveDirectButton = new JButton(); + JButton openButton = new JButton(); + JButton saveButton = new JButton(); + JButton openDirectButton = new JButton(); + JButton saveDirectButton = new JButton(); showMessageDialogOnOKCheckBox = new JCheckBox(); - hSpacer1 = new JPanel(null); - messageDialogButton = new JButton(); - messageBoxButton = new JButton(); - filesScrollPane = new JScrollPane(); + JPanel hSpacer1 = new JPanel(null); + JButton messageDialogButton = new JButton(); + JButton messageBoxButton = new JButton(); + JScrollPane filesScrollPane = new JScrollPane(); filesField = new JTextArea(); //======== this ======== @@ -650,14 +578,10 @@ public class FlatSystemFileChooserWindowsTest } // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables - private JLabel ownerLabel; private JRadioButton ownerFrameRadioButton; private JRadioButton ownerDialogRadioButton; private JRadioButton ownerNullRadioButton; - private JPanel ownerSpacer; - private JLabel titleLabel; private JTextField titleField; - private JPanel panel1; private FlatTriStateCheckBox overwritePromptCheckBox; private FlatTriStateCheckBox pathMustExistCheckBox; private FlatTriStateCheckBox noDereferenceLinksCheckBox; @@ -681,39 +605,18 @@ public class FlatSystemFileChooserWindowsTest private FlatTriStateCheckBox supportStreamableItemsCheckBox; private FlatTriStateCheckBox allowMultiSelectCheckBox; private FlatTriStateCheckBox hidePinnedPlacesCheckBox; - private JPanel messageDialogPanel; - private JLabel messageLabel; - private JScrollPane messageScrollPane; private JTextArea messageField; - private JLabel buttonsLabel; private JTextField buttonsField; - private JLabel okButtonLabelLabel; private JTextField okButtonLabelField; - private JLabel fileNameLabelLabel; private JTextField fileNameLabelField; - private JLabel fileNameLabel; private JTextField fileNameField; - private JLabel folderLabel; private JTextField folderField; - private JLabel saveAsItemLabel; private JTextField saveAsItemField; - private JLabel defaultFolderLabel; private JTextField defaultFolderField; - private JLabel defaultExtensionLabel; private JTextField defaultExtensionField; - private JLabel fileTypesLabel; private JComboBox fileTypesField; - private JLabel fileTypeIndexLabel; private JSlider fileTypeIndexSlider; - private JButton openButton; - private JButton saveButton; - private JButton openDirectButton; - private JButton saveDirectButton; private JCheckBox showMessageDialogOnOKCheckBox; - private JPanel hSpacer1; - private JButton messageDialogButton; - private JButton messageBoxButton; - private JScrollPane filesScrollPane; private JTextArea filesField; // JFormDesigner - End of variables declaration //GEN-END:variables } diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserWindowsTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserWindowsTest.jfd index 040c5c82..86f6219e 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserWindowsTest.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSystemFileChooserWindowsTest.jfd @@ -3,6 +3,9 @@ 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]" @@ -20,6 +23,9 @@ new FormModel { "text": "JFrame" "selected": true "$buttonGroup": new FormReference( "ownerButtonGroup" ) + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 0" } ) @@ -27,6 +33,9 @@ new FormModel { name: "ownerDialogRadioButton" "text": "JDialog" "$buttonGroup": new FormReference( "ownerButtonGroup" ) + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 0" } ) @@ -34,6 +43,9 @@ new FormModel { name: "ownerNullRadioButton" "text": "null" "$buttonGroup": new FormReference( "ownerButtonGroup" ) + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 0" } ) @@ -50,6 +62,9 @@ new FormModel { } ) add( new FormComponent( "javax.swing.JTextField" ) { name: "titleField" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 1" } ) @@ -62,54 +77,81 @@ new FormModel { 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" } ) @@ -117,12 +159,18 @@ new FormModel { 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" } ) @@ -130,60 +178,90 @@ new FormModel { 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" } ) @@ -191,12 +269,18 @@ new FormModel { 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" } ) @@ -219,6 +303,9 @@ new FormModel { name: "messageField" "columns": 40 "rows": 4 + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 0" @@ -231,6 +318,9 @@ new FormModel { } ) add( new FormComponent( "javax.swing.JTextField" ) { name: "buttonsField" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 1" } ) @@ -248,6 +338,9 @@ new FormModel { } ) add( new FormComponent( "javax.swing.JTextField" ) { name: "okButtonLabelField" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 2" } ) @@ -259,6 +352,9 @@ new FormModel { } ) add( new FormComponent( "javax.swing.JTextField" ) { name: "fileNameLabelField" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 3" } ) @@ -270,6 +366,9 @@ new FormModel { } ) add( new FormComponent( "javax.swing.JTextField" ) { name: "fileNameField" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 4" } ) @@ -281,6 +380,9 @@ new FormModel { } ) add( new FormComponent( "javax.swing.JTextField" ) { name: "folderField" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 5" } ) @@ -292,6 +394,9 @@ new FormModel { } ) add( new FormComponent( "javax.swing.JTextField" ) { name: "saveAsItemField" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 6" } ) @@ -303,6 +408,9 @@ new FormModel { } ) add( new FormComponent( "javax.swing.JTextField" ) { name: "defaultFolderField" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 7" } ) @@ -314,6 +422,9 @@ new FormModel { } ) add( new FormComponent( "javax.swing.JTextField" ) { name: "defaultExtensionField" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 8" } ) @@ -333,6 +444,9 @@ new FormModel { 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" } ) @@ -349,6 +463,9 @@ new FormModel { "value": 0 "paintLabels": true "snapToTicks": true + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 10" } ) @@ -383,6 +500,9 @@ new FormModel { 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" } ) @@ -410,6 +530,9 @@ new FormModel { 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"