I'm trying to implement a application with GUI in Java that can let users build a model using certain predefined modeling language.
Is there any approach that I could easily build a GUI where user can do "drag a circle into canvas", "connect this circle with that rectangle", etc?
Or I should just use Swing.(maybe Swing Builder for simplicity). listen to the action of mouse and draw something accordingly?
Also I found Graphic Modeling Frame work in Eclipse very interesting, but I'm not sure if I could integrate it into my App easily.
Personally, I would give the Eclipse Modeling Framework a try before starting to write something in Swing (or SwingBuilder - you mean the Swing framework for Groovy?), unless you need something very simple and you are quite sure the required functionality will remain small.
According to the FAQ on the Eclipse wiki, it is possible to use EMF standalone in your application:
"I want to use EMF, SDO, or XSD in my standalone project, or include only a working subset of the code. What libraries (jar files) do I need in my CLASSPATH?
Eclipse Modeling Framework (EMF) provides the infrastructure to run the generated models and dynamic model based on existing ecore files. It also provides XMI/XML serialization and deserialization.
The following jars can be used in standalone mode. [Lists of jars are provided for several scenarios.]"
This EMF tutorial by Lars Vogel could also be useful.
Related
Exactly how much bloat does using a platform like the Netbeans Platform or Eclipse RCP actually add to your application? I am trying to decide if it is really neccessary for me to use it. I will only be using a very small amount of the functionality actually provided by the framework, all of which are relatively easy to implement from scratch.
All I basically need is some form of plugin management, where users code their libraries according to an API and my program can locate their services. This is easy enough to implement from scratch in a few lines of code. Further than that, I will need to do some 2D graphics work where widgets can be dragged and dropped etc. Does these two requirements make a strong enough case to use a framework? I am actually leaning more towards just doing it myself.
Thanks.
If you are considering a writing your own plugin solution, I would highly recommend going with Eclipse's implementation of OSGi through the RCP. OSGi is rock solid, and handles things like alternate versions of the same library and all sorts of class-path issues. This will help your plugin providers, since they won't have to worry about what other libraries are present. This is much better than dropping a bunch of jars into the same classpath.
I'd like to create an Eclipse extension modelling a decision tree/diagram. The actual modelling would be done using a graphical interface (nodes, connections etc). I'd like this plugin to generate code based on nodes and their interconnections. I have basic model classes ready; however, my diagrams are very large and it's difficult to manage all the connections only through code. I imagine I would build the whole diagram using GUI. When I double-click on a connection, I'd like to be able to override some of its methods, thus creating an anonymous subclass.
I found GEF used in similar plugins. Is my goal plugin "doable" in GEF? Do you have any advice?
Yes. GEF is the foundation for building any graphical editor in Eclipse. It has basic support for moving nodes, placing connection, palette, etc. Other frameworks sit on top of GEF to make the task of creating a graphical editor even easier if your requirements fit with their supported scenarios. Take a look at Eclipse Graphiti project.
I would say that GMF is something that would help your life. GMF generates quite big parts for free, and also includes EMF.
Also GMF is highly extendeable, so if you don't like something it has generated, you can just override those parts.
There are good GMF tutorial here: http://wiki.eclipse.org/Graphical_Modeling_Framework/Tutorial
Swing provides the basic building blocks for any GUI application but what about a higher level take on building GUI applications?
I'm not asking about the many arbitrary libraries that provide yet more wizzy variants on various visual components.
I'm talking about the missing pieces that everyone ends up building themselves whenever they create anything other than a trivial GUI application.
I.e. the framework that the application specific logic builds on.
E.g. handling data binding, application lifecycle issues or supporting common things like building forms.
If we were talking about persistence you could say that anyone can code up their own persistence layer using the javax.sql or java.io classes - however most people would rather use something like Hibernate.
So, just as someone asking about persistence libraries probably isn't looking for variants on ObjectOutputStream, I am not looking for variants on some JComponent subclass or other.
I think this is a fair Stackoverflow question as, unlike areas like persistence, a clear consensus on the answer is not easy to determine using Google.
Rather than a grab bag of random libraries perhaps people could answer in terms of what GUI issues are not immediately addressed by Swing and what libraries they feel best fill these gap?
I asked a similar question to this last week and it was closed - I've tried to phrase this such that this won't also be closed. If you feel inclined to close it perhaps you might consider making it community wiki instead?
Here are some essential libraries:
JGoodies - http://www.jgoodies.com/. This provides some nice layout tools (FormLayout) as well as common builders and databinding tools
SwingLabs - http://www.swinglabs.org/. This provides many common components you likely may need to use that are not part of standard swing.
Swing Application Framework - https://appframework.dev.java.net/ (already mentioned by jluzwick)
Groovy SwingBuilder - http://groovy.codehaus.org/Swing+Builder. This provides for easier building of GUIs by using a logical, hierarchical scripting-like language for building GUIs. It also has native support for some databinding.
Could you be referring to something like this?
https://appframework.dev.java.net/
This was integrated with Netbeans at one point and I don't think the development has continued, but this framework greatly helped me in creating a much more involved application with java.
EDIT:
It seems these projects are derivations of the former I mentioned that are actively in development:
http://kenai.com/projects/bsaf/pages/Home
http://kenai.com/projects/guts/pages/Home
JGoodies Bindings is great if you want to have a well-architected program.
NetBeans Platform (RCP) I really want to try. It's really the only viable Swing frameworks because ...
Swing Application Framework is very lacking and is not actively in development anymore.
MiGLayout is my favorite layout manager for cases where I used to use GridBagLayout (long time ago) and JGoodies form layout. Also, I dislike GroupLayout.
Have look at the NetBeans Platform (Swing based RCP)
In eclipse you can detach tabs and they will displayed in a special kind of window.
Win7 with aero displays it as follows
http://www.oliholz.de/data/1.jpg
How can i produce this frame? i have tried many styles of JFrame,JWindow,JDialog, ...
As other people mentioned eclipse uses it's own library for UI. That library is based on SWT which is better integrated with the native window system.
See this article for explanation on how SWT, AWT, and Swing relate to each other.
Eclipse Rich Client Platform which is also mentioned here can be observed as a layer above SWT that can make your life much easier if you intend to develop a complex, feature rich application (for example an IDE for the new programming language you made).
Take a look at the Eclipse Rich Client Platform. If you want to emulate their look and feel, you might consider building your user interface upon their free (and rather good) open source framework.
I'm a fan of swing and find it has done everything I need except for extensible GUIs. I can make small parts extensible programmatically, but if I want to plug in an optional feature it can be quite tedious to dynamically generate every component being altered.
The short period I spent writing a Firefox plug in got me very interested in the idea of Overlays.
Does there exist anything for Java with a similar concept?
It would of course be good to know more precisely what do you mean by "extensible" GUI.
In my work most needs for extending Swing components are nicely fulfilled by JXLayer. For example, things like implementing validation notification layer, blocking with progress indication etc.
"to plug in"
Do you mean plugins?
Take a look here:
http://karussell.wordpress.com/2009/09/16/plugable-swing-a-hello-world-osgi-example/
similar things are possible with NetBeans lookup class (openide) and the ServiceLoader included in JDK6:
http://weblogs.java.net/blog/2008/08/12/simple-dependency-injection-serviceloader-jdk-6
For an extensible GUI framework look here:
http://karussell.wordpress.com/2009/10/08/java-application-frameworks-not-only-client-side/
Update: Now with griffon you can do this too
There have been multiple attempts at projects that can convert an xml document into a java GUI.
JavaFX would be ideal, but that requires 1.6u10 or better.
Take a look at the SwingBean framework.
It's kind of cool, because it allows you to generate user interfaces through xml files.
Here is the link: http://swingbean.sourceforge.net/