Using monkeybars with netbeans

I’m experimenting with monkeybars in NetBeans. I’ve gotten a couple of
simple projects to run. The main NetBeans project is a Java project, and
I understand why. However, I’ve noticed that this hobbles ruby
development within the project: within the java project, there is no
simple way to access rake tasks, netbeans suddenly doesn’t know how to
handle RSpec files, etc.

I’m guessing (hoping?) that I’m not the first to ponder this. What are
the best ways to manage ruby development for a monkeybars-based project
in NetBeans? Is it possible to put most of the model code in a separate
ruby project, and link that with the java project in some clean way?
Other ideas?

The prospect of using NetBeans/Matisse to design Swing forms, monkeybars
to connect the gui to ruby-coded model code, and package the whole thing
up in a cross-platform friendly format via rawr is highly attractive for
what I ultimately need to do. I’m trying to find the best IDE set-up
towards that end.

Thank you in advance,
Bruce

Bruce Tesar wrote:

ruby project, and link that with the java project in some clean way?
Other ideas?

It’s been a while since I used Netbeans with Monkeybars. I’ve been
using Swingset-NG to create the UI code in plain (more or less) Ruby.
My UI needs have been fairly simple.

The prospect of using NetBeans/Matisse to design Swing forms, monkeybars
to connect the gui to ruby-coded model code, and package the whole thing
up in a cross-platform friendly format via rawr is highly attractive for
what I ultimately need to do. I’m trying to find the best IDE set-up
towards that end.

I used to work on a fairly large Monkeybars project in Netbeans, but I
used it in conjunction with vim and the command line. I don’t recall
running tests or specs from Netbeans. I’m not sure I could, since I
think the NB project would have been set as a Java project, not a Ruby
project. OTOH, my memory can be flaky.

I tended to use Netbeans to design and compile the GUI, then run rake
tasks from the command line. Yet I have a vague recollection that
others in my team were doing everything in Netbeans. I was surprised at
how good NB was for editing Ruby; it has some nice refactoring tools
built-in. I just preferred my vim/CLI set-up.

I’m thinking maybe the way to do this is to set up the project as a Ruby
project, and then (somehow) add in Java files. This way Netbeans is
aware of Rake tasks and such but compiles the Java code to class files.

BTW, I found this, but it doesn’t mention mixing JRuby and Java code in
the same project: http://wiki.netbeans.org/NetbeansedJRuby

James B.

Neurogami - Avant-garage Research & Development

[email protected]

Bruce -

I don’t have any experience with the gems/libraries that simplify Swing
programming, but even if you code to raw Swing you don’t have to write a
line of Java code (though you do need to call Java methods and
subclass Java classes). For an example of this, you can check out my
JRuby Swing app at GitHub - keithrbennett/life_game_viewer.

Also there is an illustration of turning it into a gem in case that
would be helpful for you. You could provide an executable in the gem, as
I have done:

This should be done in JRuby and not MRI Ruby, of course:

gem install life_game_viewer
life_view_sample

Of course, that would require the user have JRuby fully installed (as
opposed to just having the JRuby jar file), which you probably don’t
want to require.

