This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[GUI] Patch: javax.swing.plaf.basic.BasicButtonUI
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Tue, 8 Jun 2004 22:17:53 +0200
- Subject: [GUI] Patch: javax.swing.plaf.basic.BasicButtonUI
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi list,
I just commited the attached patch to be able to draw disabled
buttons.
Michael
2004-06-08 Michael Koch <konqueror@gmx.de>
* javax/swing/plaf/basic/BasicButtonUI.java
(paintIcon): Simplified.
(paintText): Paint disabled button correctly.
- --
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFAxh70WSOgCCdjSDsRAt8yAKCQdF6ftQAbRpnrvdnOUZ+sEvuESACfX52M
fVFrEOhJasEInxOJviC7XNU=
=h/SG
-----END PGP SIGNATURE-----
Index: javax/swing/plaf/basic/BasicButtonUI.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/plaf/basic/BasicButtonUI.java,v
retrieving revision 1.6.2.2
diff -u -b -B -r1.6.2.2 BasicButtonUI.java
--- javax/swing/plaf/basic/BasicButtonUI.java 21 May 2004 23:34:15 -0000 1.6.2.2
+++ javax/swing/plaf/basic/BasicButtonUI.java 8 Jun 2004 20:15:18 -0000
@@ -311,11 +311,7 @@
Icon i = currentIcon(b);
if (i != null)
- {
- int x = iconRect.x;
- int y = iconRect.y;
- i.paintIcon(c, g, x, y);
- }
+ i.paintIcon(c, g, iconRect.x, iconRect.y);
}
/**
@@ -369,9 +365,18 @@
Font f = c.getFont();
g.setFont(f);
FontMetrics fm = g.getFontMetrics(f);
+
+ if (c.isEnabled())
+ {
g.setColor(c.getForeground());
- BasicGraphicsUtils.drawString(g, text, 0,
- textRect.x,
- textRect.y + fm.getAscent());
+ g.drawString(text, textRect.x, textRect.y + fm.getAscent());
+ }
+ else
+ {
+ g.setColor(c.getBackground().brighter());
+ g.drawString(text, textRect.x, textRect.y + fm.getAscent());
+ g.setColor(c.getBackground().darker());
+ g.drawString(text, textRect.x + 1, textRect.y + fm.getAscent() + 1);
+ }
}
}