changeset 383:5083f5c15103

5035693: "Open" button should be a default one in JFileChooser under Windows XP LAF Summary: The "Open" button was made default button of FileChooser dialog windows Reviewed-by: loneid, peterz
author rupashka
date Fri, 06 Jun 2008 13:30:20 +0400
parents e26917dd7b7c
children ec9c8e73ae53
files src/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java src/share/classes/javax/swing/JFileChooser.java src/share/classes/javax/swing/plaf/FileChooserUI.java src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java
diffstat 6 files changed, 22 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java	Thu Jun 05 13:30:41 2008 +0400
+++ b/src/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java	Fri Jun 06 13:30:20 2008 +0400
@@ -1222,9 +1222,7 @@
             "FileChooser.enterFileNameLabelMnemonic", new Integer (KeyEvent.VK_N), // 'n'
             "FileChooser.ancestorInputMap",
                new UIDefaults.LazyInputMap(new Object[] {
-                     "ESCAPE", "cancelSelection",
-                     "ENTER", "approveSelection",
-                "ctrl ENTER", "approveSelection"
+                     "ESCAPE", "cancelSelection"
                  }),
 
 
--- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Thu Jun 05 13:30:41 2008 +0400
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Fri Jun 06 13:30:20 2008 +0400
@@ -825,9 +825,7 @@
                      "ESCAPE", "cancelSelection",
                      "F2", "editFileName",
                      "F5", "refresh",
-                     "BACK_SPACE", "Go Up",
-                     "ENTER", "approveSelection",
-                "ctrl ENTER", "approveSelection"
+                     "BACK_SPACE", "Go Up"
                  }),
 
             "FileView.directoryIcon", SwingUtilities2.makeIcon(getClass(),
--- a/src/share/classes/javax/swing/JFileChooser.java	Thu Jun 05 13:30:41 2008 +0400
+++ b/src/share/classes/javax/swing/JFileChooser.java	Fri Jun 06 13:30:20 2008 +0400
@@ -770,7 +770,8 @@
      * @since 1.4
      */
     protected JDialog createDialog(Component parent) throws HeadlessException {
-        String title = getUI().getDialogTitle(this);
+        FileChooserUI ui = getUI();
+        String title = ui.getDialogTitle(this);
         putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY,
                           title);
 
@@ -794,6 +795,7 @@
                 dialog.getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG);
             }
         }
+        dialog.getRootPane().setDefaultButton(ui.getDefaultButton(this));
         dialog.pack();
         dialog.setLocationRelativeTo(parent);
 
--- a/src/share/classes/javax/swing/plaf/FileChooserUI.java	Thu Jun 05 13:30:41 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/FileChooserUI.java	Fri Jun 06 13:30:20 2008 +0400
@@ -25,7 +25,7 @@
 
 package javax.swing.plaf;
 
-import javax.swing.JFileChooser;
+import javax.swing.*;
 import javax.swing.filechooser.FileFilter;
 import javax.swing.filechooser.FileView;
 import java.io.File;
@@ -46,4 +46,15 @@
 
     public abstract void rescanCurrentDirectory(JFileChooser fc);
     public abstract void ensureFileIsVisible(JFileChooser fc, File f);
+
+    /**
+     * Returns default button for current <code>LookAndFeel</code>.
+     * <code>JFileChooser</code> will use this button as default button
+     * for dialog windows.
+     *
+     * @since 1.7
+     */
+    public JButton getDefaultButton(JFileChooser fc) {
+        return null;
+    }
 }
--- a/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java	Thu Jun 05 13:30:41 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java	Fri Jun 06 13:30:20 2008 +0400
@@ -384,6 +384,10 @@
         return null;
     }
 
+    public JButton getDefaultButton(JFileChooser fc) {
+        return getApproveButton(fc);
+    }
+
     public String getApproveButtonToolTipText(JFileChooser fc) {
         String tooltipText = fc.getApproveButtonToolTipText();
         if(tooltipText != null) {
--- a/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java	Thu Jun 05 13:30:41 2008 +0400
+++ b/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java	Fri Jun 06 13:30:20 2008 +0400
@@ -853,9 +853,7 @@
                      "ESCAPE", "cancelSelection",
                      "F2", "editFileName",
                      "F5", "refresh",
-                     "BACK_SPACE", "Go Up",
-                     "ENTER", "approveSelection",
-                "ctrl ENTER", "approveSelection"
+                     "BACK_SPACE", "Go Up"
                  }),