This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 26640

Summary: RFE: One-line API call to set text, mnemonics & mnemonic index
Product: platform Reporter: _ mihmax <mihmax>
Component: -- Other --Assignee: Jesse Glick <jglick>
Status: VERIFIED FIXED    
Severity: blocker CC: hmichel, jf4jbug, jglick, jtulach, raccah, ttran
Priority: P2 Keywords: API, I18N
Version: 3.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:
Bug Depends on: 26678, 31004, 31093    
Bug Blocks: 27009, 30885, 31147    
Attachments: Mnemonics v4
v4 with \n only

Description _ mihmax 2002-08-20 15:42:16 UTC
I found a very serious bug in localized Netbeans:

When I translate, e.g. "&File" menu name into Russian, I 
have "&<SOME RUSSIAN SYMBOL>...", 
but then the key combination Alt+<SOME RUSSIAN SYMBOL> 
doesn't work!

All other menus and submenus, buttons, etc. are also 
affected.

I'd like this fixed for Netbeans 3.4, please.

Of course, the user may use the mouse, but the Keyboard is 
also handy thing ;)

And I do not like the way, used by Localizators of Mozilla 
(which also has the same bug), who just translated the 
menu name, but left the English key combination.
So "&File" menu would look like 
"<RUSSIAN TRANSLATION> (&F)" - this is not very attractive 
anyway.
Comment 1 _ mihmax 2002-08-20 15:46:46 UTC
In order to simulate, download Russian L10N module from 
Daily Autoupdate or http://translatedfiles.netbeans.org 
(Files section),
and add "-locale ru" into ide.cfg or command line of runide
Comment 2 Jesse Glick 2002-08-20 18:49:09 UTC
As mentioned on nbdev, there is no better way of doing this known to
us... you can use the Mozilla-style technique in NetBeans with no code
change. See Javadoc for Actions.{setMenuText,cutAmpersand} for
details, or Japanese bundles for examples.

If you know of a better solution which works with at least some
languages not using Roman script, please investigate, and reopen with
a patch. Properly testing such things requires knowledge of the kinds
of keyboards used by people working in such locales, for example.
Japanese localizers concluded that the current system was best for
Japanese - I don't know details.
Comment 3 _ mihmax 2002-09-04 14:33:48 UTC
As the resolution of issue
http://www.netbeans.org/issues/show_bug.cgi?id=26678
stated, 

this can be fixed,
I'll prepare the setLabelText method patch, and hope that all of
Netbeans developers will use the setLabelText instead of setText &
setDisplayedMnemonic separately.
Comment 4 _ mihmax 2002-09-04 14:38:41 UTC
See also RFE http://www.netbeans.org/issues/show_bug.cgi?id=27009
to module form.

I'd like that the form module use both setButtonText & setLabelText
from org.openide.awt.Actions.
Comment 5 Jaroslav Tulach 2002-09-04 16:41:35 UTC
I suggest to move the method from Actions class to Utilities class.
The reason is that Utilities are part of openide-util separate bundle
while Actions class is included just in the whole NetBeans
distribution. This could be useful for form editor users that could
bundle openide-util.jar (build by cd openide; ant libs) with their
applications.

public static void Utilities.setLocalizedText (AbstractButton b,
String text);
public static void Utilities.setLocalizedText (JLabel l, String text)

The Action.setXXX method would just delegate to Utilities.setLocalizedText
Comment 6 _ mihmax 2002-09-04 20:05:27 UTC
I've created patches for the form module, that fix this issue for all
AbstractButton's children.
Comment 7 _ mihmax 2002-09-04 20:31:55 UTC
Good idea, Jaroslav!!!
(or Jarda is better?)

> I suggest to move the method from Actions class to 
> Utilities class.

I'd suggest to create two separate files ??? and ???14 which will
contain only these pieces of code.
And put them into separate jar.

The reason:
Bundle for user-applications will be as small as possible.

> The Action.setXXX method would just delegate to 
> ???.setLocalizedText
No problem

