Swing is good in many ways, then why do we need JavaFX?
There is both a technology part of JavaFX that will help design UIs, and a language part that will make writing UIs easier.
The JavaFX technology brings a 2d scenegraph and video capabilities. Afaik these will also be made available generally to java. They are good advancements for creating client side application with fancy and interactive graphical UIs. The 2d scenegraph should make it possible to create more graphic heavy applications that are still responsive.
The JavaFX language is a much better way off creating UIs programatically. Java Swing code can get very verbose, while the same JavaFX code will be smaller and easier to maintain. Closure support makes creating event handlers easier. Declerative assignment of settings makes configuration of elements easier. Native list syntax makes adding components easier.
Please note that I haven't really written any JavaFX, but I have read code and paid attention to what's going on. I recommend trying it yourself to find out what's cooking.
I think Staale's answer is a good start but I would add...
Use JavaFX if
1) If you're interested in developing the application for mobile or TV (note this has yet to be released)
2) If you're working with a graphic designer who is creating the appearance of the application in photoshop and you want to be able to import their look directly.
3) If making the GUI filthy rich is important to you. (so if you want a panel to fade in or out, or slide upon demand)
Use Swing if
1) You're creating an application mainly for the desktop.
2) Performance matters and you know what you are doing (so if you're writing an IDE, Swing would be a better choice)
3) You're looking for a RPC (rich client platform) to build upon.
It is the same reason why we have Java, C++, C#, Python, Perl, Ruby... although we already have C.
Related
Pretty soon now, we're gonna need to develop a GUI for creating configurations (more like scripts, to be honest) for our EAI solution at work. Think of a typical workflow editor. The visualization of the actual flows will most likely be a completely custom job, either in Swing, SWT or JavaFX 2. What I have trouble with choosing is whether to do everything else by ourselves or using a rich client platform.
In particular, I've noticed that JavaFX 2 is getting a lot of attention and seems to be really pushed by Oracle as the next big thing in the Java GUI landscape. The demonstrations look interesting and perhaps this newer API is more closely focused on productivity as opposed to the tons of boilerplate code that Swing tends to impose. Using a newer technology that gets a lot of support seems like a safe bet for future maintenance.
Using an RCP would have definite benefits for this project. Whether we go for Eclipse or NetBeans as the platform, having existing plugins/modules for viewing the underlying (XML) config, version control etc. would offer powerful functionality with minimal work. I also like the idea of having project types of our software next to Java projects in the same GUI. Even simple stuff like window management and customly arranging panels is much better handled by RCPs that what we could whip up.
So the question now is, what technology or combination thereof is viable? My options, as far as I can see, are thus:
Eclipse. I'm not too eager for using SWT, though, since I'm more familiar with Swing. NetBeans is also my primary IDE and I'm most familiar with it. It always felt more intuitive too.
NetBeans. This'd allow development of custom components in Swing. A lower learning curve for me.
NetBeans + JavaFX 2. This idea appeals to me... Use NetBeans for the RCP goodness and using JavaFX 2 for custom components. JavaFX 2 apparently integrates with Swing, but how well can this be done within NetBeans?
Swing or JavaFX 2. Do all the GUI work ourselves or use some existing framework(s) to get most of what an RCP offers. This seems like a lot of work but also offers superb control. I'm a bit loathe to try this in Swing. How well would JavaFX 2 suit itself to this?
Basically my only GUI experience is in Swing on small apps. This is the first time I'll be going for something that would warrant a RCP. But JavaFX 2 seems the way forward and I don't want to miss the boat on that one. If Swing might be on the way out, I'd prefer hopping onboard the newer technology.
If there are people who can share their experiences, have tried something like NetBeans + JavaFX 2 or are closer to the forefront of JavaFX and can recommend/discourage its use for this sort of thing I'd be most interested.
I realize it's a somewhat open question, but I can't really think of a more appropriate place. I'm not looking for a "what's the best RCP / is JavaFX better than Swing" debate. I'm looking for valid points for/against their use in this context.
My opinion in few lines,
JavaFX2 can be integrated into Swing and SWT applications into a panel/container.
Swing doesn't provide a structured architecture to deal with multi components applications, Eclipse RCP does but it's heavier and sometimes too complex (WindowWorkbench etc..) and hard to customize.
If you have a good UI Designer in your team (Developer or Graphic Designer) you should begin to work on an application Full JavaFX2 with a simple but powerful framework (like JRebirth or a custom one you can build on your own way).
JavaFX will be the Java UI Standard for years to come, It could'nt be a bad choice, thus its architecure is pretty good and powerful
Moreover javaFX2 could be used into a browser and/or deployed online with help of JNLP.
Don't bother you to learn complex undocumented framework (like EclipseRCP), create Yours !! and be free to make the application your client need :D
I worked 3 years on Swing Appz, 2 years on Eclipse RCP, and 2 years on Flex/Silverlight/JavafX apps
Here some points and (personal) opinions for helping you determining a proper solution for your current situation:
Eclipse vs. Netbeans
Personally, I dont't like big discussions about pros/cons of IDEs. Just use the one you feel most comfortable with. If you work in a team, make a voting. Considering Swing both IDEs are fine (IMHO Netbeans has the better GUI builder). Considering JavaFX 2.0 both IDEs are also fine but both share the absence of a GUI builder. I wouldn't recommend a mixture of IDEs.
JavaFX 2.0 vs. Swing vs. SWT vs. Eclipse RCP
Well, I don't - I even can't - want to tell you which of the above listed UI technologies is best since I don't know enough about your project's environment - experience, human resources, budget, timeline etc. Having a lean timeline and a team(?) of experienced Swing developers should lead the decision to Swing. Same for SWT and Eclipse RCP. Cutting edge developers might tend to try JavaFX. I agree, JavaFX gets a lot attention and you get great looking demonstrations, but keep in mind, that using JavaFX requires - additionally to the JRE - the JavaFX runtime on each client.
Hope this helps.
We switched to javaFx due to FXML usage,you can use MVC pattern ,you can add javascript and css init,but it seems slow when changing page
Im working on coding a WYSIWYG document designer. The basic intent of this designer is to be capable of both reading(loading) and creating multiple documents written in a variety of templating languages (ZPL, XSL-FO etc).
Now for the sake of building a WYSIWYG designer, i plan to have an elegant UI which the user can play around with to create/edit the document.
The compulsory needs of the UI is that --
The UI should be such that the user must be able to pick or
choose elements and be able to drop them off on the UI. Once
dropped, the position of the elements should be capable of allowing
repositioning.
The UI must associate the spatial postioning of elements to the
element's metadata (say, x coordinate,y coordinate, height ,width
etc).
The UI must be capable of seamlessly passing on the elements and
their spatial positions to a backend module,written in Java, that
would wither edit or create the document in the specified templating
language.
Im having trouble in deciding what to implement the UI in. I tried Swing and found it to be not great(was pretty rigid for my needs). Any suggestions with regard to what can be used to build the UI described above would be of immense help.
Your underpinnings options are pretty much Swing or SWT.
Not sure what you mean by "rigid"; Swing is a pretty good GUI framework architecturally, although some prefer SWT. Not sure how JavaFX will end up, but it has some nice features.
XUI layers on top. Or take the Griffon approach, although I'm not sure it's a great fit for the type of application you're working on. Or use Groovy/JRuby/etc. to make many aspects of working with Swing/etc. less painful.
IIRC there are Java bindings for QT as well, if the QT licensing works for you.
Perhaps you'll be better served by some rich client platform (RCP) like Eclipse or NetBeans. Both are probably best known as IDEs, but the IDEs are actually built on top of the respective platforms. Using an RCP will take a lot of responsibility out of your hands. Existing plugins/modules can be made to interoperate with your code and facilities such as perspectives (Eclipse) or rearranging panels are accounted for.
Like Dave Newton hinted at, JavaFX could also be a candidate. JavaFX 2.0 is now out and no longer requires the scripting language used in 1.0, instead opting for a Java API that'll feel more natural to experienced Java developers. And it can be used within Swing.
I've been developing in Java Swing for a while now, and I'm starting to feel that Swing-based desktop applications are feeling a little stale and are tedious to develop.
I'm seeing new applications that look very sleek and modern, like TweetDeck and Synthesia (a piano game). Despite the wisdom in Haase & Guy's "Filthy Rich Clients," I imagine that writing applications like these in Swing would be quite a chore.
Presuming that desktop applications won't totally disappear within the next 5 years (or that the division between the web and the desktop will become seamless), what UI languages and technologies should front-end developers be exploring to keep current? What's the next big thing?
Microsoft's WPF is probably one of the newest, coolest technologies out there.
It allows you to make much better looking GUIs.
You should also look into some of Microsoft's Expression products. They let you put that extra flare into your GUIs.
I'm not sure there's "the next big thing" in desktop UI development. If anything, "the next big thing" is a multi-touch based interface ala popular tablets and smartphones. Given that, I think it might be smart to learn how to create multitouch UIs by downloading a sdk for a mobile phone or tablet that supports multitouch.
If you like Swing, Take a look at Google GWT.
It is like Swing for the Web, well almost.
There will always be a need for OpenGL/Direct3D developers, but that might be further down than you're talking about.
On the Windows side WPF and Windows Forms are available.
On the Mac/iOS Cocoa is the way to go.
On Linux there's a few options such as GTK or QT.
You might just want to bite the bullet and learn some HTML5/JavaScript though. I doubt that's going to go away any time soon.
I'd suggest looking into Flex. It's much more interesting to develop than Swing and b/c it's Flash it can run in a browser or on a desktop.
Java still works fine. You simply replace standard controls with images and use image states to change the look on mouse overs and clicks.
I would also suggest WPF as another UI framework to get under your belt, because it does afford some pretty powerful UIs in desktop applications (and most of what can be one in WPF is translatable to Silverlight for webapps).
On the flipside, instead of looking for the next new UI language or technology, I think you may be better served looking at UI from a usability standpoint, and tracking the trends currently making waves.
As an example, one of the paradigm shift I'm seeing in UI development (mostly on the web) is the switch to making important things bigger and less important things smaller - including yes/no buttons in a dialog. I'm still warming up to this idea because it flies in the face of a consistent button look to show users their options.
Instead of providing options in a world today where we are constantly making decisions, the goal of this newer UI look is to breadcrumb the happy path. If the user decides they want to do something different, they can, but the UI is going to make the user put in a little effort and read the fine print.
Another example is flash-highlighting a recent change a person has made (SO does this, but I forget the term used to describe this effect) when coming onto a website.
Lastly, and this is one of my favorites, the shift from an administrative/user view (also mostly in the webapp sphere), to an ad-hoc WYSIWYG editor...Flickr is a prime example of this, where you can change captions on a picture by clicking on the current caption and editing it inline, without the need to go to a separate admin view to edit these values.
Is anyone else seeing trends like these that are interesting and new?
You've been programming in Swing for a while and you only just started feeling it looks outdated? :)
Swing looks like crap, no matter what look-and-feel tricks folks do for it. It actually put vendors of Swing-based desktop apps like ourselves at a disadvantage because of how shiny and pretty WPF stuff looks.
If you want to stay in the Java realm, I encourage you to try out SWT and JFace. You don't need Eclipse for it. But it's a much better looking system with a much nicer API.
If you want to go for attractive, WPF is your friend. You're limited to Windows and can't use Java (both showstoppers for me), but you can't ignore the aesthetics benefits of that SDK because it is so tightly bound to recent versions of Windows.
I think the point of the book you mention, and most of the answers here, are that most languages give you the tools, (or enough rope to hang yourself ;) to throw out the basic ugly controls of ANY OS you are on, and paint whatever user experience you want to. Yes it is tedious to skin or otherwise manually take over the visual representation of the controls in a UI, but if that's whats important to you, then you'll do it, and possibly be rewarded for it. Or castigated for breaking the "platform UI standards".
Can I build attractive GUI in Java? If yes, how should I do it? Or should I use some other language or tool to do it?
Filthy Rich Clients is a good book for learning how to use Java to build attractive GUIs that go beyond the usual Swing look.
You can use SWT, which as the other answer mentions is nice for a more native look. You can use JavaFx if you want to add a lot of visual candy, or you can use flash or other technologies and just perform remote operations.
Good luck.
You can just modify Swing look'n'feel as per this Java tutorial.
Attractive is quite subjective, but you can take a look to the Substance LaF (https://substance.dev.java.net/) and the Pushing Pixels blog (http://www.pushing-pixels.org)
If you are looking for a native look and feel in every platform you could use SWT. It's the one used in Eclipse.
You can build very attractive GUI using Java. You can use SWT: The Standard Widget Toolkit.
You have also mentioned if you can use other programming language then you can go for VIsual Basic.It will be easier than compare to Java. As we have to just drag and drop over there.
There are lots of answers on here about using SWT for an attractive native look and feel. However, I would suggest that Swing, set to use the native look and feel, is pixel perfect now, at least on Windows, using java 6. There is no longer a reason to use SWT. I work on a very large Swing project and you would be hard pressed to tell it is not a native windows app.
Edit: Here are a couple of links to some Sun blogs posts that touch on the subject -
http://weblogs.java.net/blog/bino_george/archive/2004/11/hifi_swing_or_i_1.html
http://weblogs.java.net/blog/chet/archive/2006/10/java_on_vista_y.html
Java is just a language. You cannot build a GUI in Java. Period.
The JDK libraries, however, can build guis through various means. You can use AWT, Swing, SWT, JavaFX or GWT libraries to build GUIs--or you can build your own library if you really want.
You can also just create an AWT frame and draw anything you want in it. (I worked on an waveform analyzer (o-scope looking thing) with a GUI written entirely in AWT.
Now, most of those libraries are fairly platform independent, if you want to restrict yourself to a single platform, you can do anything that can be done in C or any other language.
Therefore your question doesn't make too much sense. Are you saying that you want to put in minimum effort and get a good interface? Swing will be less effort than just about any other toolkit out there and can be skinned in more ways than most.
Or are you saying that you want to specify the exact GUI? In that case, don't use swing but there are a bunch of alternatives that should do just what you want.
Can you be more specific (Do you really want help?), or were you just trying to bash Java?
Obviously the Java API reference, but what else is there that you all use?
I've been doing web development my entire career. Lately I've been messing around a lot with Groovy and I've decided to do a small application in Griffon just to experiment more with Groovy and also break some ground in desktop development. The only thing is I'm totally green when it comes to desktop apps.
So, world, where's a good place to start?
The Swing Tutorial is very good. Apart from that, the Swing API is obviously the reference, however it's also a treasure trove of fairly good source code! Add the API source to your IDE and you can jump directly to the implementation to all the Swing classes. This is a great way to explore the functionality, see how various Swing components work and learn a good Swing "style". Furthermore, it's great to be able to step through the API classes if things don't seem to work and you have no idea why! Adding the API source to the IDE has the additional benefit that you get all the JavaDocs along with it, although all modern IDEs can also pull them from the net -- you do not want to program desktop Java without the documentation available from within the IDE!
NetBeans and other IDEs do make the creation of IDEs very easy, but be aware that there is a lot more to Swing than just containers and layout managers. In fact, containers and layout managers are among the easier things, and I'd recommend learning to use them by hand, too. There is nothing at all wrong with using a GUI builder, but in some cases it's overkill, and then it's nicer to just quickly whip up a GUI from source. In other cases you need to be able to create a GUI dynamically and then GUI builders are no use at all! For creating very complex layouts from source, I recommend FormLayout, which has its own set of quirks, but which does scale (in terms of programming effort) to very big frames and layouts.
If you've only done Groovy so far, you'll be surprised how well documented Swing and the rest of the Java API is and how well everything is integrated. It might also take some getting used to a different style of programming, using the debugger more often and println-debugging less, etc. There might also be some "boiler-plate" code that will be very annoying. ;) Enjoy.
The Sun Java tutorials are pretty good. I cannot vouch specifically for the Swing one as it has been ages since I've done any Swing development and I have not read it myself.
Creating a GUI with JFC/Swing
When it comes to developing java desktop applications, I would highly recommend using the IDE environment Netbeans. Especially when it comes to the development of Swing based applications.
I recommend you to play around with netbeans. It will allow you to build complete GUIs using only your mouse. Once you get familiar with Swing components, start using the Java API. Thats how I started.
The O'Reilly Swing Book is a pretty good reference, it has a good overview of general Swing concepts and covers each of the major classes. I used it recently when I had to refresh my memory on Swing.