提交 6f006cab 编写于 作者: R rupashka

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
上级 eeb7e0fd
...@@ -1222,9 +1222,7 @@ public class MotifLookAndFeel extends BasicLookAndFeel ...@@ -1222,9 +1222,7 @@ public class MotifLookAndFeel extends BasicLookAndFeel
"FileChooser.enterFileNameLabelMnemonic", new Integer (KeyEvent.VK_N), // 'n' "FileChooser.enterFileNameLabelMnemonic", new Integer (KeyEvent.VK_N), // 'n'
"FileChooser.ancestorInputMap", "FileChooser.ancestorInputMap",
new UIDefaults.LazyInputMap(new Object[] { new UIDefaults.LazyInputMap(new Object[] {
"ESCAPE", "cancelSelection", "ESCAPE", "cancelSelection"
"ENTER", "approveSelection",
"ctrl ENTER", "approveSelection"
}), }),
......
...@@ -825,9 +825,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel ...@@ -825,9 +825,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
"ESCAPE", "cancelSelection", "ESCAPE", "cancelSelection",
"F2", "editFileName", "F2", "editFileName",
"F5", "refresh", "F5", "refresh",
"BACK_SPACE", "Go Up", "BACK_SPACE", "Go Up"
"ENTER", "approveSelection",
"ctrl ENTER", "approveSelection"
}), }),
"FileView.directoryIcon", SwingUtilities2.makeIcon(getClass(), "FileView.directoryIcon", SwingUtilities2.makeIcon(getClass(),
......
...@@ -770,7 +770,8 @@ public class JFileChooser extends JComponent implements Accessible { ...@@ -770,7 +770,8 @@ public class JFileChooser extends JComponent implements Accessible {
* @since 1.4 * @since 1.4
*/ */
protected JDialog createDialog(Component parent) throws HeadlessException { 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, putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY,
title); title);
...@@ -794,6 +795,7 @@ public class JFileChooser extends JComponent implements Accessible { ...@@ -794,6 +795,7 @@ public class JFileChooser extends JComponent implements Accessible {
dialog.getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG); dialog.getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG);
} }
} }
dialog.getRootPane().setDefaultButton(ui.getDefaultButton(this));
dialog.pack(); dialog.pack();
dialog.setLocationRelativeTo(parent); dialog.setLocationRelativeTo(parent);
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
package javax.swing.plaf; package javax.swing.plaf;
import javax.swing.JFileChooser; import javax.swing.*;
import javax.swing.filechooser.FileFilter; import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileView; import javax.swing.filechooser.FileView;
import java.io.File; import java.io.File;
...@@ -46,4 +46,15 @@ public abstract class FileChooserUI extends ComponentUI ...@@ -46,4 +46,15 @@ public abstract class FileChooserUI extends ComponentUI
public abstract void rescanCurrentDirectory(JFileChooser fc); public abstract void rescanCurrentDirectory(JFileChooser fc);
public abstract void ensureFileIsVisible(JFileChooser fc, File f); 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;
}
} }
...@@ -384,6 +384,10 @@ public class BasicFileChooserUI extends FileChooserUI { ...@@ -384,6 +384,10 @@ public class BasicFileChooserUI extends FileChooserUI {
return null; return null;
} }
public JButton getDefaultButton(JFileChooser fc) {
return getApproveButton(fc);
}
public String getApproveButtonToolTipText(JFileChooser fc) { public String getApproveButtonToolTipText(JFileChooser fc) {
String tooltipText = fc.getApproveButtonToolTipText(); String tooltipText = fc.getApproveButtonToolTipText();
if(tooltipText != null) { if(tooltipText != null) {
......
...@@ -853,9 +853,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel ...@@ -853,9 +853,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"ESCAPE", "cancelSelection", "ESCAPE", "cancelSelection",
"F2", "editFileName", "F2", "editFileName",
"F5", "refresh", "F5", "refresh",
"BACK_SPACE", "Go Up", "BACK_SPACE", "Go Up"
"ENTER", "approveSelection",
"ctrl ENTER", "approveSelection"
}), }),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册