mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
System File Chooser: fixes for Windows
This commit is contained in:
@@ -17,10 +17,12 @@
|
||||
package com.formdev.flatlaf.testing;
|
||||
|
||||
import static com.formdev.flatlaf.ui.FlatNativeWindowsLibrary.*;
|
||||
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;
|
||||
@@ -75,7 +77,26 @@ public class FlatSystemFileChooserWindowsTest
|
||||
}
|
||||
|
||||
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() ) {
|
||||
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
|
||||
openOrSave( open, direct, null );
|
||||
}
|
||||
|
||||
private void openOrSave( boolean open, boolean direct, Window owner ) {
|
||||
String title = n( titleField.getText() );
|
||||
String okButtonLabel = n( okButtonLabelField.getText() );
|
||||
String fileNameLabel = n( fileNameLabelField.getText() );
|
||||
@@ -215,6 +236,11 @@ public class FlatSystemFileChooserWindowsTest
|
||||
|
||||
private void initComponents() {
|
||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
||||
ownerLabel = new JLabel();
|
||||
ownerFrameRadioButton = new JRadioButton();
|
||||
ownerDialogRadioButton = new JRadioButton();
|
||||
ownerNullRadioButton = new JRadioButton();
|
||||
ownerSpacer = new JPanel(null);
|
||||
titleLabel = new JLabel();
|
||||
titleField = new JTextField();
|
||||
panel1 = new JPanel();
|
||||
@@ -285,12 +311,31 @@ public class FlatSystemFileChooserWindowsTest
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[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 ========
|
||||
{
|
||||
@@ -402,46 +447,46 @@ public class FlatSystemFileChooserWindowsTest
|
||||
hidePinnedPlacesCheckBox.setText("hidePinnedPlaces");
|
||||
panel1.add(hidePinnedPlacesCheckBox, "cell 1 7");
|
||||
}
|
||||
add(panel1, "cell 2 0 1 10,aligny top,growy 0");
|
||||
add(panel1, "cell 2 1 1 10,aligny top,growy 0");
|
||||
|
||||
//---- okButtonLabelLabel ----
|
||||
okButtonLabelLabel.setText("okButtonLabel");
|
||||
add(okButtonLabelLabel, "cell 0 1");
|
||||
add(okButtonLabelField, "cell 1 1");
|
||||
add(okButtonLabelLabel, "cell 0 2");
|
||||
add(okButtonLabelField, "cell 1 2");
|
||||
|
||||
//---- fileNameLabelLabel ----
|
||||
fileNameLabelLabel.setText("fileNameLabel");
|
||||
add(fileNameLabelLabel, "cell 0 2");
|
||||
add(fileNameLabelField, "cell 1 2");
|
||||
add(fileNameLabelLabel, "cell 0 3");
|
||||
add(fileNameLabelField, "cell 1 3");
|
||||
|
||||
//---- fileNameLabel ----
|
||||
fileNameLabel.setText("fileName");
|
||||
add(fileNameLabel, "cell 0 3");
|
||||
add(fileNameField, "cell 1 3");
|
||||
add(fileNameLabel, "cell 0 4");
|
||||
add(fileNameField, "cell 1 4");
|
||||
|
||||
//---- folderLabel ----
|
||||
folderLabel.setText("folder");
|
||||
add(folderLabel, "cell 0 4");
|
||||
add(folderField, "cell 1 4");
|
||||
add(folderLabel, "cell 0 5");
|
||||
add(folderField, "cell 1 5");
|
||||
|
||||
//---- saveAsItemLabel ----
|
||||
saveAsItemLabel.setText("saveAsItem");
|
||||
add(saveAsItemLabel, "cell 0 5");
|
||||
add(saveAsItemField, "cell 1 5");
|
||||
add(saveAsItemLabel, "cell 0 6");
|
||||
add(saveAsItemField, "cell 1 6");
|
||||
|
||||
//---- defaultFolderLabel ----
|
||||
defaultFolderLabel.setText("defaultFolder");
|
||||
add(defaultFolderLabel, "cell 0 6");
|
||||
add(defaultFolderField, "cell 1 6");
|
||||
add(defaultFolderLabel, "cell 0 7");
|
||||
add(defaultFolderField, "cell 1 7");
|
||||
|
||||
//---- defaultExtensionLabel ----
|
||||
defaultExtensionLabel.setText("defaultExtension");
|
||||
add(defaultExtensionLabel, "cell 0 7");
|
||||
add(defaultExtensionField, "cell 1 7");
|
||||
add(defaultExtensionLabel, "cell 0 8");
|
||||
add(defaultExtensionField, "cell 1 8");
|
||||
|
||||
//---- fileTypesLabel ----
|
||||
fileTypesLabel.setText("fileTypes");
|
||||
add(fileTypesLabel, "cell 0 8");
|
||||
add(fileTypesLabel, "cell 0 9");
|
||||
|
||||
//---- fileTypesField ----
|
||||
fileTypesField.setEditable(true);
|
||||
@@ -451,11 +496,11 @@ public class FlatSystemFileChooserWindowsTest
|
||||
"Text Files,*.txt,PDF Files,*.pdf,All Files,*.*",
|
||||
"Text and PDF Files,*.txt;*.pdf"
|
||||
}));
|
||||
add(fileTypesField, "cell 1 8");
|
||||
add(fileTypesField, "cell 1 9");
|
||||
|
||||
//---- fileTypeIndexLabel ----
|
||||
fileTypeIndexLabel.setText("fileTypeIndex");
|
||||
add(fileTypeIndexLabel, "cell 0 9");
|
||||
add(fileTypeIndexLabel, "cell 0 10");
|
||||
|
||||
//---- fileTypeIndexSlider ----
|
||||
fileTypeIndexSlider.setMaximum(10);
|
||||
@@ -463,27 +508,27 @@ public class FlatSystemFileChooserWindowsTest
|
||||
fileTypeIndexSlider.setValue(0);
|
||||
fileTypeIndexSlider.setPaintLabels(true);
|
||||
fileTypeIndexSlider.setSnapToTicks(true);
|
||||
add(fileTypeIndexSlider, "cell 1 9");
|
||||
add(fileTypeIndexSlider, "cell 1 10");
|
||||
|
||||
//---- 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");
|
||||
|
||||
//======== filesScrollPane ========
|
||||
{
|
||||
@@ -492,11 +537,22 @@ public class FlatSystemFileChooserWindowsTest
|
||||
filesField.setRows(8);
|
||||
filesScrollPane.setViewportView(filesField);
|
||||
}
|
||||
add(filesScrollPane, "cell 0 11 3 1,growx");
|
||||
add(filesScrollPane, "cell 0 12 3 1,growx");
|
||||
|
||||
//---- ownerButtonGroup ----
|
||||
ButtonGroup ownerButtonGroup = new ButtonGroup();
|
||||
ownerButtonGroup.add(ownerFrameRadioButton);
|
||||
ownerButtonGroup.add(ownerDialogRadioButton);
|
||||
ownerButtonGroup.add(ownerNullRadioButton);
|
||||
// JFormDesigner - End of component initialization //GEN-END:initComponents
|
||||
}
|
||||
|
||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
||||
private JLabel ownerLabel;
|
||||
private JRadioButton ownerFrameRadioButton;
|
||||
private JRadioButton ownerDialogRadioButton;
|
||||
private JRadioButton ownerNullRadioButton;
|
||||
private JPanel ownerSpacer;
|
||||
private JLabel titleLabel;
|
||||
private JTextField titleField;
|
||||
private JPanel panel1;
|
||||
|
||||
@@ -6,19 +6,52 @@ new FormModel {
|
||||
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"
|
||||
"selected": true
|
||||
"$buttonGroup": new FormReference( "ownerButtonGroup" )
|
||||
}, 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" )
|
||||
}, 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" )
|
||||
}, 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"
|
||||
}, 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"
|
||||
@@ -165,90 +198,90 @@ new FormModel {
|
||||
"value": "cell 1 7"
|
||||
} )
|
||||
}, 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: "okButtonLabelLabel"
|
||||
"text": "okButtonLabel"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 1"
|
||||
"value": "cell 0 2"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "okButtonLabelField"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 1"
|
||||
"value": "cell 1 2"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "fileNameLabelLabel"
|
||||
"text": "fileNameLabel"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 2"
|
||||
"value": "cell 0 3"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "fileNameLabelField"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 2"
|
||||
"value": "cell 1 3"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "fileNameLabel"
|
||||
"text": "fileName"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 3"
|
||||
"value": "cell 0 4"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "fileNameField"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 3"
|
||||
"value": "cell 1 4"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "folderLabel"
|
||||
"text": "folder"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 4"
|
||||
"value": "cell 0 5"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "folderField"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 4"
|
||||
"value": "cell 1 5"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "saveAsItemLabel"
|
||||
"text": "saveAsItem"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 5"
|
||||
"value": "cell 0 6"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "saveAsItemField"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 5"
|
||||
"value": "cell 1 6"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "defaultFolderLabel"
|
||||
"text": "defaultFolder"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 6"
|
||||
"value": "cell 0 7"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "defaultFolderField"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 6"
|
||||
"value": "cell 1 7"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "defaultExtensionLabel"
|
||||
"text": "defaultExtension"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 7"
|
||||
"value": "cell 0 8"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "defaultExtensionField"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 7"
|
||||
"value": "cell 1 8"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "fileTypesLabel"
|
||||
"text": "fileTypes"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 8"
|
||||
"value": "cell 0 9"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JComboBox" ) {
|
||||
name: "fileTypesField"
|
||||
@@ -261,13 +294,13 @@ new FormModel {
|
||||
addElement( "Text and PDF Files,*.txt;*.pdf" )
|
||||
}
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 8"
|
||||
"value": "cell 1 9"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "fileTypeIndexLabel"
|
||||
"text": "fileTypeIndex"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 9"
|
||||
"value": "cell 0 10"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JSlider" ) {
|
||||
name: "fileTypeIndexSlider"
|
||||
@@ -277,35 +310,35 @@ new FormModel {
|
||||
"paintLabels": true
|
||||
"snapToTicks": true
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 9"
|
||||
"value": "cell 1 10"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "openButton"
|
||||
"text": "Open..."
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "open", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 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 FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
|
||||
name: "filesScrollPane"
|
||||
@@ -314,11 +347,16 @@ new FormModel {
|
||||
"rows": 8
|
||||
} )
|
||||
}, 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( 690, 630 )
|
||||
"size": new java.awt.Dimension( 845, 630 )
|
||||
} )
|
||||
add( new FormNonVisual( "javax.swing.ButtonGroup" ) {
|
||||
name: "ownerButtonGroup"
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 0, 640 )
|
||||
} )
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user