Can JavaFX be included on a Java SE project? - java

I'm trying to create an Inventory project and have graphs on it. I'd like the graph to be created thru JavaFX and call it on a Java main class. Is it possible to add a JavaFX class to a Java project?
I'm using netbeans btw.

JavaFX for Java 7 is different from JavaFX on Java 8. My advice would be to go for Java 8. Then maybe NetBeans 8 too. JavaFX and swing/awt have different event threads, though under java 8 there seems to be a better integration.
JavaFX and java swing are two separate worlds. One might embed JavaFX in swing. Though if you are at the start of a basically new project, then you might go for pure JavaFX.
JavaFX uses "properties", wrapped values that can have change listeners on them / data binding. This separation from components makes dealing with the Model-View-Controller paradigm a bit nicer / different. JavaFX components themselves are a slightly more difficult, as swing provides a full API full of setters. It can be hard to make a column right-aligned for the first time. Another thing that makes JavaFX harder, is the use of callbacks with generic types, lambda expressions. Giving the correct signature not always is straight-forward.
So embedding JavaFX in swing might be a good approach if there is much swing experience or existing code: see
Embediing Swing in JavaFX (the other way around) and
How to Use JavaFX in Your Swing Application
If you mean, you have a NetBeans 7 Richt Client Application, then on the NetBeans.org there several small articles on JavaFX integration.

Related

Is JavaFX supposed to supersede Swing?

I am used to Swing programming and have heard about JavaFX. Is it supposed to replace Swing as the preferred platform for writing desktop applications in Java?
To put it in another way, should I choose JavaFX for my new project?
Yes JavaFX is replacing Swing.
See also official documentation of Oracle:
http://www.oracle.com/technetwork/java/javafx/overview/faq-1446554.html#6
Is JavaFX replacing Swing as the new client UI library for Java SE?
Yes. However, Swing will remain part of the Java SE specification for
the foreseeable future, and therefore included in the JRE. While we
recommend developers to leverage JavaFX APIs as much as possible when
building new applications, it is possible to extend a Swing
application with JavaFX, allowing for a smoother transition.
See also SO posts:
Swing vs JavaFx for desktop applications
https://stackoverflow.com/questions/1318645/javafx-or-swing (OLD)

Difference between Java Swing application & Netbeans platform Swing

I want to develop a simple desktop application that connects to the Java DB , using Java Swing for the interface design.
I am new to Swing so I tried some tutorials on the net and came across
the Netbeans platform Swing components.
What is
the difference between the Java Swing architecture and the Netbeans Swing components?
Which one will be appropriate for developing interfaces
for desktop applications in Java?
From The NetBeans Platform:
The NetBeans Platform is a generic framework for Swing applications. It provides the "plumbing" that, before, every developer had to write themselves—saving state, connecting actions to menu items, toolbar items and keyboard shortcuts; window management, and so on.
It is an API built with Swing, that is supposed to provide some extra 'built-in' functionality. Since you need to know Swing to be able to use it. I suggest you concentrate on Swing for now.
Actually, it will be better to move on Intellij Idea from Jet Brains. It’s much more better than NetBeans IDE. Of course, it’s only my opinion.

Java - Building GUI for application

I've written a lot of Java applications over the years, but the vast majority of them have been simple command line programs with only a few hundred lines and (at most) several classes.
My question is this:
How do I now design/code an interface to this application?? Where do I start? I mean are there any tutorials/resources which describe the steps involved?
I know Swing exists, but where do you start, and is it the only option?
Any help/assistance appreciated...
The rich client GUI toolkits for Java are basically:
AWT Sun's Abstract Window Toolkit was the original component kit for making GUIs, a toolkit based around using native components. AWT still contains the core of very important parts of J2SE GUIs such as Graphics/Color/Java 2D, Image & BufferedImage, printing, D'n'D..
Swing The current, main-stream desktop app. component toolkit. Swing generates the components internally, and allows setting a Pluggable Look and Feel to the GUI. Swing offers components & functionality not available in AWT such as JTable, JTree, support for formatted documents (e.g. RTF & simple HTML) in Swing components.. For more information see things that Swing provides beyond AWT.
Java FX 2 Intended as an (eventual) replacement to Swing, AFAIU.
SWT is another choice, not written by Oracle, uses natives. I would not recommend it for someone learning rich client programming, since it is a lot easier to get answers in relation to Swing.
You have to learn core GUI API java.awt and its sub-packages along with (extended API) javax.swing and its sub-packages. You may start - The Java Tutorial.
No, Swing is not the only option but it is where you should start. Swing is the "new and improved" version of some of the GUI objects in java.awt. Most of the Swing objects build off of their AWT counter parts our are completely new. Both Swing and AWT are a part of the core Java API so it would be best to start with the tutorial that AVD linked you to (The Java Tutorial)

