提交 5e849a15 编写于 作者: A alexsch

7024965: Stylepad demo: remove non-translatable resources from Stylepad.properties file

Reviewed-by: alexp
上级 c53980b6
...@@ -62,7 +62,7 @@ import javax.swing.UIManager.LookAndFeelInfo; ...@@ -62,7 +62,7 @@ import javax.swing.UIManager.LookAndFeelInfo;
@SuppressWarnings("serial") @SuppressWarnings("serial")
class Notepad extends JPanel { class Notepad extends JPanel {
private static Properties properties; protected static Properties properties;
private static ResourceBundle resources; private static ResourceBundle resources;
private final static String EXIT_AFTER_PAINT = "-exit"; private final static String EXIT_AFTER_PAINT = "-exit";
private static boolean exitAfterFirstPaint; private static boolean exitAfterFirstPaint;
...@@ -77,12 +77,12 @@ class Notepad extends JPanel { ...@@ -77,12 +77,12 @@ class Notepad extends JPanel {
try { try {
properties = new Properties(); properties = new Properties();
properties.load(Notepad.class.getResourceAsStream( properties.load(Notepad.class.getResourceAsStream(
"resources/system.properties")); "resources/NotepadSystem.properties"));
resources = ResourceBundle.getBundle("resources.Notepad", resources = ResourceBundle.getBundle("resources.Notepad",
Locale.getDefault()); Locale.getDefault());
} catch (MissingResourceException | IOException e) { } catch (MissingResourceException | IOException e) {
System.err.println("resources/Notepad.properties " System.err.println("resources/Notepad.properties "
+ "or resources/system.properties not found"); + "or resources/NotepadSystem.properties not found");
System.exit(1); System.exit(1);
} }
} }
...@@ -298,7 +298,7 @@ class Notepad extends JPanel { ...@@ -298,7 +298,7 @@ class Notepad extends JPanel {
*/ */
private Component createToolbar() { private Component createToolbar() {
toolbar = new JToolBar(); toolbar = new JToolBar();
for (String toolKey: TOOLBAR_KEYS) { for (String toolKey: getToolBarKeys()) {
if (toolKey.equals("-")) { if (toolKey.equals("-")) {
toolbar.add(Box.createHorizontalStrut(5)); toolbar.add(Box.createHorizontalStrut(5));
} else { } else {
...@@ -363,7 +363,7 @@ class Notepad extends JPanel { ...@@ -363,7 +363,7 @@ class Notepad extends JPanel {
*/ */
protected JMenuBar createMenubar() { protected JMenuBar createMenubar() {
JMenuBar mb = new JMenuBar(); JMenuBar mb = new JMenuBar();
for(String menuKey: MENUBAR_KEYS){ for(String menuKey: getMenuBarKeys()){
JMenu m = createMenu(menuKey); JMenu m = createMenu(menuKey);
if (m != null) { if (m != null) {
mb.add(m); mb.add(m);
...@@ -389,8 +389,10 @@ class Notepad extends JPanel { ...@@ -389,8 +389,10 @@ class Notepad extends JPanel {
return menu; return menu;
} }
// get keys for menus /**
private String[] getItemKeys(String key) { * Get keys for menus
*/
protected String[] getItemKeys(String key) {
switch (key) { switch (key) {
case "file": case "file":
return FILE_KEYS; return FILE_KEYS;
...@@ -403,6 +405,14 @@ class Notepad extends JPanel { ...@@ -403,6 +405,14 @@ class Notepad extends JPanel {
} }
} }
protected String[] getMenuBarKeys() {
return MENUBAR_KEYS;
}
protected String[] getToolBarKeys() {
return TOOLBAR_KEYS;
}
// Yarked from JMenu, ideally this would be public. // Yarked from JMenu, ideally this would be public.
protected PropertyChangeListener createActionChangeListener(JMenuItem b) { protected PropertyChangeListener createActionChangeListener(JMenuItem b) {
return new ActionChangedListener(b); return new ActionChangedListener(b);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册