Creating a simple gui in java for running a background process - java

Well, I had this question in mind for a long time.
Even though I have a complex requirement,i will keep it as simple as possible.
I have background process which takes two arguments which I use to execute from command line.
The first argumets can have three valid values and the secong argument can have two valid values.
I usually run that process on command line in solaris unix.and that process is completely coded in C++.
What I want now is I wish to create a simple gui in java for running the process in background.
I am complete new to the advanced concepts of java, and I am aware of some core java which I studied in my college days.
So,My question overe here how do I start creating a gui?
What all do I need to create a simple gui using java?
I am confident enough to learn gui programming in java as I am a c++ programmer.
Please give me some right directions to give some life to my thought and any some good materials available on the net would be helpful.

I would start by looking at;
Creating a GUI with Swing
Concurrency in Swing
Concurrency in Java
I'd also become familiar with ProcessBuilder (a simple example) and Basic IO
MarvinLabs also makes some great points as well

The Google search you'll want to use is "java swing tutorial". Swing is Java's GUI library.
You can also have a look at: Java GUI frameworks. What to choose? Swing, SWT, AWT, SwingX, JGoodies, JavaFX, Apache Pivot?

You really just need a JFrame and a JPanel. The JFrame is the physical window that the gui lives in, while the JPanel is the content manager. You place JComponents (e.g. JLabel, JComboBox) into the JPanel.
Java Api: http://docs.oracle.com/javase/7/docs/api/
Examples of using each component: http://docs.oracle.com/javase/tutorial/uiswing/components/index.html

IMO, you may try using JavaFX 2.1 to develop your GUI in java. It has Scene builder tool to design your application, built-in support css-like skin.
Check the concurrency in Javafx 2.1 here.

Related

How do I create an interface with buttons and text?

I've tried different ways of creating different interfaces and applets. One of the main things I'm trying to do is to get these gui's to display text and show multiple buttons with different text leading to different outcomes. What I'm asking is, what code is necessary to create an applet or an interface (because I fail at telling the difference between the two) and how should I approach building and structuring that.
I recommend you use netbeans because it has an editor and is the easy way to create Applet.
https://netbeans.org/kb/docs/web/applets.html
You have three main choices I can think of, others will for sure think of something else:
Create a web server and actually serve a web site with your interface. You can code the interface yourself and communicate with your java server using ajax, you can let GWT among others do that for you. COnsider also frameworks like Struts
Create an applet which will become an embedded object in a web site. This is quickly falling out of grace, and I'd strongly discourage you from doing it, if only because of the pains of java plugins in the browser
Create an application with an interface by using AWT or Swing (which come with Java) or, and this is my personal opinion, more elegantly with SWT
It's hard to tell what will best help you without knowing more of your requirements, but if you are going web, I'd suggest you check out GWT, and if you are going desktop app, look into SWT. Also, please understand these are all well tested frameworks and my preferences are just that, preferences.
To create an interface in eclipse using java you can use swing.
In eclipse:
Create a new Java Project (File -> New -> Java Project).
Right Click on src folder and click New -> Other -> WindowBuilder -> Swing Designer -> [Application Window]/[JApplet].
Add the components that you want (buttons, textfields...).
Seems to me like your trying to graduate from console programs to GUI programs. A GUI works differently from a console program. A console program you have a bunch of loops and if statements, but a GUI program work completely differently. The main difference is that GUI programs are event driven.
With that being said, you want to choose a GUI framework, like Swing. Then decide if you want your application to be web based or desktop. An applet is more for web. If you want a desktop program, then you want a JFrame which will be the top-level container of your application.
You can learn all the components that are available to you in the standard Swing API here. IMO it seems like you need to start from the beginnging, so I would start from the very being of How to Create GUIs with Swing. You will want to pay close attention to section on Writing Event Listeners
If you do want to create an Applet instead of a desktop program, you can see the Applets, where you'll learn how to develop Applets and how to deploy them. You will still need to learn some basics though from the Swing link I mentioned.
Also, before you start using drag and drop gui builder tools, I would strongly urge you to first learn to hand code. It will work best for you in the long run.
I hope this gets you started in the right direction.
The defacto world standard GUI for all platforms is becoming Html5 and css3.
So the easiest way for you to write an interface is in HTML. You don't need an applet unless you have real specific needs like having a constant connection to the server for a chat or whatever. Anyway most of the applet reasons to exist are now resolved in standard HTML. If you want to learn a new langue, try Dart (dartlang.org)
You could use dart to have the more adaptable GUI to standards in the world
I explain why in this blog post
http://1veu.blogspot.com/2013/12/why-i-think-dart-will-detrone-java.html
Naturally even if you need to write a stand alone application with native GUI, HTML5 and css3 are still widely employed along with webkit or native code transformers like PhoneGap.