You can also run a JRuby app with the command line looking something
like this (from http://jruby.org/apidocs/org/jruby/Main.html):

java -jar jruby.jar [switches] [rubyfile.rb] [arguments]

  • Keith

Keith R. Bennett

Bruce Tesar wrote:

James B. wrote in post #1102000:

It’s been a while since I used Netbeans with Monkeybars. I’ve been
using Swingset-NG to create the UI code in plain (more or less) Ruby.
My UI needs have been fairly simple.

James, thanks for the thoughtful reply.
When you use Swingset-NG and Monkeybars, is all of the source code ruby
files? Or do you still need a Main.java on top?

A main.java is needed as a Java entry point it you want an executable
jar but it’s autogenerated by rawr.

If you are just calling the code from JRuby you don’t need that.

If it is ruby all the way through, is there still a good way (rawr or
other) to package the whole project into a single executable?

Rawr works fine with this.

I’m still quite new to Swing, so the project I’m working on looks
complex to me, but might not appear so to a more experienced developer.
The use of Matisse looks convenient, but I am going to have to make a
non-trivial amount of contact with swing code in any event, because I
need to do some GUI manipulation at runtime. So doing things purely in
ruby might ultimately be nicer, anyway.

Swing can be a major PITA. Swingset-NG helps with basics (frames, text,
labels, layout using MiG) but for anything complex you would have to
know a bunch of Swing, and that’s where using a WYSIWYG editor has the
upper hand.

You can still write your Swing using Ruby, but you spend a lot of time
with Swing API docs to get method and property names and conventions and
quirks.

James

Neurogami - Avant-garage Research & Development

[email protected]

James B. wrote in post #1102000:

It’s been a while since I used Netbeans with Monkeybars. I’ve been
using Swingset-NG to create the UI code in plain (more or less) Ruby.
My UI needs have been fairly simple.

James, thanks for the thoughtful reply.
When you use Swingset-NG and Monkeybars, is all of the source code ruby
files? Or do you still need a Main.java on top?

If it is ruby all the way through, is there still a good way (rawr or
other) to package the whole project into a single executable?

I’m still quite new to Swing, so the project I’m working on looks
complex to me, but might not appear so to a more experienced developer.
The use of Matisse looks convenient, but I am going to have to make a
non-trivial amount of contact with swing code in any event, because I
need to do some GUI manipulation at runtime. So doing things purely in
ruby might ultimately be nicer, anyway.

Thanks again,
Bruce

James,

thanks for the information!

Swing can be a major PITA. Swingset-NG helps with basics (frames, text,
labels, layout using MiG) but for anything complex you would have to
know a bunch of Swing, and that’s where using a WYSIWYG editor has the
upper hand.

You can still write your Swing using Ruby, but you spend a lot of time
with Swing API docs to get method and property names and conventions and
quirks.

It looks like I have more experimenting to do (determining what my
tolerance is for swing-speak). I may follow up on a suggestion from your
previous post, and try creating a java project just to construct the gui
forms, compile them, and copy the class files over to a ruby project.

Thanks again,
Bruce

James

Neurogami - Avant-garage Research & Development

http://www.neurogami.com

[email protected]

Keith,

thanks for the clarification, and for the pointer to your project; I may
take a look at it soon, as another example. I don’t think I’ve worked
with cellular automata since 1990 or so. :slight_smile:

Bruce

Keith B. wrote in post #1102126:

Bruce -

I don’t have any experience with the gems/libraries that simplify Swing
programming, but even if you code to raw Swing you don’t have to write a
line of Java code (though you do need to call Java methods and
subclass Java classes). For an example of this, you can check out my
JRuby Swing app at GitHub - keithrbennett/life_game_viewer.

Also there is an illustration of turning it into a gem in case that
would be helpful for you. You could provide an executable in the gem, as
I have done:

This should be done in JRuby and not MRI Ruby, of course:

gem install life_game_viewer
life_view_sample

Of course, that would require the user have JRuby fully installed (as
opposed to just having the JRuby jar file), which you probably don’t
want to require.

You can also run a JRuby app with the command line looking something
like this (from http://jruby.org/apidocs/org/jruby/Main.html):

java -jar jruby.jar [switches] [rubyfile.rb] [arguments]

  • Keith

Keith R. Bennett
Keith R. Bennett - Reston, Virginia, Bennett Business Solutions Inc | about.me

Hope that this can help http://zetcode.com/gui/jrubyswing/

Regards

Manuel R. Caro wrote in post #1102499:

Hope that this can help http://zetcode.com/gui/jrubyswing/

Manuel, thanks! At first glance, this looks quite accessible; I’ll read
through it.

Bruce

That site looks interesting. The Java (as opposed to JRuby) Swing site
at http://zetcode.com/tutorials/javaswingtutorial/ has more detailed
information about Swing and can easily be mentally translated into
JRuby.

In some of the code examples, the Java set methods are used, and you can
simplify the call a bit by using JRuby’s snake case and attribute=
aliasing, e.g.:

   self.getContentPane.setLayout layout

can be simplified to:

content_pane.layout = layout

I agree with the poster who said that Java Swing is complicated (at
least for nontrivial applications). However, I’ve found that the
frameworks that are simpler are usually too primitive for my needs.

  • Keith

Keith R. Bennett

Keith B. wrote:

Manuel R. Caro wrote:

Hi again…

There’s also a JavaFx integration … since Jruby can call directly Java
its only a question of translation … but it is poorly documented…

Just to make things even more fun, you can also use the Processing jars
and use Processing as your GUI.

This may only be sensible if you are already familiar with Processing,
and some particular Processing library in mind to use. (Toxiclibs or
something, for example.)

James

Neurogami - Avant-garage Research & Development

[email protected]

Hi again…

There’s also a JavaFx integration … since Jruby can call directly Java
its only a question of translation … but it is poorly documented…

JavaFx Scene Builder…

… and FXML maybe can help a little more.

Regards