Till now, I was using VB for developing applications. Now I have to use Java for developing the front-end. I am quite confused with the Components. Need help.. A book reference or site reference would also do the job.
Basically, I will be using MenuBar, ToolBar, a Frame with JEditorPane. Now if I want to use a small window which will be a child form, to write some notes, of the master frame, which Component should I use?
I guess you're looking for a JDialog or a JPanel. Follow the Swing tutorial. It has detailed guidelines for every component, and has a visual index of all the components.
You can use a JInternalFrame for this. Follow this link for a demo
Components are quite easy to understand. A detailed tutorial is given here. But to tell you the gist Components are nothing but containers. For example JPanel is a component which can hold another component for example a JButton. Since JButton is again a container, you can add one more component, a JPanel to it.
The order and placement of the components that you add are determined by layouts. You have different layouts viz Borederlayout, BoxLayout, Flowlayout, GridLayout, GridBaglayout each having its own pros and cons and behaviors on how it reacts when window is resized.
For an IDE, I would recommend using Netbeans as you can drag and drop components as well as take a look at the generated Java source code to get a better understanding.
You want to the develop desktop applications using java right?
You need:
-Installed JDK(Java development Kit)
-You will need an IDE. My favourite is Eclipse.
There are many out there, but maybe the most intuitive for beginners in java might be Netbeans.
-When creating applications that use the components you mentioned, you will be using the libraries in the pagcage javax.swing(See the documentation in the link)
-And finally, just one more suggestion(Optional), is to get also a most powerfull IDE, just for graphics, so you can speed up your programming.I suppose you would like to speed up your development. In that case i highly recommend you this tool: JFormDesigner
Watch the videos and in matter of a couple of hours you will be developing interfaces fast as light :)
I hope this is useful
Related
I have a rather large Java application that uses Swing extensively. The look-and-feel used by the application is Metal and we have a custom theme that lightens some of the colours. I'm building a new component within this application (it's a large project that will deploy in a few years) and would like to use JavaFX for all the GUI parts (several reasons, including being a little more future proof, better APIs, and new widgets I would like to use). However, I don't want to upset the common look-and-feel of the application.
Is there any way (aside from writing lots and lots of my own CSS) to make all the JavaFX components look like the Swing components?
To get a Swing Metal look in JavaFX, start writing lots and lots of your own JavaFX CSS. I know it's not the answer you want, but it is the answer that is.
You could put put the JavaFX components that you need inside the Swing Components. For example, you could put a JavaFX ImageView inside a Swing panel. That way, you get the Swing look (and compatibility) on the outside but the JavaFX functionality on the inside.
I found this tutorial helpful:
https://docs.oracle.com/javase/8/javafx/interoperability-tutorial/swing-fx-interoperability.htm
But other than that, I don't think JavaFX has a look and feel identical to metal.
I need a new way to create the graphical user interface of my application. I don't want to use Swing. I'm looking for something that looks a little different. Can you recommend me some other way of creating it, please?
Why not JavaFX ?
It is supposed to be replacing Swing as the standard Java GUI builder, so it would be a good option as it will be getting regular updates from Oracle itself. Additionally, being an officially sanctioned kit, it has plenty of tutorials, guides, and a decent (and growing) userbase that you can use for help.
And it uses CSS, which is good to learn as it can be useful in other applications. (Webdesign, etc.)
Finally, JavaFX is included with Java 8, so you don't even have to worry about installing a separate package! (Although adding a package is really not difficult if you prefer Java 7 or below.)
If your complaint with Swing is how it looks, note that you can change the look and feel of a Swing application very easily, or even write your own if you really wanted.
To get a look and feel that matches other applications on your system, you call:
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
At the beginning of your program.
The default L&F, called Metal, also has a couple themes you can choose from (or you can create your own):
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
Yes, javafx could be the way for you.
You can create Views using FXML files instead of coding everything in java.
The learning curve is not too hard in my view (and I am far from being a guru).
The tool Javafx Scene Builder is here to help you create your views or controls in FXML and integrates nicely with netbeans, and I suppose also with eclipse.
You can adapt the look of your controls using css.
I would suggest to start here to see if it would fit your need:
http://docs.oracle.com/javafx/2/overview/jfxpub-overview.htm
I'm a .net developer and I am studying Swing for Java and I have a question.
Is there any way to build the form controls by dragging and drop like a simple .net windows application project or WPF project?
I am using eclipse and it seems that everybody works with controls by adding positioning and width, height by code, I find that a pain in the a**.
Yes! Take a look at Window Builder for Eclipse (install it from the update site). Netbeans has also a built-in editor, if you prefer that IDE.
You need to install a plugin to do that.
In Eclipse you can try WindowBuilder.
In Netbeans this ability comes within the standard package.
Java's Swing framework tries to address a broad set of platforms, and it does this by separating out look-and-feel concerns, layout concerns, etc. The most painful part of setting up a form is the layout, and that is driven by the LayoutManagers.
There are various LayoutManager implementations built to be used in conjunction with form designer tooling. I've personally had good results with IntelliJ's designer. See some screen shots and feature listings here.
I would personally not recommend using any Drag and Drop builders. In some IDEs the generated code is not editable. Some IDEs allow you to edit the code, but the bottom line is no matter what IDE you use the generated code is very difficult to maintain. After a while you will find it difficult to work with it yourself.
Instead, since you are just starting out, I would recommend using a good layout manager right away. While we are on that, give the jdk's layout managers a wide berth. They are horrible and that's what causes most people to go in for the drag and drop solution. Instead try the Jgoodies Form Layout. Its very easy to understand and use. The link is here:
http://www.jgoodies.com/freeware/formsdemo/index.html
After you have understood that, try to give this builder I wrote a shot. It makes life even more simple:
http://code.google.com/p/swingobjects/source/browse/SwingObjects/src/org/aesthete/swingobjects/view/SwingObjFormBuilder.java
I cannot find one online and I am surprised there isn't one... but is there an online Java GUI Layoutmanager at least?
WindowBuilder for Eclipse is phenomenal. One of the things that awesome about it is that you can hand modify its' generated code and it will pick that up without a problem.
What do you mean by an online GUI builder? If you want one that's a webapp, it's not likely you're going to find one.
If you're looking for a GUI to build a GUI, I would recommend the Netbeans IDE. I forget where it is exactly in the IDE, but you can basically just do file->new->java-gui (or something of the sort) and you will get a very nice interface for constructing swing gui's.
How do I extend a simple InputDialog in an eclipse plugin to put additional checkboxes, radio buttons, etc?
You need to create your own dialog box. You do that by using SWT, the Eclipse UI framework. If you are a good Java coder, the best thing you can (IMHO) do is look at the SWT code snippets.
Another option, perhaps better one, is using JFace. It is a framework built on top of SWT. JFace makes it easier to build the UI and it works with SWT without hiding it. You can find many code examples of doing dialog boxes with JFace here.