Desktop GUI framework

I tried to create a new Swing GUI desktop application template using NetBean 7.0 and just found NetBean has a disclaimer:
"Note that JSR-296 (Swing Application Framework) is no longer developed and will not become part of the official Java Development Kit as was originally planned. You can still use the Swing Application Framework library as it is, but no further development is expected."
So does it mean swing will stay the same from now on and nothing new will be added? What will that impact the applications using Swing? Do I need to consider other GUI frameworks instead? What would be the best framework option for a scientific plotting and graphic heavy application?
Thanks.
Swing is part of JAVA since 1.2 and it is part of the JAVA STANDARD. It is not going anywhere any time soon.
The JSR-296 (Swing Application Framework) was a framework to simplify and help developing in swing, which didnt go very far. Netbeans uses it internally. If using JAVA 7 then, like many other netbeans specific libraries, you need to ship it separately with you app, because it is not standard.
So, feel free to develop in swing. A pure swing app WILL WORK on any JAVA STANDARD on almost any platform for a long time to come. If you use the SAF, thats also OK, but that is not standard and its pretty much dead, so just remember to ship the jar with your app.
Hope that clarifies the situation.

How do "professionals" make a GUI in java?

Thanks for your answers to my previous question about GUI in java. I now wonder what are the solutions chosen by professionals to get a nice GUI, for "real" applications. Do you use swing and JComponents and just change the "look and feel" ? Do you prefer awt or another library ?
Sorry if that question sounds weird, I'm a student and I don't really know how java is used in the real world...
In our company we use Swing, as that is supported by the JVM out of the box, but we do use color coded background colors for some panels and buttons.
If we'd use something different, like SWT or Jambi we'd also have to roll out those frameworks for all platforms, and test those frameworks for all OSses and (supported) java versions. Not nice at all.
It is however fairly tricky to create a nice responsive application with Swing; so you really need to use SwingWorker and the like. With a bit of experience however you can create a nice application that way.
And even if it isn't the fastest framework to develop in, development time is really small compared to defining the functional requirements of the user interface, and testing and support when the version is released.
That said, our target is desktops. If you target mobile devices or also need a web frontend your choices may vary.
I don't believe anyone prefers AWT anymore. Swing supplanted it entirely eleven years ago, building on top of it to correct flaws in the AWT 1.0 design.
Swing isn't the only way that professionals make Java UIs. That works for desktops, but there's also JavaFX now. For the web, UIs are built using HTML, CSS, JavaScript, and JSPs.
My experience is that most organizations that want to create rich GUIs still use Swing, and manually go through all the annoyances of layout managers, etc.
The use of SWT is fairly limited to organizations that are using the Eclipse RCP as their platform. I'm not sure why it hasn't caught on outside this platform.
It's sad to admit, but Java Swing GUIs don't generally look good unless you spend a lot of time creating a more native feel for them. Even then, they often lose out on aesthetics to equivalent programs written specifically for Windows and which use Window APIs like WinForms.
The most decent Apps I saw in the last years were build using Eclipse Rich Client Platform
Eclipse uses the Standard Widget Toolkit
and provides Graphical Editing Framework (GEF)
We typically use Swing becuse it's supported in standard JREs out of the box. Normally we do the initial form design and event hookup in Netbeans and then export it to whatever we wish, Eclipse, for example.
Netbeans spits out pure Java using standard libraries (plus a jar or two you have to include) so it's no big deal designing the form in Netbeans and later moving on to something else.
Some people suggested doing form layout by hand using a layout manager. I see that as an option only if you are doing something big and very well budgeted that has to be maintained ad infinitum. Otherwise it's just too time consuming to be worth it.
We rely on SWT for our Java GUIs. Yes, you have to include an external native library, but the look and feel is native, more responsive (although Swing has become much faster in the past few years) and seamless with other apps on the target platform.
Macintosh OS X creates their own Java runtime. They give Swing components the same look and feel as native applications.
I use strictly Swing. I distribute "real" desktop applications via Web Start for both Mac and Windows that interface with the user's smart card reader.
The NetBeans IDE gives you a WYSIWYG way to create your forms. I've tried it out, and it's pretty neat, but we still use Eclipse as our IDE and design the forms in code.

Categories