Some mauve tests were submitted to test the MetalIconFactory icons. I
fixed them to return a shared instance instead of creating a new Icon
instance each time.
2005-11-23 Lillian Angel <[EMAIL PROTECTED]>
* javax/swing/plaf/metal/MetalIconFactory.java:
Added new fields to store an instance of the icons.
(getMenuArrowIcon): Fixed to make use of the new field.
(getMenuItemArrowIcon): Fixed implementation to return
an instance of the icon, instead of calling getMenuArrowIcon.
Even though, these two look identical.
On Wed, 2005-11-23 at 10:25 -0500, Lillian Angel wrote:
> On Wed, 2005-11-23 at 11:43 +0100, Roman Kennke wrote:
> > Hi Lillian,
> >
> > Am Dienstag, den 22.11.2005, 15:15 -0500 schrieb Lillian Angel:
> > > Added implementations for missing functions in MetalIconFactory and
> > > MetalTextFieldUI.
> > >
> > > 2005-11-22 Lillian Angel <[EMAIL PROTECTED]>
> > >
> > > * javax/swing/plaf/metal/MetalIconFactory.java
> > > (getMenuArrowIcon): Implemented.
> > > (getMenuItemArrowIcon): Implemented to call getMenuArrowIcon,
> > > because both icons look the same.
> >
> > Would be useful to figure out if this really should return the same icon
> > class. They may look the same in some scenarious, but differ in
> > others...
>
> Roman and I agreed to leave this. The arrow icons look identical in all
> scenarios. If anyone sees differently, please let me know.
>
> >
> > > (getMenuItemCheckIcon): Implemented.
> > > * javax/swing/plaf/metal/MetalTextFieldUI.java
> > > (propertyChange): Implemented to call super only, because it
> > > is a hook method. It doesn't have a different purpose from
> > > BasicLookAndFeel, other than allowing a subclass to override it.
> >
> > I disagree. If the hook is provided in the BasicLookAndFeel and it's
> > specified to be overridden in MetalTextFieldUI, then there must be some
> > functionality there. Only calling super.propertyChange() doesn't change
> > anything (except some additional useless calls) from not implementing
> > this class at all in MetalTextFieldUI. I would guess that there actually
> > _should_ be some functionality in this method. Would be good to figure
> > out.
>
> Neither Roman or I could see what else should be done here. I am leaving
> it as is for now.
>
> Lillian
>
>
>
> _______________________________________________
> Classpath-patches mailing list
> [email protected]
> http://lists.gnu.org/mailman/listinfo/classpath-patches
Index: javax/swing/plaf/metal/MetalIconFactory.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalIconFactory.java,v
retrieving revision 1.21
diff -u -r1.21 MetalIconFactory.java
--- javax/swing/plaf/metal/MetalIconFactory.java 22 Nov 2005 20:14:34 -0000 1.21
+++ javax/swing/plaf/metal/MetalIconFactory.java 23 Nov 2005 21:02:32 -0000
@@ -68,6 +68,12 @@
/** A constant representing "light". */
public static final boolean LIGHT = true;
+
+ /** A shared instance of the MenuArrowIcon. */
+ private static Icon menuArrow;
+
+ /** A shared instance of the MenuItemArrowIcon. */
+ private static Icon menuItemArrow;
/**
* An icon displayed for [EMAIL PROTECTED] JCheckBoxMenuItem} components.
@@ -2476,39 +2482,62 @@
*/
public static Icon getMenuArrowIcon()
{
- return new Icon()
- {
- public int getIconHeight()
+ if (menuArrow == null)
+ menuArrow = new Icon()
{
- return 8;
- }
+ public int getIconHeight()
+ {
+ return 8;
+ }
- public int getIconWidth()
- {
- return 4;
- }
+ public int getIconWidth()
+ {
+ return 4;
+ }
- public void paintIcon(Component c, Graphics g, int x, int y)
- {
- Color saved = g.getColor();
- g.setColor(Color.BLACK);
- for (int i = 0; i < 4; i++)
- g.drawLine(x + i, y + i, x + i, y + 7 - i);
- g.setColor(saved);
- }
- };
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+ g.setColor(Color.BLACK);
+ for (int i = 0; i < 4; i++)
+ g.drawLine(x + i, y + i, x + i, y + 7 - i);
+ g.setColor(saved);
+ }
+ };
+ return menuArrow;
}
/**
* Returns a new instance of a 4 x 8 icon showing a small black triangle that
- * points to the right. This is displayed in menu items that have a
- * sub menu.
+ * points to the right. This is displayed in menu items that have a sub menu.
*
* @return The icon.
*/
public static Icon getMenuItemArrowIcon()
{
- return getMenuArrowIcon();
+ if (menuItemArrow == null)
+ menuItemArrow = new Icon()
+ {
+ public int getIconHeight()
+ {
+ return 8;
+ }
+
+ public int getIconWidth()
+ {
+ return 4;
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+ g.setColor(Color.BLACK);
+ for (int i = 0; i < 4; i++)
+ g.drawLine(x + i, y + i, x + i, y + 7 - i);
+ g.setColor(saved);
+ }
+ };
+ return menuItemArrow;
}
/**
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches