David Koontz
Posts: 3
Nickname: dkoontz
Registered: May, 2008
|
|
Re: Puppets Do JRuby
|
Posted: May 30, 2008 4:23 PM
|
|
I know this post is pretty old and I'm sure you've learned more about JRuby but I wanted to stick some notes on here for people just learning about JRuby via this video.
1. You don't need include_class for java or javax packages. You could have done JFrame = javax.swing.JFrame. If you wanted to import your own package, com.bruceeckel.foo you would need to put that in quotes, i.e. include_class 'com.bruceeckel.foo'. The reason it worked in your example is that JRuby knows what javax is and thus resolved it for you. A third (hah, Ruby's all about choice right!) is to use Java::com::bruceeckel::foo and that will work for any arbitrary package.
2. You don't need parentheses on setSize just like you didn't need them for setVisible or the call to JFrame.new. You can use either set_size or setSize, JRuby preserves the original Java name.
3. For single arg get/set methods JRuby gives you a far more Ruby'ish method. setVisible becomes visible = and getVisible becomes just visible. So your last line would be "frame.visible = true"
|
|