Creating JFrame

We can create Java GUI based application using net-beans IDE and also we can create it using Notepad . Using netbeans or eclipse it is very easy . But I saw every where that every one used notepad. So I just want to know that the best way for create Java GUI application.
Its better preferring some IDE like Netbeans , Eclipse since because, you can consume time in creating the gui by utilizing the features like drag and drop, in-build function support suggestion which proper demonstration of usage and syntax.
If you are developing gui from scratch using notepad, it may takes more time, one developing things in that way should be thorough knowledge in syntax and all other functionalities
The Java Tutorials on Swing are a pretty good resource. If you don't like hand-coding your UI with Java code there are several GUI builders out there where you can lay out your UI visually and just fill in the behaviour in code-behind. E.g. Netbeans has such a thing and there is WindowBuilder for Eclipse.

Genome browser built in java: Swing and awt or Swing and Processing?

I'm writing a genome browser designed primarily to view the history of chromosomal rearrangements. Right now the project is a series of proof-of-concept demos written using Processing. At this point if I don't make any radical changes the final application will be a web applet with a gui built of swing components that open PApplets to actually show the rearrangements happening.
My question is: Should I give up on processing and switch over to pure Swing/AWT? This is my first big java project. I'm building in eclipse, but I can use netbeans as well. If I could embed PApplet objects inside a JFrame, for example, that would make my day.
processing.core.PApplet extends java.applet.Applet, so it should be possible to embed
a PApplet in a java.awt.Frame, as discussed in the article Applet ⇒ application: Hybrid Switch Hitters. See also, Mixing heavy and light components.
Addendum: From the API, "Processing runs in a Frame and not a JFrame. However, there's nothing to prevent you from embedding a PApplet into a JFrame," except for the limitations mentioned above.
Keep in mind that I know almost nothing about either Processing or your project, so I can only give you general advice.
The question that you should ask yourself before every major design change: what problem am I trying to solve by making this change? If the current architecture works, then you should keep it. If it's not working, then you should start by defining the specific things that are wrong with it (which I notice you didn't do).

Swing Menu that can be customized by user

Is there any framework or lib out there to create a Java swing menue that can be edited by the user via drag and drop?
Added: Implementing a polished solution myself can take a lot of time. What i would like to see: display the entry while dragging, opening submenus automaticially, showing a line where the item would be placed when releasing the mouse. Actually like the windows startmenu in XP. This would take a lot of time, i am still hoping to find framework or a subclassed Jmenu with these features.
You can implement drag and drop on most (all?) Swing components. See this tutorial to get started.
Update: based on your updated question. have a look at JFrameBuilder (note that its not free).
JFrameBuilder is an easy-to-use visual Java GUI builder.
JFrameBuilder provides the application GUI solution for Java developers. It enables Java developers to create sophisticated Swing GUI applications using drag-and-drop interface without spending a lot of time writing code.
Personally I find it a lot simpler to write pretty UIs in SWT (the toolkit used by Eclipse), it has more access to the underlying OS and provides a richer experience that's closer to what you're after in my opinion. Here's a guide to implementing drag and drop in SWT.

What Java GUI framework is good for a first GUI project?

The title description basically says it all. I'd like to use something that requires a relatively short learning curve since it is my first project and I'd like to spend at least some of it actually writing the code, not just learning how to do it, but also something that has good documentation in a way that some new bleeding edge framework probably wouldn't. Any ideas?
If what you want to do, is actually create a working program with a GUI, and you just want to do that I would recommend looking at the Swing GUI editor in NetBeans, as it is very easy to work with and powerful too.
There is an old demonstration floating around showing how to implement a preference panel like the one in Netscape Navigator (the predecessor to Firefox), but I cannot find it right now.
The Java tutorial trail is here: http://java.sun.com/docs/books/tutorial/uiswing/learn/index.html
EDIT: It appears the preference panel demo has been taken offline. You may want to see this demo for NetBeans 6.0 instead: http://www.javalobby.org/eps/matisse-updates/
It's not clear if you mean a desktop or Web GUI.
For a desktop GUI, just use Java's Swing framework. Creating a GUI With JFC/Swing is a starting point for that. Sure it's old but then again so is Swing. You could also try The Java Swing tutorial.
For a Web GUI, start with servlets/JSPs. Try Servlets and JavaServer Pages (JSP) 1.0: A Tutorial.
Swing + MiGLayout ^^
I know you did say you wanted a simple and easy to learn GUI toolkit. #cletus has nailed that answer :)
But if need to look for alternatives and evaluate them before you decide how to write a GUI, check out this list of alternatives to Swing and AWT.
Swing + GroupLayout
I've been posting on these a couple of times.

Categories

Resources