Where's the right place for two new files?
I mean full path: module/src/.../ ;)
 (because, I didn't get the location you mention ;))

Comment 8 _ mihmax 2002-09-10 10:48:06 UTC
I suggest org.openide.awt.Mnemonic.java & org.openide.awt.Mnemonic14.java
Comment 9 _ mihmax 2002-09-11 10:18:33 UTC
> I suggest to move the method from Actions class to Utilities class.

the openide-util.jar is also rather big for redistributing it with
user-apps

My proposal:
    org/openide/mnemonic/Mnemonic.java 
    - setLocalizedText (AbstractButton b, String text);
    - setLocalizedText (JLabel b, String text);

Any other thoughts?
Comment 10 Jesse Glick 2002-09-11 16:18:19 UTC
Issue #27009 is the proper place to discuss whether & how
Mnemonic.java could be redistributed to users. That question should be
handled by the form module developers. For example, they can easily
package any particular class from openide/src/ into a dedicated
redistributable JAR file without help from openide developers (simple
form/build.xml patch I guess).
Comment 11 _ mihmax 2002-10-21 20:52:00 UTC
Final proposal: 
1. This functionality is mainly for developing Netbeans using
Netbeans, hence it will be advertised as such to users ("Don't use it
unless you know what you're doing" ;) ).
2. It goes into 4.0
3. Names:
   Class is org.openide.awt.Mnemonic.java (+ *14.java) 
   Methods are:
     public static void setLocalizedLabel(AbstractButton b, String text);
     public static void setLocalizedLabel(JLabel l, String text);
=======================================================
If no feedback in 48 hours, I start coding & asking everybody on the
Earth to put my code into CVS, then to change all their code to use
mine ;-)

Sincere, Maxym
Comment 12 _ ttran 2003-01-29 10:15:08 UTC
IMO, this issue turned into an ENHANCEMENT, and it's for the form
module, not core/openide anymore.

I am reassinging it to the form module for further actions
Comment 13 Jesse Glick 2003-01-29 15:24:06 UTC
In fact it is intended to be an openide API addition with devel-time
support from form, plus numerous updates to actual uses of mnemonics
in various places throughout the NB UI.
Comment 14 _ ttran 2003-01-29 15:37:23 UTC
Hmm taking back to openide, but making this ENHANCEMENT
Comment 15 _ mihmax 2003-02-09 20:34:02 UTC
*** Issue 29676 has been marked as a duplicate of this issue. ***
Comment 16 _ mihmax 2003-02-09 20:50:13 UTC
I'm trying to order these two issues: 26640 and 27009.

This issue should be openide Enchancement to allow setting label and
mnemonics by a single API call.
That's why I change issue summary (was: I18N - Alt+Symbol doesn't work
for localized Menus, Buttons & Labels), and mark 27009 depend on this
issue.

Issue 27009 will be the change in form module to use this RFE in
NetBeans developing NetBeans.

Comment 17 _ mihmax 2003-02-09 20:56:14 UTC
Created attachment 8857 [details]
Mnemonics v4
Comment 18 _ mihmax 2003-02-09 21:00:30 UTC
The v4 attachment is a remake of v3 from issue 27009, changed upon
Jesse' suggestions.
Another thing Jesse suggested is to reassign this issue to him, so
please take it ;-)

// Don't forget that I'm using Windows, so change \r\n -> \n before
commiting in on Unix, because weird things happen then //
Comment 19 _ mihmax 2003-02-09 21:18:46 UTC
Created attachment 8858 [details]
v4 with \n only
Comment 20 Jesse Glick 2003-02-10 18:05:01 UTC
*** Issue 30885 has been marked as a duplicate of this issue. ***
Comment 21 Jesse Glick 2003-02-10 19:55:43 UTC
Done; Maxym please review & verify esp. using Russian locale.

committed   * Up-To-Date  1.102       openide/openide-spec-vers.properties
committed   * Up-To-Date  1.137      
openide/api/doc/changes/apichanges.xml
committed   * Up-To-Date  1.80       
openide/src/org/openide/awt/Actions.java
removed     * Up-To-Date  1.1        
openide/src/org/openide/awt/Actions14.java
added       * Up-To-Date  1.1        
openide/src/org/openide/awt/Mnemonics.java
added       * Up-To-Date  1.1        
openide/src/org/openide/awt/Mnemonics.properties
Comment 22 _ mihmax 2003-02-17 13:48:56 UTC
With (or even w/o) #31004,
in Russian locale the API gives the possibility to get the 
nice-looking underlined menus, buttons and labels under 
JDK1.4, now we need to replace:
- btn.setText(...);
- btn.setMnemonic(...);
to
- Mnemonics.setLocalizedText(btn,...);

all around NetBeans code... Allot places out there, so I 
filed a separate Task #31147 as an umbrella ;-)