提交 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
"FileChooser.enterFileNameLabelMnemonic", new Integer (KeyEvent.VK_N), // 'n'
"FileChooser.ancestorInputMap",
new UIDefaults.LazyInputMap(new Object[] {
"ESCAPE", "cancelSelection",
"ENTER", "approveSelection",
"ctrl ENTER", "approveSelection"
"ESCAPE", "cancelSelection"
}),
......
......@@ -825,9 +825,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
"ESCAPE", "cancelSelection",
"F2", "editFileName",
"F5", "refresh",
"BACK_SPACE", "Go Up",
"ENTER", "approveSelection",
"ctrl ENTER", "approveSelection"
"BACK_SPACE", "Go Up"
}),
"FileView.directoryIcon", SwingUtilities2.makeIcon(getClass(),
......
......@@ -770,7 +770,8 @@ public class JFileChooser extends JComponent implements Accessible {
* @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 @@ public class JFileChooser extends JComponent implements Accessible {
dialog.getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG);
}
}
dialog.getRootPane().setDefaultButton(ui.getDefaultButton(this));
dialog.pack();
dialog.setLocationRelativeTo(parent);
......
......@@ -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 class FileChooserUI extends ComponentUI
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;
}
}
......@@ -384,6 +384,10 @@ public class BasicFileChooserUI extends FileChooserUI {
return null;
}
public JButton getDefaultButton(JFileChooser fc) {
return getApproveButton(fc);
}
public String getApproveButtonToolTipText(JFileChooser fc) {
String tooltipText = fc.getApproveButtonToolTipText();
if(tooltipText != null) {
......
......@@ -853,9 +853,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"ESCAPE", "cancelSelection",
"F2", "editFileName",
"F5", "refresh",
"BACK_SPACE", "Go Up",
"ENTER", "approveSelection",
"ctrl ENTER", "approveSelection"
"BACK_SPACE", "Go Up"
}),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册