Index: Actions.java =================================================================== RCS file: /cvs/openide/src/org/openide/awt/Actions.java,v retrieving revision 1.66 diff -c -r1.66 Actions.java *** Actions.java 21 Aug 2002 10:20:42 -0000 1.66 --- Actions.java 22 Aug 2002 09:55:36 -0000 *************** *** 200,209 **** } else { item.setText(text.substring(0, i) + text.substring(i + 1)); if (useMnemonic) { ! item.setMnemonic(text.charAt(i + 1)); } } } } /** Replaces the first occurence of &? by ? or (&?? by the empty string --- 200,250 ---- } else { item.setText(text.substring(0, i) + text.substring(i + 1)); if (useMnemonic) { ! char ch = text.charAt(i + 1); ! java.util.ResourceBundle bundle = org.openide.util.NbBundle.getBundle (Actions.class); ! try { ! String s = bundle.getString("MNEMONIC_" + ch); // NOI18N ! if (s.length () == 1) { ! // associated is a character ! item.setMnemonic (s.charAt (0)); ! } else { ! // associated should be an integer ! int vkcode = Integer.parseInt(s); ! item.setMnemonic (vkcode); ! } ! // not i+1, because we've cut the "&" ! setDisplayedMnemonicIndex (item, i); ! } catch (java.util.MissingResourceException ex) { ! // ok just set the character ! item.setMnemonic(ch); ! } } } } + } + + /** holds instance of Actions14 or plain object if not on JDK1.4 */ + private static Object actions14; + private static void setDisplayedMnemonicIndex (AbstractButton button, int index) { + if (org.openide.modules.Dependency.JAVA_SPEC.compareTo ( + new org.openide.modules.SpecificationVersion("1.4") + ) >= 0) { // NOI18N + if (actions14 == null) { + try { + Class c = Class.forName ("org.openide.awt.Actions14"); + actions14 = c.newInstance (); + } catch (Exception ex) { + ErrorManager.getDefault().notify(ex); + actions14 = ex; + } + } + + if (actions14 instanceof java.util.Map.Entry) { + ((java.util.Map.Entry)actions14).setValue(new Object[] { + button, new Integer (index) + }); + } + } } /** Replaces the first occurence of &? by ? or (&?? by the empty string Index: Actions14.java =================================================================== RCS file: Actions14.java diff -N Actions14.java *** /dev/null 1 Jan 1970 00:00:00 -0000 --- Actions14.java 22 Aug 2002 09:55:36 -0000 *************** *** 0 **** --- 1,44 ---- + /* + * Sun Public License Notice + * + * The contents of this file are subject to the Sun Public License + * Version 1.0 (the "License"). You may not use this file except in + * compliance with the License. A copy of the License is available at + * http://www.sun.com/ + * + * The Original Code is NetBeans. The Initial Developer of the Original + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2002 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.openide.awt; + + /** A helper class that calls JDK1.4 methods on AbstractButton + * + * @author Jaroslav Tulach + */ + final class Actions14 implements java.util.Map.Entry { + + /** Creates a new instance of Actions14 */ + public Actions14() { + } + + public Object getKey() { + return null; + } + + public Object getValue() { + return null; + } + + public Object setValue(Object value) { + Object[] arr = (Object[])value; + + javax.swing.AbstractButton button = (javax.swing.AbstractButton)arr[0]; + Integer index = (Integer)arr[1]; + + button.setDisplayedMnemonicIndex(index.intValue()); + return null; + } + + }