Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Won't Fix
-
Affects Version/s: JRuby 1.1
-
Fix Version/s: None
-
Component/s: Java Integration
-
Labels:None
-
Environment:Windows XP SP2, JDK 1.5.0 update 15
Description
Implementing a custom component ...
class CustomComponent < JComponent
def initialize
@paint2 = GradientPaint.new( 0, 0, Color::BLACK, 0, 200, Color::WHITE )
end
def paintComponent(g)
- g.setPaint( @paint2 )
g.paint = @paint2
g.fillRect( 0, 0, getWidth, getHeight )
end
end
the above doesn't display the GradiantPaint component. However, when calling setPaint the class behaves as expected.
This happens because the Graphics implementation (sun.java2d.SunGraphics2D) defines a public paint field (in Java => Ruby mapping, public fields take precedence over Rubified method aliases). Setting the field directly bypasses some of the logic in setPaint(), which is why it fails.
Not really anything to be done about it – as I've noted elsewhere, this is a common issue with the older AWT classes, which expose a lot of public fields.