Fixed

2005-10-04  Lillian Angel  <[EMAIL PROTECTED]>

        * javax/swing/plaf/metal/MetalToolTipUI.java
        (paint): Added space around the toolTip's accelerator.
        (fetchAcceleratorString): Added code to get mnemonic for
        JMenuItem if it does not have an accelerator.



On Tue, 2005-10-04 at 11:13 -0400, Lillian Angel wrote:
> I have tested this and the mnemonics are not being shown if the
> accelerator is null. Also there should be more space around the
> accelerator in the tooltip. Looks a little crammed.
> 
> I am working on fixing this. I will let you know how it goes.
> 
> Lillian
> 
> On Tue, 2005-10-04 at 15:13 +0000, David Gilbert wrote:
> > Lillian Angel wrote:
> > 
> > >On Tue, 2005-10-04 at 12:39 +0000, David Gilbert wrote:
> > >  
> > >
> > >>I decided to implement the missing methods in MetalToolTipUI.  As far as 
> > >>I can tell, 
> > >>tooltips for buttons and menu items under the MetalLookAndFeel display 
> > >>the 
> > >>accelerator text in the tooltip, but under the BasicLookAndFeel they do 
> > >>not.  So the 
> > >>accelerator code in BasicToolTipUI needs moving to MetalToolTipUI.
> > >>
> > >>This patch cleans up both classes - I'm asking for review and comments 
> > >>because it is 
> > >>a reasonably big change to BasicToolTipUI and it is possible that I've 
> > >>missed 
> > >>something.  Here is the ChangeLog:
> > >>
> > >>2005-10-04  David Gilbert  <[EMAIL PROTECTED]>
> > >>
> > >>  * javax/swing/plaf/basic/BasicToolTipUI.java
> > >>  (accText): removed,
> > >>  (accDeliminator): removed,
> > >>  (accFont): removed,
> > >>  (accFore): removed,
> > >>  (getPreferredSize): removed accelerator code (now in MetalToolTipUI),
> > >>  (getAcceleratorText): removed (equivalent is now in MetalToolTipUI),
> > >>  (paint): removed accelerator painting,
> > >>  * javax/swing/plaf/metal/MetalToolTipUI.java
> > >>  (padSpaceBetweenStrings): new field,
> > >>  (MetalToolTipUI): initialise defaults,
> > >>  (getAcceleratorString): new method,
> > >>  (installUI): new method,
> > >>  (uninstallUI): new method,
> > >>  (isAcceleratorHidden): new method,
> > >>  (getPreferredSize): new method,
> > >>  (paint): new method,
> > >>  (fetchAcceleratorString): new private method,
> > >>  (acceleratorToString): new private method,
> > >>  * examples/gnu/classpath/examples/swing/Demo.java
> > >>  (mkButton): set tool tip.
> > >>
> > >>Comments?
> > >>    
> > >>
> > >
> > >Looks fine to me :)
> > >Lillian
> > >
> > >
> > >
> > >  
> > >
> > Thanks.  Committed.
> > 
> > Regards,
> > 
> > Dave
> 
> 
> 
> _______________________________________________
> Classpath-patches mailing list
> [email protected]
> http://lists.gnu.org/mailman/listinfo/classpath-patches
Index: javax/swing/plaf/metal/MetalToolTipUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalToolTipUI.java,v
retrieving revision 1.3
diff -u -r1.3 MetalToolTipUI.java
--- javax/swing/plaf/metal/MetalToolTipUI.java	4 Oct 2005 14:12:34 -0000	1.3
+++ javax/swing/plaf/metal/MetalToolTipUI.java	4 Oct 2005 15:19:59 -0000
@@ -258,7 +258,7 @@
         g.setColor(acceleratorForeground);
         fm = t.getFontMetrics(acceleratorFont);
         int width = fm.stringWidth(acceleratorString);
-        g.drawString(acceleratorString, vr.x + vr.width - width, 
+        g.drawString(acceleratorString, vr.x + vr.width - width - padSpaceBetweenStrings/2, 
                 vr.y + vr.height - fm.getDescent());
       }
 
@@ -282,19 +282,22 @@
         JToolTip toolTip = (JToolTip) c;
         JComponent component = toolTip.getComponent();
         KeyStroke ks = null;
+        int mne = 0;
         if (component instanceof JMenuItem)
           {
             JMenuItem item = (JMenuItem) component;
             ks = item.getAccelerator();
+            if (ks == null)
+                mne = item.getMnemonic();
           }
         else if (component instanceof AbstractButton)
           {
             AbstractButton button = (AbstractButton) component;
-            int mne = button.getMnemonic();
-            if (mne > 0)
-              ks = KeyStroke.getKeyStroke(Character.toUpperCase((char) mne), 
-                    InputEvent.ALT_MASK, false);
+            mne = button.getMnemonic();
           }
+        if (mne > 0)
+          ks = KeyStroke.getKeyStroke(Character.toUpperCase((char) mne), 
+                InputEvent.ALT_MASK, false);
         if (ks != null)
           result = acceleratorToString(ks);
       }
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to