I've been looking for a set of tools for rapid GUI development in jRuby and everywhere I look, I get Swing, AWT and other Java-related tools. I learnt jRuby coz I was pretty much fed up with the excessively verbose Java code that made programming a chore. The last thing I want to do is look at it again while coding in ruby code. Does anyone have any suggestions for jRuby GUI development tools that do NOT include Swing, AWT or other Java-related stuff? I don't need a native look and feel, just the ability to add my own images as buttons and customize the UI elements using images.
on 2013-05-04 03:42
on 2013-05-04 08:40
Have you tried MigLayout which (IMHO) makes Swing usable. ...R
on 2013-05-04 12:39
Limelight comes to mind , see here; http://limelight.8thlight.com/ Charles Monteiro email@example.com
on 2013-05-04 17:16
Charles, Limelight is interesting -- althoughI just looked at it briefly, it looks good. It *is* written in Java, though it looks like it provides a Ruby wrapper around its Java. Farsheed, that said, if the development you're doing is for something serious (that is, multiple users and an expected multiyear lifetime with future upgrades), then I think you'd do better with something more established. I believe Limelight hasn't been updated in 8 months (https://github.com/slagyr/limelight), and though there's nothing wrong with that, it could, for example, eventually become out of date with respect to a new version of Java, JRuby, etc. However, please be aware that just because Java code is verbose doesn't mean that the Ruby code calling it needs to be. I have an example of a JRuby Swing program here: Github repo: https://github.com/keithrbennett/life_game_viewer Blog article: http://www.bbs-software.com/blog/2012/09/05/conway... This fileprobably has the most Swing library interaction: https://github.com/keithrbennett/life_game_viewer/... Thanks to JRuby, the code there isn't that much worse than code using a Ruby library would be. I spent several years doing Java Swing development, andmy take on it is it's a very powerful library, but it's complex, with a steep learning curve. Complex UI products like NetBeans and the Intellij IDE's such as RubyMine use it. Forget AWT, it's ancient, and worse. SWT, maybe; I only looked at it briefly once, and thought it to be less fully featured than Swing. This page lists some GUI frameworks for Ruby: https://www.ruby-toolbox.com/categories/GUI_Frameworks. There's an FFI wrapper around Tk -- that might be an option for you -- I think Tk is far less complex than Swingor SWT. - Keith Keith R. Bennett http://about.me/keithrbennett
on 2013-05-06 01:32
Keith: I know, it seemed to be that the op was looking for non-Swing i.e. not the usual Java GUI development framework. I'm not pushing it and I agree with your assessment. Thanks for the links on the Jruby Swing example. Charles
on 2013-05-06 03:22
Keith: Can you think of any examples that uses Jruby's Swing API but does that in the context of the output generated by a GUI design tools like IDEA's GUI Builder ? thanks Charles
on 2013-05-06 14:21
Charles - To be honest, I've never used a GUI builderfor Swing. I have no idea what their output is. So I don't know of any examples. I'm a bit suspicious of GUI builders, believing they may nurture bad habits, such as the production of monolithic and complex frames that defy reuse. That's probably an invalid prejudice based on GUI builders I used that predated Swing, though. Unless it's a trivial UI, you'll want to reuse panels, both to save you work, and for look and feel consistency. So be careful how you use them -- it's easy to be tempted to do an entire frame in one step, but there may be cases where you would be better off creating individual panelsby themselves, and then assembling them either in code, or in the GUI builder, if that is possible. - Keith Keith R. Bennett http://about.me/keithrbennett
on 2013-05-06 17:24
Keith: thanks, I have been spoiled I'm afraid. I have been using GUI builders in VisualWorks Smalltalk since 94 and they do allow you to create reusable components which is well supported and encouraged. Again, i totally agree with your advise and it may be the case that the IDEA GUI builder and or Swing combo make it hard to create reusable components via the builder. I hope that's not the case. I suppose that the GUI builder will generated a class or set of classes so perhaps its just a matter of requiring said file into one's Ruby project and then creating in Jruby the callback implementations for the various listeners. Perhaps the IDEA team has examples of that somewhere. Charles
on 2013-05-06 18:29
We are still actively developing JRubyFX but you can use JavaFX scene builder: http://www.oracle.com/technetwork/java/javafx/tool... This will create a FXML file of the layout you made and then you can attach controllers to it for behavior. JRubyFX can be found here: https://github.com/jruby/jrubyfx There is an example showing this in the repo... -Tom
on 2013-05-06 18:47
Very interesting Is there a roadmap for the project ? I'll scan git but I trust that I will be able to understand what the current limitations are. thanks Charles
on 2013-05-06 20:21
There is not a roadmap, but I can mention a few things which are still happening: - Fxml support has been in flux recently but I think it should be fairly stable now. byteit101 has been working on that and it would be what you would consume from the RAD tool. Jumping on now will help shake out any issues with FXML support. He is using it for a complex GUI. - DSL API which can work in conjunction with Fxml is filling out method signatures which are missing parameter helpers. Parameter helpers allow us to specify things like 'fill= :red' instead of 'fill = Color.new(...)'. We have these on most of the popular FX types but we need to make them for all types. - Speeding up load time. byteit101 also has a branch which loads fast(er) now. loadtime is an ever-present work item for JRuby in general :) So, it is a project where many things work and there are still plenty of unfinished aspects. -Tom
on 2013-05-07 05:02
Tom - Can you tell us anything about JavaFX in general? Do you like it? Is it a good framework? (I guess they all have their issues, so my question should really be "is it better than the others?".) I found this information page on FX, if anyone's interested: http://www.oracle.com/technetwork/java/javafx/over... - Keith Keith R. Bennett http://about.me/keithrbennett
on 2013-05-07 18:25
I take JavaFX as the Swing replacement these days and I think if you are interesting in a rich GUI then JavaFX has more to offer over Swing. As such, frameworks like Moneybars could be retrofitted to also target FX controls. So don't think of JavaFX as being as much a new framework as a new set of components/controls. The obvious nice things about FX is how easy it is to get a polished visual effect. Or how easy it is to make non-rectangular windows. If you couple this with the fact that stylesheets are baked into the system then you can write a program once and restyle it without changing code. A lot of refinements over what Swing provides. JRubyFX (and any other language binding like GroovyFX) typically makes using the library nicer since they all layer on their idiomatic patterns on the API. In JRubyFX, programatically we have a DSL for simpler scene layout. JavaFX also provides FXML as a mechanism for storing a scene layout as data (typically generated using a RAD tool) which generally will be used for more complex layouts. JRubyFX can pull in these XML files and use them in a natural way. -Tom
on 2013-05-10 20:19
Thanks for the responses, everyone. JavaFX does look promising, although I haven't used it and sincerely hope it isn't as user unfriendly as everything else Java has made. I'm curious to know how a person using Ruby (not jRuby) would go about developing desktop applications. This is not so much because I want to know about how Ruby actually achieves this but more because I would like to know what it would use other than Java-based technologies. I'm not sure why all the jRuby UI development tools are Java-centric. What does Ruby, which cannot use these, do and can this also be used for jRuby? This would enable developers to easily switch between Ruby and jRuby without needing to learn or use a different technology in each case.
on 2013-05-10 20:32
Farsheed - I think it's because almost all user facing apps written these days are web or mobile apps -- very few are desktop apps. Try looking for a job coding in Ruby that's not a Rails job and you'll know what I mean. ;) Back when Java became popular, they were still writing a lot of desktop client apps, and a desktop GUI library was quite important. Not so much anymore. - Keith
on 2013-05-11 00:26
That makes sense, Keith. Would you know what Ruby (not jRuby) does in case of a thick client application? Something more on the lines of a fullscreen multiplayer game rather than a browser-based application.
on 2013-05-11 01:12
I don't really know what you'd use for MRI Ruby. I guess you could access the low level OS calls if you wanted to, but I imagine that would be a lot of work, and nonportable. If you're writing games, I do know that Java has a 3D library, and you could drive that from JRuby if you wanted to. At least you'd be OS-portable. That would be low level too though. There may be libraries available to wrap some of that complexity for you, I don't know. If you can find a C library, then you could probably find a way to drive it from MRI Ruby. - Keith
on 2013-05-11 13:59
A great native GUI library for Ruby is Shoes, http://shoesrb.com/. I don't know if Shoes is appropriate for game development. I seem to remember talk of a JRuby version of Shoes, but I'm not finding it in a too quick search.
on 2013-05-11 15:36
Bruce Adams wrote in post #1108591: > A great native GUI library for Ruby is Shoes, http://shoesrb.com/. I > don't know if Shoes is appropriate for game development. > > I seem to remember talk of a JRuby version of Shoes, but I'm not finding > it in a too quick search. Purple Shoes, perhaps?: https://github.com/ashbb/purple_shoes
on 2013-05-12 13:14
It looks like Steve Klabnik's reply didn't make it to the list. (He may not be a subscriber.) Steve Klabnik <firstname.lastname@example.org> wrote: Shoes 4 (github/shoes/shoes4) is all jruby, and people do write games in Shoes.
on 2013-05-12 15:19
Hi ... I had experiment with Qt and theres a way to integrate Nokias Wysiwyg tool and a translator to Ruby... but i thinks on this on MRI and sure this will give you more that one headache... first i choose Jruby thinking on portability ... Also a solution for GUI that nots include Java need a 3rd party lib to makes it run.. This must require aditional work on deploy or event on develop stations day to day ... All this troubles and works hours are reduced using Java that let you run Jruby itself. The Gui libs are ready to be used and its crossplatform. After a lots on thinks hours i find that this is one of the reasons because all Ruby Gui tries are on that way...and take it as one of the better for mines... Regards El 11/05/2013 20:12, "Bruce Adams" <email@example.com> escribi:
on 2013-05-14 00:12
On Fri, May 3, 2013 at 8:42 PM, Farsheed Bamboat <firstname.lastname@example.org>wrote: > There's a Qt binding for JRuby (hasn't been updated in 11 months though): https://github.com/CeesZ/qt_connect There's also Monkeybars, which applies a modified MVC pattern to Swing: https://github.com/monkeybars/monkeybars-core
on 2013-05-14 00:24
I share your non-enthusiasm for Java related UI having done a fair bit of Swing in the thankfully distant past. However, so far my initial use of JavaFX is promising. It by far more reminds me of Apache (Adobe) Flex than Swing / AWT. There is also a major corp player and decent community behind it supporting and enhancing it. They claim it uses hardware acceleration although I have not tested that yet. I would suggest checking it out. Charles Monteiro email@example.com
on 2013-05-14 00:37
Keith Bennett wrote: > > C harles - > > To be hone st, I've never used a GUI builder for Swing. I have no idea > what their output i s. So I don't know of any examples. I'm a bit > suspicious of GUI builders , believing they may nurture bad habits, such > as the production of mon olithic and comp lex frames that defy reuse. That's entirely up to do the developer, at least in the case of the Netbeans GUI builder. I worked on a large commercial application that managed satellite modems, rendering a number of detailed windows and panels. It was written in JRuby using Monkeybars. (I'm the Monkeybars project admin, so assorted caveats apply.) We had several custom components that were reused. For example, a screen might show four different modems; we didn't code a separate modem panel for each one, nor did we create a single monolithic panel, since the number of modems could change . Such panels were dynamically added or removed as needed, reusing a single component class. > That's probably an invalid pre judice based on GUI builders I used that > predated Swing, though. > > Unless it's a tr ivial UI, you'll want to reuse panels, both to save you > work, and for look and feel consistency . S o be careful how you use > them -- it's easy to be temp ted to do an entire frame in one step, but > t here may b e cases wher e you wou ld be better off creating individual > panels by themselves, and then assembling them eithe r in code, or in > the GUI builder, if that is possible. Monkeybars has built-in support for the reuse of, and dynamic creation/removal of, components and (bearing in mind all my biases) is the only JRuby GUI framework suitable for anything of more than moderate complexity. And while it works really well with pre-compiled classes such as you can get from the Netbeans GUI builder you can also easily create UI items using in-line Ruby. In my own Monkeybars apps I use in-line code (via the Swingset-NG gem) to create simple stuff like an "About" screen or user input forms, and a GUI builder for anything more complicated. You can see an example program here: https://github.com/Neurogami/JotBot I think all the screens were made in Netbeans using the GUI tool. To address the original post, using Monkeybars will, at some point, have you sticking your nose into Swing. You really can't avoid it, if only to understand what options are available. No matter what GUI tool you choose you will have to dig into the quirks and foibles of the tool in order to do anything sophisticated, and that assumes the GUI toolkit even allows for sophistication. (I.e., can you design your own widgets outside of what the toolkit provides?) Swing is probably not much worse than others in that regard, and offers a tremendous range of UI options. You have to pick your battles. James Britt -- Neurogami - Avant-garage Research & Development http://www.neurogami.com firstname.lastname@example.org
on 2013-05-14 06:02
I've actually spent a great deal of time researching this question: how does one build a GUI app with Ruby? To answer your question here, there are basically two roads, in MRI (that's Matz's Ruby Implementation, the non-java ruby) there are a handful of GUI libraries, all of them binding to one of the C/C++ toolkits: Gnome/GTK, QT, Wx, Gosu(for games) etc. The second option is to use JRuby, and either work directly with one of the Java toolkits (Swing, SWT, JavaFX) , or use one of the libraries that wraps/abstacts/builds on top of those toolkits (Monkeybars, Rubeus, Limelight, JRubyFX). Shoes has also been mentioned. It is undergoing a rewrite that will use JRuby to provide a wrapper around SWT. Your suggestion of using one of the MRI GUI libraries, from JRuby, would make a lot of sense (portability of code, etc) except that all of those libraries bind to various C libraries, and support for that in JRuby is, well, currently unsupported. C-Ext support was offered as an experiment, in a previous version of JRuby (to the best of my understanding) but (again to the best of my understanding), it was buggy, difficult to maintain, and essentially working against the tool. I believe it is still possible to invoke JRuby with C-Extension support enabled, but I think for something as complex as a GUI toolkit, you'd have a hard time getting it working. You could possibly bind to one of those libraries via JNI/FFI support, but again, at this point you are basically working against the tool, creating a lot of trouble for yourself, to get something working which would never really be a good fit for each other. And quite possibly you would end up writing far, far more java code than had you just written your app using one of those Java GUI toolkits you seem to want to avoid. So, after all this research, what have I chosen for my projects going forward? JRubyFX, 100%. One, JavaFX is a really nice, modern GUI toolkit, with a lot of manhours being poured into improving it. It uses CSS for styling, has a great GUI builder (SceneBuilder), which produces FXML (which is quite readable/writable on its own), it performs well, and I could go on and on. It's really easy to create your own widgets, components, etc in JavaFX (or JRubyFX), and there's tons of great documentation, blog posts, and other info easily available for it. Two, JRubyFX provides a very ruby-ish wrapper around this, and its getting better all the time as byteit101 has been putting a ton of work into making it a top-notch framework. Three, efforts are currently underway to get JavaFX running on iOS and Android (it's been done in Oracle's lab, and they've opensourced their proto-types). This means, it may eventually be possible to write JRubyFX apps targeting those devices as well (This one's a big maybe, of course, but Android, at least, should be a very real possibility. This stuff about the mobile stuff is just speculation on my part, nobody from JRubyFX is doing any work on this stuff at the moment, or looking at it, that I know of, but it's something I am personally very intrigued by). Four, javafx provides some really slick packaging tools for easily building native installers for Windows, Linux and OSX. We've already integrated that support (in basic form, with information on how to customize it available) into JRubyFX. Finally, Oracle themselves have stated that JavaFX is the replacement for Swing, and that they will be phasing Swing out in favor of FX. Hope that helped answer your questions, and I hope I've convinced you to go checkout JRubyFX. It's awesome-sauce.
on 2013-05-15 18:50
Thanks for the responses, everyone. Eric, I think I'll check out JRubyFX.
on 2013-05-15 21:22
A great way of checking that out is via the Ensemble app which is basically an collection of sample Java FX apps for browser style exploration. It comes with the latest jdk i.e. as part of the samples , but is also available in the Apple AppStore if you are a Mac user. Charles Monteiro email@example.com
on 2013-05-16 06:21
Charles - Just to be sure, you're not talking about using Fx in a web browser, right? It seems that most or all of the Java security issues have to do with running Java in the browser. - Keith Keith R. Bennett http://about.me/keithrbennett