jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • JRuby
  • JRUBY-2395

Have to call setPaint instead of assigning to g.paint

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor 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)

  1. 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.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Text File
    test.rb
    15/Apr/08 9:44 AM
    0.6 kB
    Andrew Whitehouse

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Bill Dortch added a comment - 15/Apr/08 4:13 PM

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.

Show
Bill Dortch added a comment - 15/Apr/08 4:13 PM 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.
Hide
Permalink
Andrew Whitehouse added a comment - 16/Apr/08 3:45 AM

Would it be possible to generate a warning if there is a name clash between public fields and Rubified method aliases?

Show
Andrew Whitehouse added a comment - 16/Apr/08 3:45 AM Would it be possible to generate a warning if there is a name clash between public fields and Rubified method aliases?
Hide
Permalink
Charles Oliver Nutter added a comment - 25/Aug/08 8:03 PM

A warning might be a good idea, but there would be scads of errors since there's a lot of such conflicts. I'm not sure whether we should consider this a bug or an RFE, since there's really no right way here that's going to satisfy everyone.

Show
Charles Oliver Nutter added a comment - 25/Aug/08 8:03 PM A warning might be a good idea, but there would be scads of errors since there's a lot of such conflicts. I'm not sure whether we should consider this a bug or an RFE, since there's really no right way here that's going to satisfy everyone.
Hide
Permalink
Charles Oliver Nutter added a comment - 08/Feb/09 5:16 PM

No good answer for this one, but the current behavior is probably the best default for most people.

Show
Charles Oliver Nutter added a comment - 08/Feb/09 5:16 PM No good answer for this one, but the current behavior is probably the best default for most people.

People

  • Assignee:
    Charles Oliver Nutter
    Reporter:
    Andrew Whitehouse
Vote (0)
Watch (2)

Dates

  • Created:
    15/Apr/08 9:44 AM
    Updated:
    27/Oct/09 1:48 PM
    Resolved:
    08/Feb/09 5:16 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.