mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
FileChooser: extended FlatFileChooserTest to support testing all JFileChooser properties (issue #795)
This commit is contained in:
@@ -429,7 +429,7 @@ public class FlatFileChooserUI
|
||||
iconFunction = (Function<File, Icon>) UIManager.get( "FileChooser.shortcuts.iconFunction" );
|
||||
|
||||
FileSystemView fsv = fc.getFileSystemView();
|
||||
File[] files = getChooserShortcutPanelFiles( fsv );
|
||||
File[] files = JavaCompatibility2.getChooserShortcutPanelFiles( fsv );
|
||||
if( filesFunction != null )
|
||||
files = filesFunction.apply( files );
|
||||
|
||||
@@ -498,32 +498,6 @@ public class FlatFileChooserUI
|
||||
return button;
|
||||
}
|
||||
|
||||
protected File[] getChooserShortcutPanelFiles( FileSystemView fsv ) {
|
||||
try {
|
||||
if( SystemInfo.isJava_12_orLater ) {
|
||||
Method m = fsv.getClass().getMethod( "getChooserShortcutPanelFiles" );
|
||||
File[] files = (File[]) m.invoke( fsv );
|
||||
|
||||
// on macOS and Linux, files consists only of the user home directory
|
||||
if( files.length == 1 && files[0].equals( new File( System.getProperty( "user.home" ) ) ) )
|
||||
files = new File[0];
|
||||
|
||||
return files;
|
||||
} else if( SystemInfo.isWindows ) {
|
||||
Class<?> cls = Class.forName( "sun.awt.shell.ShellFolder" );
|
||||
Method m = cls.getMethod( "get", String.class );
|
||||
return (File[]) m.invoke( null, "fileChooserShortcutPanelFolders" );
|
||||
}
|
||||
} catch( IllegalAccessException ex ) {
|
||||
// do not log because access may be denied via VM option '--illegal-access=deny'
|
||||
} catch( Exception ex ) {
|
||||
LoggingFacade.INSTANCE.logSevere( null, ex );
|
||||
}
|
||||
|
||||
// fallback
|
||||
return new File[0];
|
||||
}
|
||||
|
||||
protected String getDisplayName( FileSystemView fsv, File file ) {
|
||||
if( displayNameFunction != null ) {
|
||||
String name = displayNameFunction.apply( file );
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.formdev.flatlaf.ui;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
@@ -25,6 +26,7 @@ import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.filechooser.FileSystemView;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import com.formdev.flatlaf.util.LoggingFacade;
|
||||
@@ -88,4 +90,64 @@ public class JavaCompatibility2
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Java 8 - 11 on Windows: sun.awt.shell.ShellFolder.get( "fileChooserShortcutPanelFolders" )
|
||||
* <br>
|
||||
* Java 12: javax.swing.filechooser.FileSystemView.getChooserShortcutPanelFiles()
|
||||
*
|
||||
* @since 3.4
|
||||
*/
|
||||
public static File[] getChooserShortcutPanelFiles( FileSystemView fsv ) {
|
||||
try {
|
||||
if( SystemInfo.isJava_12_orLater ) {
|
||||
Method m = fsv.getClass().getMethod( "getChooserShortcutPanelFiles" );
|
||||
File[] files = (File[]) m.invoke( fsv );
|
||||
|
||||
// on macOS and Linux, files consists only of the user home directory
|
||||
if( files.length == 1 && files[0].equals( new File( System.getProperty( "user.home" ) ) ) )
|
||||
files = new File[0];
|
||||
|
||||
return files;
|
||||
} else if( SystemInfo.isWindows ) {
|
||||
Class<?> cls = Class.forName( "sun.awt.shell.ShellFolder" );
|
||||
Method m = cls.getMethod( "get", String.class );
|
||||
return (File[]) m.invoke( null, "fileChooserShortcutPanelFolders" );
|
||||
}
|
||||
} catch( IllegalAccessException ex ) {
|
||||
// do not log because access may be denied via VM option '--illegal-access=deny'
|
||||
} catch( Exception ex ) {
|
||||
LoggingFacade.INSTANCE.logSevere( null, ex );
|
||||
}
|
||||
|
||||
// fallback
|
||||
return new File[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Java 8: sun.awt.shell.ShellFolder.get( "fileChooserComboBoxFolders" )
|
||||
* <br>
|
||||
* Java 9: javax.swing.filechooser.FileSystemView.getChooserComboBoxFiles()
|
||||
*
|
||||
* @since 3.4
|
||||
*/
|
||||
public static File[] getChooserComboBoxFiles( FileSystemView fsv ) {
|
||||
try {
|
||||
if( SystemInfo.isJava_9_orLater ) {
|
||||
Method m = fsv.getClass().getMethod( "getChooserComboBoxFiles" );
|
||||
return (File[]) m.invoke( fsv );
|
||||
} else {
|
||||
Class<?> cls = Class.forName( "sun.awt.shell.ShellFolder" );
|
||||
Method m = cls.getMethod( "get", String.class );
|
||||
return (File[]) m.invoke( null, "fileChooserComboBoxFolders" );
|
||||
}
|
||||
} catch( IllegalAccessException ex ) {
|
||||
// do not log because access may be denied via VM option '--illegal-access=deny'
|
||||
} catch( Exception ex ) {
|
||||
LoggingFacade.INSTANCE.logSevere( null, ex );
|
||||
}
|
||||
|
||||
// fallback
|
||||
return new File[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,18 @@
|
||||
package com.formdev.flatlaf.testing;
|
||||
|
||||
import java.awt.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Function;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import javax.swing.filechooser.FileSystemView;
|
||||
import com.formdev.flatlaf.icons.FlatFileChooserHomeFolderIcon;
|
||||
import com.formdev.flatlaf.ui.JavaCompatibility2;
|
||||
import net.miginfocom.swing.*;
|
||||
|
||||
/**
|
||||
@@ -66,6 +71,55 @@ public class FlatFileChooserTest
|
||||
|
||||
FlatFileChooserTest() {
|
||||
initComponents();
|
||||
|
||||
dialogTypeField.init( DialogType.class, false );
|
||||
fileSelectionModeField.init( FileSelectionMode.class, false );
|
||||
|
||||
showControlButtonsCheckBox.setSelected( fileChooser1.getControlButtonsAreShown() );
|
||||
multiSelectionCheckBox.setSelected( fileChooser1.isMultiSelectionEnabled() );
|
||||
fileHidingCheckBox.setSelected( fileChooser1.isFileHidingEnabled() );
|
||||
dragCheckBox.setSelected( fileChooser1.getDragEnabled() );
|
||||
filterAllFilesCheckBox.setSelected( fileChooser1.isAcceptAllFileFilterUsed() );
|
||||
|
||||
updateOutput();
|
||||
}
|
||||
|
||||
private void fileChooser1PropertyChange( PropertyChangeEvent e ) {
|
||||
switch( e.getPropertyName() ) {
|
||||
case JFileChooser.DIRECTORY_CHANGED_PROPERTY:
|
||||
case JFileChooser.SELECTED_FILE_CHANGED_PROPERTY:
|
||||
case JFileChooser.SELECTED_FILES_CHANGED_PROPERTY:
|
||||
updateOutput();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateOutput() {
|
||||
currentDirectoryField.setText( String.valueOf( fileChooser1.getCurrentDirectory() ) );
|
||||
selectedFileField.setText( String.valueOf( fileChooser1.getSelectedFile() ) );
|
||||
selectedFilesField.setText( Arrays.toString( fileChooser1.getSelectedFiles() ) );
|
||||
}
|
||||
|
||||
private void dialogTypeChanged() {
|
||||
DialogType value = dialogTypeField.getSelectedValue();
|
||||
int dialogType = (value != null) ? value.value : JFileChooser.OPEN_DIALOG;
|
||||
|
||||
if( dialogType == JFileChooser.CUSTOM_DIALOG )
|
||||
fileChooser1.setApproveButtonText( "Custom" );
|
||||
fileChooser1.setDialogType( dialogType );
|
||||
}
|
||||
|
||||
private void fileSelectionModeChanged() {
|
||||
FileSelectionMode value = fileSelectionModeField.getSelectedValue();
|
||||
int mode = (value != null) ? value.value : JFileChooser.FILES_ONLY;
|
||||
|
||||
fileChooser1.setFileSelectionMode( mode );
|
||||
}
|
||||
|
||||
private void showControlButtons() {
|
||||
fileChooser1.setControlButtonsAreShown( showControlButtonsCheckBox.isSelected() );
|
||||
fileChooser1.revalidate();
|
||||
fileChooser1.repaint();
|
||||
}
|
||||
|
||||
private void showShortcuts() {
|
||||
@@ -85,14 +139,102 @@ public class FlatFileChooserTest
|
||||
fileChooser1.repaint();
|
||||
}
|
||||
|
||||
private void multiSelection() {
|
||||
fileChooser1.setMultiSelectionEnabled( multiSelectionCheckBox.isSelected() );
|
||||
}
|
||||
|
||||
private void fileHiding() {
|
||||
fileChooser1.setFileHidingEnabled( fileHidingCheckBox.isSelected() );
|
||||
}
|
||||
|
||||
private void drag() {
|
||||
fileChooser1.setDragEnabled( dragCheckBox.isSelected() );
|
||||
}
|
||||
|
||||
private final FileFilter TEXT_FILTER = new FileNameExtensionFilter( "Text Files", "txt", "md" );
|
||||
private final FileFilter IMAGES_FILTER = new FileNameExtensionFilter( "Images", "png", "git", "jpg", "jpeg" );
|
||||
private final FileFilter LONG_DESC_FILTER = new FileNameExtensionFilter( "Some long description (.png, .gif, .jpg, .svg)", "png", "gif", "jpg", "jpeg" );
|
||||
|
||||
private void filterChanged() {
|
||||
boolean all = filterAllFilesCheckBox.isSelected();
|
||||
if( all != fileChooser1.isAcceptAllFileFilterUsed() )
|
||||
fileChooser1.setAcceptAllFileFilterUsed( all );
|
||||
|
||||
addRemoveFilter( filterTextFilesCheckBox.isSelected(), TEXT_FILTER );
|
||||
addRemoveFilter( filterImagesCheckBox.isSelected(), IMAGES_FILTER );
|
||||
addRemoveFilter( filterLongDescCheckBox.isSelected(), LONG_DESC_FILTER );
|
||||
}
|
||||
|
||||
private void addRemoveFilter( boolean add, FileFilter filter ) {
|
||||
if( add )
|
||||
fileChooser1.addChoosableFileFilter( filter );
|
||||
else
|
||||
fileChooser1.removeChoosableFileFilter( filter );
|
||||
}
|
||||
|
||||
private void printShortcutFiles() {
|
||||
printFiles( JavaCompatibility2.getChooserShortcutPanelFiles( fileChooser1.getFileSystemView() ) );
|
||||
}
|
||||
|
||||
private void printComboBoxFiles() {
|
||||
printFiles( JavaCompatibility2.getChooserComboBoxFiles( fileChooser1.getFileSystemView() ) );
|
||||
}
|
||||
|
||||
private void printRoots() {
|
||||
FileSystemView fsv = fileChooser1.getFileSystemView();
|
||||
File[] roots = fsv.getRoots();
|
||||
printFiles( roots );
|
||||
|
||||
for( File root : roots )
|
||||
printFiles( fsv.getFiles( root, true ) );
|
||||
}
|
||||
|
||||
private void printFiles( File[] files ) {
|
||||
System.out.println( "--------------------------------" );
|
||||
FileSystemView fsv = fileChooser1.getFileSystemView();
|
||||
for( File file : files ) {
|
||||
System.out.printf( "%-30s ", file );
|
||||
System.out.println(
|
||||
(fsv.isComputerNode( file ) ? "computer " : "") +
|
||||
(fsv.isDrive( file ) ? "drive " : "") +
|
||||
(fsv.isFileSystem( file ) ? "fileSystem " : "") +
|
||||
(fsv.isFileSystemRoot( file ) ? "fileSystemRoot " : "") +
|
||||
(fsv.isFloppyDrive( file ) ? "floppyDrive " : "") +
|
||||
(fsv.isHiddenFile( file ) ? "hiddenFile " : "") +
|
||||
(fsv.isRoot( file ) ? "root " : "") +
|
||||
(fsv.isTraversable( file ) ? "traversable " : "") );
|
||||
}
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
||||
JLabel fileChooserLabel = new JLabel();
|
||||
JPanel panel1 = new JPanel();
|
||||
fileChooser1 = new JFileChooser();
|
||||
JPanel panel3 = new JPanel();
|
||||
JLabel currentDirectoryLabel = new JLabel();
|
||||
currentDirectoryField = new JTextField();
|
||||
JLabel selectedFileLabel = new JLabel();
|
||||
selectedFileField = new JTextField();
|
||||
JLabel selectedFilesLabel = new JLabel();
|
||||
selectedFilesField = new JTextField();
|
||||
JLabel dialogTypeLabel = new JLabel();
|
||||
dialogTypeField = new FlatTestEnumSelector<>();
|
||||
showControlButtonsCheckBox = new JCheckBox();
|
||||
showShortcutsCheckBox = new JCheckBox();
|
||||
showAccessoryCheckBox = new JCheckBox();
|
||||
JLabel fileSelectionModeLabel = new JLabel();
|
||||
fileSelectionModeField = new FlatTestEnumSelector<>();
|
||||
multiSelectionCheckBox = new JCheckBox();
|
||||
fileHidingCheckBox = new JCheckBox();
|
||||
dragCheckBox = new JCheckBox();
|
||||
JLabel filtersLabel = new JLabel();
|
||||
filterAllFilesCheckBox = new JCheckBox();
|
||||
filterTextFilesCheckBox = new JCheckBox();
|
||||
filterImagesCheckBox = new JCheckBox();
|
||||
filterLongDescCheckBox = new JCheckBox();
|
||||
printShortcutFilesButton = new JButton();
|
||||
printComboBoxFilesButton = new JButton();
|
||||
printRootsButton = new JButton();
|
||||
JLabel label1 = new JLabel();
|
||||
JLabel label2 = new JLabel();
|
||||
JLabel label3 = new JLabel();
|
||||
@@ -110,10 +252,17 @@ public class FlatFileChooserTest
|
||||
"ltr,insets dialog,hidemode 3",
|
||||
// columns
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[grow]",
|
||||
// rows
|
||||
"[grow,fill]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]para" +
|
||||
"[]"));
|
||||
|
||||
//---- fileChooserLabel ----
|
||||
@@ -124,82 +273,216 @@ public class FlatFileChooserTest
|
||||
{
|
||||
panel1.setBorder(new MatteBorder(4, 4, 4, 4, Color.red));
|
||||
panel1.setLayout(new BorderLayout());
|
||||
|
||||
//---- fileChooser1 ----
|
||||
fileChooser1.addPropertyChangeListener(e -> fileChooser1PropertyChange(e));
|
||||
panel1.add(fileChooser1, BorderLayout.CENTER);
|
||||
}
|
||||
add(panel1, "cell 1 0,growx");
|
||||
add(panel1, "cell 1 0 2 1,growx");
|
||||
|
||||
//======== panel3 ========
|
||||
{
|
||||
panel3.setLayout(new MigLayout(
|
||||
"hidemode 3",
|
||||
// columns
|
||||
"[fill]" +
|
||||
"[fill]",
|
||||
// rows
|
||||
"[]"));
|
||||
//---- currentDirectoryLabel ----
|
||||
currentDirectoryLabel.setText("Current Directory:");
|
||||
add(currentDirectoryLabel, "cell 0 1");
|
||||
|
||||
//---- showShortcutsCheckBox ----
|
||||
showShortcutsCheckBox.setText("Show Shortcuts");
|
||||
showShortcutsCheckBox.setSelected(true);
|
||||
showShortcutsCheckBox.addActionListener(e -> showShortcuts());
|
||||
panel3.add(showShortcutsCheckBox, "cell 0 0");
|
||||
//---- currentDirectoryField ----
|
||||
currentDirectoryField.setEditable(false);
|
||||
add(currentDirectoryField, "cell 1 1 2 1,growx");
|
||||
|
||||
//---- showAccessoryCheckBox ----
|
||||
showAccessoryCheckBox.setText("Show Accessory");
|
||||
showAccessoryCheckBox.addActionListener(e -> showAccessory());
|
||||
panel3.add(showAccessoryCheckBox, "cell 1 0");
|
||||
}
|
||||
add(panel3, "cell 1 1");
|
||||
//---- selectedFileLabel ----
|
||||
selectedFileLabel.setText("Selected File:");
|
||||
add(selectedFileLabel, "cell 0 2");
|
||||
|
||||
//---- selectedFileField ----
|
||||
selectedFileField.setEditable(false);
|
||||
add(selectedFileField, "cell 1 2 2 1,growx");
|
||||
|
||||
//---- selectedFilesLabel ----
|
||||
selectedFilesLabel.setText("Selected Files:");
|
||||
add(selectedFilesLabel, "cell 0 3");
|
||||
|
||||
//---- selectedFilesField ----
|
||||
selectedFilesField.setEditable(false);
|
||||
add(selectedFilesField, "cell 1 3 2 1,growx");
|
||||
|
||||
//---- dialogTypeLabel ----
|
||||
dialogTypeLabel.setText("Dialog Type:");
|
||||
add(dialogTypeLabel, "cell 0 4");
|
||||
|
||||
//---- dialogTypeField ----
|
||||
dialogTypeField.addActionListener(e -> dialogTypeChanged());
|
||||
add(dialogTypeField, "cell 1 4");
|
||||
|
||||
//---- showControlButtonsCheckBox ----
|
||||
showControlButtonsCheckBox.setText("Show Control Buttons");
|
||||
showControlButtonsCheckBox.addActionListener(e -> showControlButtons());
|
||||
add(showControlButtonsCheckBox, "cell 2 4");
|
||||
|
||||
//---- showShortcutsCheckBox ----
|
||||
showShortcutsCheckBox.setText("Show Shortcuts");
|
||||
showShortcutsCheckBox.setSelected(true);
|
||||
showShortcutsCheckBox.addActionListener(e -> showShortcuts());
|
||||
add(showShortcutsCheckBox, "cell 2 4");
|
||||
|
||||
//---- showAccessoryCheckBox ----
|
||||
showAccessoryCheckBox.setText("Show Accessory");
|
||||
showAccessoryCheckBox.addActionListener(e -> showAccessory());
|
||||
add(showAccessoryCheckBox, "cell 2 4");
|
||||
|
||||
//---- fileSelectionModeLabel ----
|
||||
fileSelectionModeLabel.setText("File Selection Mode:");
|
||||
add(fileSelectionModeLabel, "cell 0 5");
|
||||
|
||||
//---- fileSelectionModeField ----
|
||||
fileSelectionModeField.addActionListener(e -> fileSelectionModeChanged());
|
||||
add(fileSelectionModeField, "cell 1 5");
|
||||
|
||||
//---- multiSelectionCheckBox ----
|
||||
multiSelectionCheckBox.setText("Multi Selection");
|
||||
multiSelectionCheckBox.addActionListener(e -> multiSelection());
|
||||
add(multiSelectionCheckBox, "cell 2 5");
|
||||
|
||||
//---- fileHidingCheckBox ----
|
||||
fileHidingCheckBox.setText("File Hiding");
|
||||
fileHidingCheckBox.addActionListener(e -> fileHiding());
|
||||
add(fileHidingCheckBox, "cell 2 5");
|
||||
|
||||
//---- dragCheckBox ----
|
||||
dragCheckBox.setText("Drag");
|
||||
dragCheckBox.addActionListener(e -> drag());
|
||||
add(dragCheckBox, "cell 2 5");
|
||||
|
||||
//---- filtersLabel ----
|
||||
filtersLabel.setText("Filters:");
|
||||
add(filtersLabel, "cell 0 6");
|
||||
|
||||
//---- filterAllFilesCheckBox ----
|
||||
filterAllFilesCheckBox.setText("All Files");
|
||||
filterAllFilesCheckBox.addActionListener(e -> filterChanged());
|
||||
add(filterAllFilesCheckBox, "cell 1 6 2 1");
|
||||
|
||||
//---- filterTextFilesCheckBox ----
|
||||
filterTextFilesCheckBox.setText("Text Files");
|
||||
filterTextFilesCheckBox.addActionListener(e -> filterChanged());
|
||||
add(filterTextFilesCheckBox, "cell 1 6 2 1");
|
||||
|
||||
//---- filterImagesCheckBox ----
|
||||
filterImagesCheckBox.setText("Images");
|
||||
filterImagesCheckBox.addActionListener(e -> filterChanged());
|
||||
add(filterImagesCheckBox, "cell 1 6 2 1");
|
||||
|
||||
//---- filterLongDescCheckBox ----
|
||||
filterLongDescCheckBox.setText("Long description");
|
||||
filterLongDescCheckBox.addActionListener(e -> filterChanged());
|
||||
add(filterLongDescCheckBox, "cell 1 6 2 1");
|
||||
|
||||
//---- printShortcutFilesButton ----
|
||||
printShortcutFilesButton.setText("Print Shortcut Files");
|
||||
printShortcutFilesButton.addActionListener(e -> printShortcutFiles());
|
||||
add(printShortcutFilesButton, "cell 1 7 2 1");
|
||||
|
||||
//---- printComboBoxFilesButton ----
|
||||
printComboBoxFilesButton.setText("Print ComboBox Files");
|
||||
printComboBoxFilesButton.addActionListener(e -> printComboBoxFiles());
|
||||
add(printComboBoxFilesButton, "cell 1 7 2 1");
|
||||
|
||||
//---- printRootsButton ----
|
||||
printRootsButton.setText("Print Roots");
|
||||
printRootsButton.addActionListener(e -> printRoots());
|
||||
add(printRootsButton, "cell 1 7 2 1");
|
||||
|
||||
//---- label1 ----
|
||||
label1.setText("icons:");
|
||||
add(label1, "cell 0 2");
|
||||
add(label1, "cell 0 8");
|
||||
|
||||
//---- label2 ----
|
||||
label2.setIcon(UIManager.getIcon("FileView.directoryIcon"));
|
||||
add(label2, "cell 1 2");
|
||||
add(label2, "cell 1 8 2 1");
|
||||
|
||||
//---- label3 ----
|
||||
label3.setIcon(UIManager.getIcon("FileView.fileIcon"));
|
||||
add(label3, "cell 1 2");
|
||||
add(label3, "cell 1 8 2 1");
|
||||
|
||||
//---- label4 ----
|
||||
label4.setIcon(UIManager.getIcon("FileView.computerIcon"));
|
||||
add(label4, "cell 1 2");
|
||||
add(label4, "cell 1 8 2 1");
|
||||
|
||||
//---- label5 ----
|
||||
label5.setIcon(UIManager.getIcon("FileView.hardDriveIcon"));
|
||||
add(label5, "cell 1 2");
|
||||
add(label5, "cell 1 8 2 1");
|
||||
|
||||
//---- label6 ----
|
||||
label6.setIcon(UIManager.getIcon("FileView.floppyDriveIcon"));
|
||||
add(label6, "cell 1 2");
|
||||
add(label6, "cell 1 8 2 1");
|
||||
|
||||
//---- label7 ----
|
||||
label7.setIcon(UIManager.getIcon("FileChooser.newFolderIcon"));
|
||||
add(label7, "cell 1 2");
|
||||
add(label7, "cell 1 8 2 1");
|
||||
|
||||
//---- label8 ----
|
||||
label8.setIcon(UIManager.getIcon("FileChooser.upFolderIcon"));
|
||||
add(label8, "cell 1 2");
|
||||
add(label8, "cell 1 8 2 1");
|
||||
|
||||
//---- label9 ----
|
||||
label9.setIcon(UIManager.getIcon("FileChooser.homeFolderIcon"));
|
||||
add(label9, "cell 1 2");
|
||||
add(label9, "cell 1 8 2 1");
|
||||
|
||||
//---- label10 ----
|
||||
label10.setIcon(UIManager.getIcon("FileChooser.detailsViewIcon"));
|
||||
add(label10, "cell 1 2");
|
||||
add(label10, "cell 1 8 2 1");
|
||||
|
||||
//---- label11 ----
|
||||
label11.setIcon(UIManager.getIcon("FileChooser.listViewIcon"));
|
||||
add(label11, "cell 1 2");
|
||||
add(label11, "cell 1 8 2 1");
|
||||
// JFormDesigner - End of component initialization //GEN-END:initComponents
|
||||
}
|
||||
|
||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
||||
private JFileChooser fileChooser1;
|
||||
private JTextField currentDirectoryField;
|
||||
private JTextField selectedFileField;
|
||||
private JTextField selectedFilesField;
|
||||
private FlatTestEnumSelector<DialogType> dialogTypeField;
|
||||
private JCheckBox showControlButtonsCheckBox;
|
||||
private JCheckBox showShortcutsCheckBox;
|
||||
private JCheckBox showAccessoryCheckBox;
|
||||
private FlatTestEnumSelector<FileSelectionMode> fileSelectionModeField;
|
||||
private JCheckBox multiSelectionCheckBox;
|
||||
private JCheckBox fileHidingCheckBox;
|
||||
private JCheckBox dragCheckBox;
|
||||
private JCheckBox filterAllFilesCheckBox;
|
||||
private JCheckBox filterTextFilesCheckBox;
|
||||
private JCheckBox filterImagesCheckBox;
|
||||
private JCheckBox filterLongDescCheckBox;
|
||||
private JButton printShortcutFilesButton;
|
||||
private JButton printComboBoxFilesButton;
|
||||
private JButton printRootsButton;
|
||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||
|
||||
//---- enum DialogType ----------------------------------------------------
|
||||
|
||||
enum DialogType {
|
||||
open( JFileChooser.OPEN_DIALOG ),
|
||||
save( JFileChooser.SAVE_DIALOG ),
|
||||
custom( JFileChooser.CUSTOM_DIALOG );
|
||||
|
||||
public final int value;
|
||||
|
||||
DialogType( int value ) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
//---- enum FileSelectionMode ---------------------------------------------
|
||||
|
||||
enum FileSelectionMode {
|
||||
files_only( JFileChooser.FILES_ONLY ),
|
||||
directories_only( JFileChooser.DIRECTORIES_ONLY ),
|
||||
files_and_directories( JFileChooser.FILES_AND_DIRECTORIES );
|
||||
|
||||
public final int value;
|
||||
|
||||
FileSelectionMode( int value ) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ new FormModel {
|
||||
}
|
||||
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$layoutConstraints": "ltr,insets dialog,hidemode 3"
|
||||
"$columnConstraints": "[][grow]"
|
||||
"$rowConstraints": "[grow,fill][][]"
|
||||
"$columnConstraints": "[][][grow]"
|
||||
"$rowConstraints": "[grow,fill][][][][][][][]para[]"
|
||||
} ) {
|
||||
name: "this"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
@@ -26,111 +26,296 @@ new FormModel {
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.beans.PropertyChangeListener", "propertyChange", "fileChooser1PropertyChange", true ) )
|
||||
}, new FormLayoutConstraints( class java.lang.String ) {
|
||||
"value": "Center"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 0,growx"
|
||||
"value": "cell 1 0 2 1,growx"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$layoutConstraints": "hidemode 3"
|
||||
"$columnConstraints": "[fill][fill]"
|
||||
"$rowConstraints": "[]"
|
||||
} ) {
|
||||
name: "panel3"
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "showShortcutsCheckBox"
|
||||
"text": "Show Shortcuts"
|
||||
"selected": true
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showShortcuts", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "showAccessoryCheckBox"
|
||||
"text": "Show Accessory"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showAccessory", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "currentDirectoryLabel"
|
||||
"text": "Current Directory:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 1"
|
||||
"value": "cell 0 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "currentDirectoryField"
|
||||
"editable": false
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 1 2 1,growx"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "selectedFileLabel"
|
||||
"text": "Selected File:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 2"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "selectedFileField"
|
||||
"editable": false
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 2 2 1,growx"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "selectedFilesLabel"
|
||||
"text": "Selected Files:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 3"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "selectedFilesField"
|
||||
"editable": false
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 3 2 1,growx"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "dialogTypeLabel"
|
||||
"text": "Dialog Type:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 4"
|
||||
} )
|
||||
add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumSelector" ) {
|
||||
name: "dialogTypeField"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
"JavaCodeGenerator.typeParameters": "DialogType"
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "dialogTypeChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 4"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "showControlButtonsCheckBox"
|
||||
"text": "Show Control Buttons"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showControlButtons", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 4"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "showShortcutsCheckBox"
|
||||
"text": "Show Shortcuts"
|
||||
"selected": true
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showShortcuts", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 4"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "showAccessoryCheckBox"
|
||||
"text": "Show Accessory"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showAccessory", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 4"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "fileSelectionModeLabel"
|
||||
"text": "File Selection Mode:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 5"
|
||||
} )
|
||||
add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumSelector" ) {
|
||||
name: "fileSelectionModeField"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
"JavaCodeGenerator.typeParameters": "FileSelectionMode"
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "fileSelectionModeChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 5"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "multiSelectionCheckBox"
|
||||
"text": "Multi Selection"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "multiSelection", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 5"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "fileHidingCheckBox"
|
||||
"text": "File Hiding"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "fileHiding", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 5"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "dragCheckBox"
|
||||
"text": "Drag"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "drag", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 5"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "filtersLabel"
|
||||
"text": "Filters:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 6"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "filterAllFilesCheckBox"
|
||||
"text": "All Files"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "filterChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 6 2 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "filterTextFilesCheckBox"
|
||||
"text": "Text Files"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "filterChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 6 2 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "filterImagesCheckBox"
|
||||
"text": "Images"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "filterChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 6 2 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "filterLongDescCheckBox"
|
||||
"text": "Long description"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "filterChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 6 2 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "printShortcutFilesButton"
|
||||
"text": "Print Shortcut Files"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "printShortcutFiles", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 7 2 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "printComboBoxFilesButton"
|
||||
"text": "Print ComboBox Files"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "printComboBoxFiles", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 7 2 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "printRootsButton"
|
||||
"text": "Print Roots"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "printRoots", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 7 2 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label1"
|
||||
"text": "icons:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 2"
|
||||
"value": "cell 0 8"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label2"
|
||||
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileView.directoryIcon" )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 2"
|
||||
"value": "cell 1 8 2 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label3"
|
||||
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileView.fileIcon" )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 2"
|
||||
"value": "cell 1 8 2 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label4"
|
||||
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileView.computerIcon" )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 2"
|
||||
"value": "cell 1 8 2 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label5"
|
||||
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileView.hardDriveIcon" )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 2"
|
||||
"value": "cell 1 8 2 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label6"
|
||||
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileView.floppyDriveIcon" )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 2"
|
||||
"value": "cell 1 8 2 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label7"
|
||||
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileChooser.newFolderIcon" )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 2"
|
||||
"value": "cell 1 8 2 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label8"
|
||||
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileChooser.upFolderIcon" )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 2"
|
||||
"value": "cell 1 8 2 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label9"
|
||||
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileChooser.homeFolderIcon" )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 2"
|
||||
"value": "cell 1 8 2 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label10"
|
||||
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileChooser.detailsViewIcon" )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 2"
|
||||
"value": "cell 1 8 2 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label11"
|
||||
"icon": new com.jformdesigner.model.SwingIcon( 2, "FileChooser.listViewIcon" )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 2"
|
||||
"value": "cell 1 8 2 1"
|
||||
} )
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 0, 0 )
|
||||
"size": new java.awt.Dimension( 790, 790 )
|
||||
"size": new java.awt.Dimension( 715, 660 )
|
||||
} )
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user