Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4306876

Fix tooltips for JMenuItems with accelerators (incl. for L10N, I18N)

XMLWordPrintable

    • beta
    • x86
    • windows_nt



      Name: krT82822 Date: 01/24/2000


      orig synopsis: "Wrong tooltips for menuitems with accelerators"
      (see also 4238727, 4267733, 4207482)

      1/24/2000 eval1127@eng -- the salient points:

      a) can't localize modifier strings, because they're in the source (believe this is an already-recorded bug)
      b) map non-printable things like <HOME> to something readable, which is one of the motivations for asking that we ...
      c) allow eliminating the accelerator from the displayed tooltip [one of the points form 4267733]

       (as of 1.3.0rc1-T, HOME shows as "$" in the tooltip on Solaris)

      ------- original user report: ---------------------------------------

      java version "1.2.2"
      Classic VM (build JDK-1.2.2-W, native threads, symcjit)

      The method <L&F>ToolTipUI.getAcceleratorText() creates wrong strings.

      First, the modifierstrings differ from those used by KeyEvent and they are part
      of the sourcecode. So they can't be localized!!!

      Second, the accelerator should be a character, because keys like <Home> are not
      displayed in the right way.

      Third, there is no way to avoid acceleratorstrings in tooltips, if the component
      got an accelerator.

      The following example shows how the accelerator Ctrl-Home turns to cntl+$.
      import java.awt.event.*;
      import javax.swing.*;
      public final class TooltipBug {
      public TooltipBug() {
      JFrame f = new JFrame("Bug-Demo");
      JMenuBar mb = new JMenuBar();
      JMenu m = new JMenu("Klick me");
      JMenuItem mi = new JMenuItem("Correct Tooltip");
      mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, InputEvent.CTRL_MASK));
      mi.setToolTipText("Wrong Tooltip");
      m.add(mi);
      mb.add(m);
      f.setJMenuBar(mb);
      f.pack();
      f.addWindowListener(
      new WindowAdapter(){
      public void windowClosing(WindowEvent event){System.exit(0);}
      }
      );
      f.setVisible(true);
      }
      public static void main(String[] parameters) {
      TooltipBug bug = new TooltipBug();
      }
      }
      (Review ID: 99709)
      ======================================================================

            peterz Peter Zhelezniakov
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: