[jsword-svn] r1288 - trunk/common-swing/src/main/java/org/crosswire/common/config/swing
dmsmith at www.crosswire.org
dmsmith at www.crosswire.org
Fri Apr 20 12:35:46 MST 2007
Author: dmsmith
Date: 2007-04-20 12:35:46 -0700 (Fri, 20 Apr 2007)
New Revision: 1288
Modified:
trunk/common-swing/src/main/java/org/crosswire/common/config/swing/DirectoryField.java
Log:
First try at a crossplatform osx compatible file chooser.
Modified: trunk/common-swing/src/main/java/org/crosswire/common/config/swing/DirectoryField.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/config/swing/DirectoryField.java 2007-04-20 18:50:16 UTC (rev 1287)
+++ trunk/common-swing/src/main/java/org/crosswire/common/config/swing/DirectoryField.java 2007-04-20 19:35:46 UTC (rev 1288)
@@ -21,8 +21,13 @@
*/
package org.crosswire.common.config.swing;
+import java.awt.FileDialog;
+
import javax.swing.JFileChooser;
+import org.crosswire.common.swing.GuiUtil;
+import org.crosswire.common.util.OSType;
+
/**
* A Directory selection.
*
@@ -38,12 +43,28 @@
/* @Override */
public void doBrowse()
{
- JFileChooser chooser = new JFileChooser(text.getText());
- chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
- if (chooser.showOpenDialog(DirectoryField.this) == JFileChooser.APPROVE_OPTION)
+ if (OSType.MAC.equals(OSType.getOSType()))
{
- text.setText(chooser.getSelectedFile().getPath());
+ FileDialog chooser = new FileDialog(GuiUtil.getFrame(getParent()), text.getText());
+ String prop = "apple.awt.fileDialogForDirectories"; //$NON-NLS-1$
+ System.setProperty(prop, "true"); //$NON-NLS-1$
+ chooser.show();
+ System.setProperty(prop, "false"); //$NON-NLS-1$
+ String dir = chooser.getFile();
+ if (dir != null)
+ {
+ text.setText(dir);
+ }
}
+ else
+ {
+ JFileChooser chooser = new JFileChooser(text.getText());
+ chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ if (chooser.showOpenDialog(DirectoryField.this) == JFileChooser.APPROVE_OPTION)
+ {
+ text.setText(chooser.getSelectedFile().getPath());
+ }
+ }
}
/**
More information about the jsword-svn
mailing list