Re: [cp-patches] RFC: BasicTabbedPaneUI paint null Icon?

2005-11-25 Thread Roman Kennke
Am Freitag, den 25.11.2005, 14:58 +0100 schrieb Mark Wielaard:
> Hi,
> 
> On Tue, 2005-11-22 at 01:03 +0100, Mark Wielaard wrote:
> > This one is a little strange. Apparently the plastic laf overrides
> > getIconForTab(int) and returns null in certain cases. But then it still
> > calls paintIcon on it. I cannot find too much documentation on this, but
> > this seems the correct thing to do:
> > 
> > 2005-11-21  Mark Wielaard  <[EMAIL PROTECTED]>
> > 
> > * javax/swing/plaf/basic/BasicTabbedPaneUI.java (paintIcon): Only
> > paint icon when not null.
> > 
> > Comments?
> 
> Several people on irc said that they found it strange, but saw no
> problem with it since it fixes a real current problem.

I think this is quite common in the laf classes. They have to deal with
possible null value because the methods are intended to be overridden in
most cases and the implementation therefore cannot guarantee that some
field or method does not return null. I have also seen this in various
other UI classes as well.

/Roman



signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: [cp-patches] RFC: BasicTabbedPaneUI paint null Icon?

2005-11-25 Thread Mark Wielaard
Hi,

On Tue, 2005-11-22 at 01:03 +0100, Mark Wielaard wrote:
> This one is a little strange. Apparently the plastic laf overrides
> getIconForTab(int) and returns null in certain cases. But then it still
> calls paintIcon on it. I cannot find too much documentation on this, but
> this seems the correct thing to do:
> 
> 2005-11-21  Mark Wielaard  <[EMAIL PROTECTED]>
> 
> * javax/swing/plaf/basic/BasicTabbedPaneUI.java (paintIcon): Only
> paint icon when not null.
> 
> Comments?

Several people on irc said that they found it strange, but saw no
problem with it since it fixes a real current problem.

Committed,

Mark



___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] RFC: BasicTabbedPaneUI paint null Icon?

2005-11-21 Thread Mark Wielaard
Hi,

This one is a little strange. Apparently the plastic laf overrides
getIconForTab(int) and returns null in certain cases. But then it still
calls paintIcon on it. I cannot find too much documentation on this, but
this seems the correct thing to do:

2005-11-21  Mark Wielaard  <[EMAIL PROTECTED]>

* javax/swing/plaf/basic/BasicTabbedPaneUI.java (paintIcon): Only
paint icon when not null.

Comments?

This is the last patch needed to get Emir to start up.
http://gnu.wildebeest.org/~mark/emir.png

Cheers,

Mark
Index: javax/swing/plaf/basic/BasicTabbedPaneUI.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java,v
retrieving revision 1.30
diff -u -r1.30 BasicTabbedPaneUI.java
--- javax/swing/plaf/basic/BasicTabbedPaneUI.java	18 Nov 2005 21:57:37 -	1.30
+++ javax/swing/plaf/basic/BasicTabbedPaneUI.java	21 Nov 2005 23:55:01 -
@@ -1881,7 +1881,8 @@
   protected void paintIcon(Graphics g, int tabPlacement, int tabIndex,
Icon icon, Rectangle iconRect, boolean isSelected)
   {
-icon.paintIcon(tabPane, g, iconRect.x, iconRect.y);
+if (icon != null)
+  icon.paintIcon(tabPane, g, iconRect.x, iconRect.y);
   }
 
   /**
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches