提交 b4cb2a97 编写于 作者: A alexsch

8020708: NLS mnemonics missing in SwingSet2/JInternalFrame demo

Reviewed-by: malenkov, leonidr
上级 baf3b072
...@@ -86,19 +86,19 @@ public class MotifInternalFrameTitlePane ...@@ -86,19 +86,19 @@ public class MotifInternalFrameTitlePane
protected void assembleSystemMenu() { protected void assembleSystemMenu() {
systemMenu = new JPopupMenu(); systemMenu = new JPopupMenu();
JMenuItem mi = systemMenu.add(new JMenuItem(restoreAction)); JMenuItem mi = systemMenu.add(restoreAction);
mi.setMnemonic('R'); mi.setMnemonic(getButtonMnemonic("restore"));
mi = systemMenu.add(new JMenuItem(moveAction)); mi = systemMenu.add(moveAction);
mi.setMnemonic('M'); mi.setMnemonic(getButtonMnemonic("move"));
mi = systemMenu.add(new JMenuItem(sizeAction)); mi = systemMenu.add(sizeAction);
mi.setMnemonic('S'); mi.setMnemonic(getButtonMnemonic("size"));
mi = systemMenu.add(new JMenuItem(iconifyAction)); mi = systemMenu.add(iconifyAction);
mi.setMnemonic('n'); mi.setMnemonic(getButtonMnemonic("minimize"));
mi = systemMenu.add(new JMenuItem(maximizeAction)); mi = systemMenu.add(maximizeAction);
mi.setMnemonic('x'); mi.setMnemonic(getButtonMnemonic("maximize"));
systemMenu.add(new JSeparator()); systemMenu.add(new JSeparator());
mi = systemMenu.add(new JMenuItem(closeAction)); mi = systemMenu.add(closeAction);
mi.setMnemonic('C'); mi.setMnemonic(getButtonMnemonic("close"));
systemButton = new SystemButton(); systemButton = new SystemButton();
systemButton.addActionListener(new ActionListener() { systemButton.addActionListener(new ActionListener() {
...@@ -124,6 +124,14 @@ public class MotifInternalFrameTitlePane ...@@ -124,6 +124,14 @@ public class MotifInternalFrameTitlePane
}); });
} }
private static int getButtonMnemonic(String button) {
try {
return Integer.parseInt(UIManager.getString(
"InternalFrameTitlePane." + button + "Button.mnemonic"));
} catch (NumberFormatException e) {
return -1;
}
}
protected void createButtons() { protected void createButtons() {
minimizeButton = new MinimizeButton(); minimizeButton = new MinimizeButton();
......
...@@ -326,18 +326,27 @@ public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane { ...@@ -326,18 +326,27 @@ public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane {
protected void addSystemMenuItems(JPopupMenu menu) { protected void addSystemMenuItems(JPopupMenu menu) {
JMenuItem mi = menu.add(restoreAction); JMenuItem mi = menu.add(restoreAction);
mi.setMnemonic('R'); mi.setMnemonic(getButtonMnemonic("restore"));
mi = menu.add(moveAction); mi = menu.add(moveAction);
mi.setMnemonic('M'); mi.setMnemonic(getButtonMnemonic("move"));
mi = menu.add(sizeAction); mi = menu.add(sizeAction);
mi.setMnemonic('S'); mi.setMnemonic(getButtonMnemonic("size"));
mi = menu.add(iconifyAction); mi = menu.add(iconifyAction);
mi.setMnemonic('n'); mi.setMnemonic(getButtonMnemonic("minimize"));
mi = menu.add(maximizeAction); mi = menu.add(maximizeAction);
mi.setMnemonic('x'); mi.setMnemonic(getButtonMnemonic("maximize"));
systemPopupMenu.add(new JSeparator()); menu.add(new JSeparator());
mi = menu.add(closeAction); mi = menu.add(closeAction);
mi.setMnemonic('C'); mi.setMnemonic(getButtonMnemonic("close"));
}
private static int getButtonMnemonic(String button) {
try {
return Integer.parseInt(UIManager.getString(
"InternalFrameTitlePane." + button + "Button.mnemonic"));
} catch (NumberFormatException e) {
return -1;
}
} }
protected void showSystemMenu(){ protected void showSystemMenu(){
......
...@@ -144,12 +144,12 @@ InternalFrame.restoreButtonToolTip=Restore ...@@ -144,12 +144,12 @@ InternalFrame.restoreButtonToolTip=Restore
InternalFrame.closeButtonToolTip=Close InternalFrame.closeButtonToolTip=Close
############ Internal Frame Title Pane Strings ############ ############ Internal Frame Title Pane Strings ############
InternalFrameTitlePane.restoreButton.textAndMnemonic=Restore InternalFrameTitlePane.restoreButton.textAndMnemonic=&Restore
InternalFrameTitlePane.moveButton.textAndMnemonic=Move InternalFrameTitlePane.moveButton.textAndMnemonic=&Move
InternalFrameTitlePane.sizeButton.textAndMnemonic=Size InternalFrameTitlePane.sizeButton.textAndMnemonic=&Size
InternalFrameTitlePane.minimizeButton.textAndMnemonic=Minimize InternalFrameTitlePane.minimizeButton.textAndMnemonic=Mi&nimize
InternalFrameTitlePane.maximizeButton.textAndMnemonic=Maximize InternalFrameTitlePane.maximizeButton.textAndMnemonic=Ma&ximize
InternalFrameTitlePane.closeButton.textAndMnemonic=Close InternalFrameTitlePane.closeButton.textAndMnemonic=&Close
############ Text strings ############# ############ Text strings #############
# Used for html forms # Used for html forms
......
...@@ -143,12 +143,12 @@ InternalFrame.restoreButtonToolTip=Wiederherstellen ...@@ -143,12 +143,12 @@ InternalFrame.restoreButtonToolTip=Wiederherstellen
InternalFrame.closeButtonToolTip=Schlie\u00DFen InternalFrame.closeButtonToolTip=Schlie\u00DFen
############ Internal Frame Title Pane Strings ############ ############ Internal Frame Title Pane Strings ############
InternalFrameTitlePane.restoreButton.textAndMnemonic=Wiederherstellen InternalFrameTitlePane.restoreButton.textAndMnemonic=Wiede&rherstellen
InternalFrameTitlePane.moveButton.textAndMnemonic=Verschieben InternalFrameTitlePane.moveButton.textAndMnemonic=Verschieben(&M)
InternalFrameTitlePane.sizeButton.textAndMnemonic=Gr\u00F6\u00DFe InternalFrameTitlePane.sizeButton.textAndMnemonic=Gr\u00F6\u00DFe(&S)
InternalFrameTitlePane.minimizeButton.textAndMnemonic=Minimieren InternalFrameTitlePane.minimizeButton.textAndMnemonic=Mi&nimieren
InternalFrameTitlePane.maximizeButton.textAndMnemonic=Maximieren InternalFrameTitlePane.maximizeButton.textAndMnemonic=Ma&ximieren
InternalFrameTitlePane.closeButton.textAndMnemonic=Schlie\u00DFen InternalFrameTitlePane.closeButton.textAndMnemonic=S&chlie\u00DFen
############ Text strings ############# ############ Text strings #############
# Used for html forms # Used for html forms
......
...@@ -143,12 +143,12 @@ InternalFrame.restoreButtonToolTip=Restaurar ...@@ -143,12 +143,12 @@ InternalFrame.restoreButtonToolTip=Restaurar
InternalFrame.closeButtonToolTip=Cerrar InternalFrame.closeButtonToolTip=Cerrar
############ Internal Frame Title Pane Strings ############ ############ Internal Frame Title Pane Strings ############
InternalFrameTitlePane.restoreButton.textAndMnemonic=Restaurar InternalFrameTitlePane.restoreButton.textAndMnemonic=&Restaurar
InternalFrameTitlePane.moveButton.textAndMnemonic=Mover InternalFrameTitlePane.moveButton.textAndMnemonic=&Mover
InternalFrameTitlePane.sizeButton.textAndMnemonic=Tama\u00F1o InternalFrameTitlePane.sizeButton.textAndMnemonic=Tama\u00F1o(&S)
InternalFrameTitlePane.minimizeButton.textAndMnemonic=Minimizar InternalFrameTitlePane.minimizeButton.textAndMnemonic=Mi&nimizar
InternalFrameTitlePane.maximizeButton.textAndMnemonic=Maximizar InternalFrameTitlePane.maximizeButton.textAndMnemonic=Ma&ximizar
InternalFrameTitlePane.closeButton.textAndMnemonic=Cerrar InternalFrameTitlePane.closeButton.textAndMnemonic=&Cerrar
############ Text strings ############# ############ Text strings #############
# Used for html forms # Used for html forms
......
...@@ -143,12 +143,12 @@ InternalFrame.restoreButtonToolTip=Restaurer ...@@ -143,12 +143,12 @@ InternalFrame.restoreButtonToolTip=Restaurer
InternalFrame.closeButtonToolTip=Fermer InternalFrame.closeButtonToolTip=Fermer
############ Internal Frame Title Pane Strings ############ ############ Internal Frame Title Pane Strings ############
InternalFrameTitlePane.restoreButton.textAndMnemonic=Restaurer InternalFrameTitlePane.restoreButton.textAndMnemonic=&Restaurer
InternalFrameTitlePane.moveButton.textAndMnemonic=D\u00E9placer InternalFrameTitlePane.moveButton.textAndMnemonic=D\u00E9placer(&M)
InternalFrameTitlePane.sizeButton.textAndMnemonic=Taille InternalFrameTitlePane.sizeButton.textAndMnemonic=Taille(&S)
InternalFrameTitlePane.minimizeButton.textAndMnemonic=R\u00E9duire InternalFrameTitlePane.minimizeButton.textAndMnemonic=R\u00E9duire(&N)
InternalFrameTitlePane.maximizeButton.textAndMnemonic=Agrandir InternalFrameTitlePane.maximizeButton.textAndMnemonic=Agrandir(&X)
InternalFrameTitlePane.closeButton.textAndMnemonic=Fermer InternalFrameTitlePane.closeButton.textAndMnemonic=Fermer(&C)
############ Text strings ############# ############ Text strings #############
# Used for html forms # Used for html forms
......
...@@ -143,12 +143,12 @@ InternalFrame.restoreButtonToolTip=Ripristina ...@@ -143,12 +143,12 @@ InternalFrame.restoreButtonToolTip=Ripristina
InternalFrame.closeButtonToolTip=Chiudi InternalFrame.closeButtonToolTip=Chiudi
############ Internal Frame Title Pane Strings ############ ############ Internal Frame Title Pane Strings ############
InternalFrameTitlePane.restoreButton.textAndMnemonic=Ripristina InternalFrameTitlePane.restoreButton.textAndMnemonic=&Ripristina
InternalFrameTitlePane.moveButton.textAndMnemonic=Sposta InternalFrameTitlePane.moveButton.textAndMnemonic=Sposta(&M)
InternalFrameTitlePane.sizeButton.textAndMnemonic=Dimensioni InternalFrameTitlePane.sizeButton.textAndMnemonic=Dimen&sioni
InternalFrameTitlePane.minimizeButton.textAndMnemonic=Riduci a icona InternalFrameTitlePane.minimizeButton.textAndMnemonic=Riduci a ico&na
InternalFrameTitlePane.maximizeButton.textAndMnemonic=Ingrandisci InternalFrameTitlePane.maximizeButton.textAndMnemonic=Ingrandisci(&X)
InternalFrameTitlePane.closeButton.textAndMnemonic=Chiudi InternalFrameTitlePane.closeButton.textAndMnemonic=&Chiudi
############ Text strings ############# ############ Text strings #############
# Used for html forms # Used for html forms
......
...@@ -143,12 +143,12 @@ InternalFrame.restoreButtonToolTip=\u5FA9\u5143 ...@@ -143,12 +143,12 @@ InternalFrame.restoreButtonToolTip=\u5FA9\u5143
InternalFrame.closeButtonToolTip=\u9589\u3058\u308B InternalFrame.closeButtonToolTip=\u9589\u3058\u308B
############ Internal Frame Title Pane Strings ############ ############ Internal Frame Title Pane Strings ############
InternalFrameTitlePane.restoreButton.textAndMnemonic=\u5FA9\u5143 InternalFrameTitlePane.restoreButton.textAndMnemonic=\u5FA9\u5143(&R)
InternalFrameTitlePane.moveButton.textAndMnemonic=\u79FB\u52D5 InternalFrameTitlePane.moveButton.textAndMnemonic=\u79FB\u52D5(&M)
InternalFrameTitlePane.sizeButton.textAndMnemonic=\u30B5\u30A4\u30BA InternalFrameTitlePane.sizeButton.textAndMnemonic=\u30B5\u30A4\u30BA(&S)
InternalFrameTitlePane.minimizeButton.textAndMnemonic=\u6700\u5C0F\u5316 InternalFrameTitlePane.minimizeButton.textAndMnemonic=\u6700\u5C0F\u5316(&N)
InternalFrameTitlePane.maximizeButton.textAndMnemonic=\u6700\u5927\u5316 InternalFrameTitlePane.maximizeButton.textAndMnemonic=\u6700\u5927\u5316(&X)
InternalFrameTitlePane.closeButton.textAndMnemonic=\u9589\u3058\u308B InternalFrameTitlePane.closeButton.textAndMnemonic=\u9589\u3058\u308B(&C)
############ Text strings ############# ############ Text strings #############
# Used for html forms # Used for html forms
......
...@@ -143,12 +143,12 @@ InternalFrame.restoreButtonToolTip=\uBCF5\uC6D0 ...@@ -143,12 +143,12 @@ InternalFrame.restoreButtonToolTip=\uBCF5\uC6D0
InternalFrame.closeButtonToolTip=\uB2EB\uAE30 InternalFrame.closeButtonToolTip=\uB2EB\uAE30
############ Internal Frame Title Pane Strings ############ ############ Internal Frame Title Pane Strings ############
InternalFrameTitlePane.restoreButton.textAndMnemonic=\uBCF5\uC6D0 InternalFrameTitlePane.restoreButton.textAndMnemonic=\uBCF5\uC6D0(&R)
InternalFrameTitlePane.moveButton.textAndMnemonic=\uC774\uB3D9 InternalFrameTitlePane.moveButton.textAndMnemonic=\uC774\uB3D9(&M)
InternalFrameTitlePane.sizeButton.textAndMnemonic=\uD06C\uAE30 InternalFrameTitlePane.sizeButton.textAndMnemonic=\uD06C\uAE30(&S)
InternalFrameTitlePane.minimizeButton.textAndMnemonic=\uCD5C\uC18C\uD654 InternalFrameTitlePane.minimizeButton.textAndMnemonic=\uCD5C\uC18C\uD654(&N)
InternalFrameTitlePane.maximizeButton.textAndMnemonic=\uCD5C\uB300\uD654 InternalFrameTitlePane.maximizeButton.textAndMnemonic=\uCD5C\uB300\uD654(&X)
InternalFrameTitlePane.closeButton.textAndMnemonic=\uB2EB\uAE30 InternalFrameTitlePane.closeButton.textAndMnemonic=\uB2EB\uAE30(&C)
############ Text strings ############# ############ Text strings #############
# Used for html forms # Used for html forms
......
...@@ -143,12 +143,12 @@ InternalFrame.restoreButtonToolTip=Restaurar ...@@ -143,12 +143,12 @@ InternalFrame.restoreButtonToolTip=Restaurar
InternalFrame.closeButtonToolTip=Fechar InternalFrame.closeButtonToolTip=Fechar
############ Internal Frame Title Pane Strings ############ ############ Internal Frame Title Pane Strings ############
InternalFrameTitlePane.restoreButton.textAndMnemonic=Restaurar InternalFrameTitlePane.restoreButton.textAndMnemonic=&Restaurar
InternalFrameTitlePane.moveButton.textAndMnemonic=Mover InternalFrameTitlePane.moveButton.textAndMnemonic=&Mover
InternalFrameTitlePane.sizeButton.textAndMnemonic=Tamanho InternalFrameTitlePane.sizeButton.textAndMnemonic=Tamanho(&S)
InternalFrameTitlePane.minimizeButton.textAndMnemonic=Minimizar InternalFrameTitlePane.minimizeButton.textAndMnemonic=Mi&nimizar
InternalFrameTitlePane.maximizeButton.textAndMnemonic=Maximizar InternalFrameTitlePane.maximizeButton.textAndMnemonic=Ma&ximizar
InternalFrameTitlePane.closeButton.textAndMnemonic=Fechar InternalFrameTitlePane.closeButton.textAndMnemonic=Fe&char
############ Text strings ############# ############ Text strings #############
# Used for html forms # Used for html forms
......
...@@ -143,12 +143,12 @@ InternalFrame.restoreButtonToolTip=\u00C5terst\u00E4ll ...@@ -143,12 +143,12 @@ InternalFrame.restoreButtonToolTip=\u00C5terst\u00E4ll
InternalFrame.closeButtonToolTip=St\u00E4ng InternalFrame.closeButtonToolTip=St\u00E4ng
############ Internal Frame Title Pane Strings ############ ############ Internal Frame Title Pane Strings ############
InternalFrameTitlePane.restoreButton.textAndMnemonic=\u00C5terst\u00E4ll InternalFrameTitlePane.restoreButton.textAndMnemonic=\u00C5terst\u00E4ll(&R)
InternalFrameTitlePane.moveButton.textAndMnemonic=Flytta InternalFrameTitlePane.moveButton.textAndMnemonic=Flytta(&M)
InternalFrameTitlePane.sizeButton.textAndMnemonic=Storlek InternalFrameTitlePane.sizeButton.textAndMnemonic=&Storlek
InternalFrameTitlePane.minimizeButton.textAndMnemonic=Minimera InternalFrameTitlePane.minimizeButton.textAndMnemonic=Mi&nimera
InternalFrameTitlePane.maximizeButton.textAndMnemonic=Maximera InternalFrameTitlePane.maximizeButton.textAndMnemonic=Ma&ximera
InternalFrameTitlePane.closeButton.textAndMnemonic=St\u00E4ng InternalFrameTitlePane.closeButton.textAndMnemonic=St\u00E4ng(&C)
############ Text strings ############# ############ Text strings #############
# Used for html forms # Used for html forms
......
...@@ -143,12 +143,12 @@ InternalFrame.restoreButtonToolTip=\u8FD8\u539F ...@@ -143,12 +143,12 @@ InternalFrame.restoreButtonToolTip=\u8FD8\u539F
InternalFrame.closeButtonToolTip=\u5173\u95ED InternalFrame.closeButtonToolTip=\u5173\u95ED
############ Internal Frame Title Pane Strings ############ ############ Internal Frame Title Pane Strings ############
InternalFrameTitlePane.restoreButton.textAndMnemonic=\u8FD8\u539F InternalFrameTitlePane.restoreButton.textAndMnemonic=\u8FD8\u539F(&R)
InternalFrameTitlePane.moveButton.textAndMnemonic=\u79FB\u52A8 InternalFrameTitlePane.moveButton.textAndMnemonic=\u79FB\u52A8(&M)
InternalFrameTitlePane.sizeButton.textAndMnemonic=\u5927\u5C0F InternalFrameTitlePane.sizeButton.textAndMnemonic=\u5927\u5C0F(&S)
InternalFrameTitlePane.minimizeButton.textAndMnemonic=\u6700\u5C0F\u5316 InternalFrameTitlePane.minimizeButton.textAndMnemonic=\u6700\u5C0F\u5316(&N)
InternalFrameTitlePane.maximizeButton.textAndMnemonic=\u6700\u5927\u5316 InternalFrameTitlePane.maximizeButton.textAndMnemonic=\u6700\u5927\u5316(&X)
InternalFrameTitlePane.closeButton.textAndMnemonic=\u5173\u95ED InternalFrameTitlePane.closeButton.textAndMnemonic=\u5173\u95ED(&C)
############ Text strings ############# ############ Text strings #############
# Used for html forms # Used for html forms
......
...@@ -143,12 +143,12 @@ InternalFrame.restoreButtonToolTip=\u5FA9\u539F ...@@ -143,12 +143,12 @@ InternalFrame.restoreButtonToolTip=\u5FA9\u539F
InternalFrame.closeButtonToolTip=\u95DC\u9589 InternalFrame.closeButtonToolTip=\u95DC\u9589
############ Internal Frame Title Pane Strings ############ ############ Internal Frame Title Pane Strings ############
InternalFrameTitlePane.restoreButton.textAndMnemonic=\u5FA9\u539F InternalFrameTitlePane.restoreButton.textAndMnemonic=\u5FA9\u539F(&R)
InternalFrameTitlePane.moveButton.textAndMnemonic=\u79FB\u52D5 InternalFrameTitlePane.moveButton.textAndMnemonic=\u79FB\u52D5(&M)
InternalFrameTitlePane.sizeButton.textAndMnemonic=\u5927\u5C0F InternalFrameTitlePane.sizeButton.textAndMnemonic=\u5927\u5C0F(&S)
InternalFrameTitlePane.minimizeButton.textAndMnemonic=\u6700\u5C0F\u5316 InternalFrameTitlePane.minimizeButton.textAndMnemonic=\u6700\u5C0F\u5316(&N)
InternalFrameTitlePane.maximizeButton.textAndMnemonic=\u6700\u5927\u5316 InternalFrameTitlePane.maximizeButton.textAndMnemonic=\u6700\u5927\u5316(&X)
InternalFrameTitlePane.closeButton.textAndMnemonic=\u95DC\u9589 InternalFrameTitlePane.closeButton.textAndMnemonic=\u95DC\u9589(&C)
############ Text strings ############# ############ Text strings #############
# Used for html forms # Used for html forms
......
...@@ -270,18 +270,27 @@ public class BasicInternalFrameTitlePane extends JComponent ...@@ -270,18 +270,27 @@ public class BasicInternalFrameTitlePane extends JComponent
protected void addSystemMenuItems(JMenu systemMenu) { protected void addSystemMenuItems(JMenu systemMenu) {
JMenuItem mi = systemMenu.add(restoreAction); JMenuItem mi = systemMenu.add(restoreAction);
mi.setMnemonic('R'); mi.setMnemonic(getButtonMnemonic("restore"));
mi = systemMenu.add(moveAction); mi = systemMenu.add(moveAction);
mi.setMnemonic('M'); mi.setMnemonic(getButtonMnemonic("move"));
mi = systemMenu.add(sizeAction); mi = systemMenu.add(sizeAction);
mi.setMnemonic('S'); mi.setMnemonic(getButtonMnemonic("size"));
mi = systemMenu.add(iconifyAction); mi = systemMenu.add(iconifyAction);
mi.setMnemonic('n'); mi.setMnemonic(getButtonMnemonic("minimize"));
mi = systemMenu.add(maximizeAction); mi = systemMenu.add(maximizeAction);
mi.setMnemonic('x'); mi.setMnemonic(getButtonMnemonic("maximize"));
systemMenu.add(new JSeparator()); systemMenu.add(new JSeparator());
mi = systemMenu.add(closeAction); mi = systemMenu.add(closeAction);
mi.setMnemonic('C'); mi.setMnemonic(getButtonMnemonic("close"));
}
private static int getButtonMnemonic(String button) {
try {
return Integer.parseInt(UIManager.getString(
"InternalFrameTitlePane." + button + "Button.mnemonic"));
} catch (NumberFormatException e) {
return -1;
}
} }
protected JMenu createSystemMenu() { protected JMenu createSystemMenu() {
......
...@@ -191,20 +191,28 @@ class SynthInternalFrameTitlePane extends BasicInternalFrameTitlePane ...@@ -191,20 +191,28 @@ class SynthInternalFrameTitlePane extends BasicInternalFrameTitlePane
} }
protected void addSystemMenuItems(JPopupMenu menu) { protected void addSystemMenuItems(JPopupMenu menu) {
// PENDING: this should all be localizable!
JMenuItem mi = menu.add(restoreAction); JMenuItem mi = menu.add(restoreAction);
mi.setMnemonic('R'); mi.setMnemonic(getButtonMnemonic("restore"));
mi = menu.add(moveAction); mi = menu.add(moveAction);
mi.setMnemonic('M'); mi.setMnemonic(getButtonMnemonic("move"));
mi = menu.add(sizeAction); mi = menu.add(sizeAction);
mi.setMnemonic('S'); mi.setMnemonic(getButtonMnemonic("size"));
mi = menu.add(iconifyAction); mi = menu.add(iconifyAction);
mi.setMnemonic('n'); mi.setMnemonic(getButtonMnemonic("minimize"));
mi = menu.add(maximizeAction); mi = menu.add(maximizeAction);
mi.setMnemonic('x'); mi.setMnemonic(getButtonMnemonic("maximize"));
menu.add(new JSeparator()); menu.add(new JSeparator());
mi = menu.add(closeAction); mi = menu.add(closeAction);
mi.setMnemonic('C'); mi.setMnemonic(getButtonMnemonic("close"));
}
private static int getButtonMnemonic(String button) {
try {
return Integer.parseInt(UIManager.getString(
"InternalFrameTitlePane." + button + "Button.mnemonic"));
} catch (NumberFormatException e) {
return -1;
}
} }
protected void showSystemMenu() { protected void showSystemMenu() {
......
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.awt.Point;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.Locale;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import sun.awt.SunToolkit;
/**
* @test
* @bug 8020708
* @author Alexander Scherbatiy
* @summary NLS: mnemonics missing in SwingSet2/JInternalFrame demo
* @library ../../regtesthelpers
* @build Util
* @run main bug8020708
*/
public class bug8020708 {
private static final Locale[] SUPPORTED_LOCALES = {
Locale.ENGLISH,
new Locale("de"),
new Locale("es"),
new Locale("fr"),
new Locale("it"),
new Locale("ja"),
new Locale("ko"),
new Locale("pt", "BR"),
new Locale("sv"),
new Locale("zh", "CN"),
new Locale("zh", "TW")
};
private static final String[] LOOK_AND_FEELS = {
"Nimbus",
"Windows",
"Motif"
};
private static JInternalFrame internalFrame;
private static JFrame frame;
public static void main(String[] args) throws Exception {
for (Locale locale : SUPPORTED_LOCALES) {
for (String laf : LOOK_AND_FEELS) {
Locale.setDefault(locale);
if (!installLookAndFeel(laf)) {
continue;
}
testInternalFrameMnemonic();
}
}
}
static void testInternalFrameMnemonic() throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 200);
JDesktopPane desktop = new JDesktopPane();
internalFrame = new JInternalFrame("Test");
internalFrame.setSize(200, 100);
internalFrame.setClosable(true);
desktop.add(internalFrame);
internalFrame.setVisible(true);
internalFrame.setMaximizable(true);
frame.getContentPane().add(desktop);
frame.setVisible(true);
}
});
toolkit.realSync();
Point clickPoint = Util.getCenterPoint(internalFrame);
robot.mouseMove(clickPoint.x, clickPoint.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync();
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_SPACE);
toolkit.realSync();
Util.hitKeys(robot, KeyEvent.VK_C);
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
if (internalFrame.isVisible()) {
throw new RuntimeException("Close mnemonic does not work");
}
frame.dispose();
}
});
}
static final boolean installLookAndFeel(String lafName) throws Exception {
UIManager.LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels();
for (UIManager.LookAndFeelInfo info : infos) {
if (info.getClassName().contains(lafName)) {
UIManager.setLookAndFeel(info.getClassName());
return true;
}
}
return false;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册