Eu Hin Chua <[EMAIL PROTECTED]> wrote:

> Has anyone ever managed to get keyboard mnemonics working for JButtons
> using Swing?
> 
> e.g.
> 
> OKButton.setMnemonic('o');
> 
> Under windows 95/8/NT, all of my code (including the SwingSet demo)
> performs as expected, with the ALT key being used to activate the mnemonic
> for both buttons and menu items. Under Linux, nothing happens at all.

Swing button mnemonics work just fine for me, both in standalone buttons
and menus.  I've used them in my own code, and I also just checked the
SwingSet demo and it works OK too.  I did nothing special to set them up;
pressing Alt+key has always just worked.

Here's my setup:

  Red Hat Linux 5.0 w/upgraded glibc libraries
  Blackdown JDK 1.1.6v4a
  Swing 1.0.3
  Metro-X 4.3 X server

Chances are, the problem is not with the JDK; it's with the way you have your
X server configured.  Are you able to use the Alt key in other X applications?
Check your .xinitrc or .xsession script for "xmodmap" commands; if you've used
xmodmap to reconfigure your keyboard, the Alt keys might be generating keysyms
other than what the JDK is expecting.  You can use the "xev" program to see
whay keysyms your Alt keys are generating; here's what the output looks like
on my system, for the left and right Alt keys respectively.  The keysym on
the third line is what's important: it should be "Alt_L" and "Alt_R".

KeyPress event, serial 23, synthetic NO, window 0x4400001,
    root 0x26, subw 0x0, time 2229881684, (-6,-24), root:(720,883),
    state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,

KeyPress event, serial 23, synthetic NO, window 0x4400001,
    root 0x26, subw 0x0, time 2229886534, (-6,-24), root:(720,883),
    state 0x0, keycode 113 (keysym 0xffea, Alt_R), same_screen YES,

Another thing to try is displaying your program on a different X display, if
one is available on your network.  If the problem goes away, then you know
it's something to do with your X server.

-Jim Burmeister, Metro Link Incorporated <[EMAIL PROTECTED]>

Reply via email to