Information about swing components (java) - java

After learning python (cpython) and using this page to search for tkinter widgets' options, methods and patterns, I've started to develop in jython due to javax.swing module from java which can help me make platform-independent GUIs.
My question is: is there a page like the one I mentioned above which presents the options and methods of swing objects?

is there a page like the one I mentioned above which presents the options and methods of swing objects?
Yep (at least on a class level).
Have a look at the package summary for javax.swing (part of the API documentation):
Package summary: javax.swing
Also, here is a page with screen shots of most of the standard components:
A Visual Guide to Swing Components

Related

Methods of styling GUI components in java

I'm creating a user interface for a java standalone desktop application but the forms, text fields and tables I built using javax.swing and java.awt packages look quite dull. Are there any methods by which these components can be stylized so that they look more appealing (like those beautiful websites made with css and javascript) ?
You can set the background, border, foreground, etc of these components. Consult the API for useful functions.
Or you can change the look and feel of your entire program. Recommended reading: http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
You could use Look and Feel, there are libraries that set your all your components with a defined style.
See this link http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/nimbus.html

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 a simple gui in java for running a background process

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.

QStackedWidget equivalent for Java Swing

I am porting a small qt app to java and i was wondering if java swing has an equivalent to Qt's QStackedWidget.
This QStackedWidget?
The QStackedWidget class provides a stack of widgets where only one widget is visible at a time..
See CardLayout, as shown here.

Is it possible to make a visually appealing GUI with JavaFX & Swing?

I would like to do a visually appealing / user-friendly GUI in java. Swing is a limited in terms of "skin" customization. I'm thinking about JavaFX, but I don't get it yet,
what can I achieve with this technology ?
how hard is it ?
do you have examples of real-life examples of Swing/JavaFX integration ?
I would like to do something in this spirit of this, which is built on the .NET framework:
original link: http://www.patrickpayet.com/net/?p=329
edit: is their any getting started overview sample code that I can read to get a general feeling of the work needed to be done to achieve something in the spirit of the screenshot? maybe something like the miglayout's swing demo http://www.migcalendar.com/miglayout/swingdemoapp.jnlp
edit2: I found http://download.java.net/general/openjfx/demos/tutorial.jnlp it's really basic though, linked from http://www.deitel.com/ResourceCenters/Programming/JavaFX/JavaFXTutorialsandDemos/tabid/2187/Default.aspx
Doing such a GUI with JavaFX seems to be rather easy.
For a rapid view on the JavaFX echosystem, I would suggest you to take a look at those sites, showing most of the bleeding edge JavaFX technologies :
Jonathan Giles blog on Swing/JavaFX/Griffon
Dean Iverson blog going more in details about JavaFX components
Amy Fowler blog
And finally, take a look at JavaFX home site samples.
Yes, Swing is very customizable. I recommend reading Filthy Rich Clients.
For an example, have a look at Cezanne L&F.
Swing alone can also create awesome looking UIs. You can explore online for number of plugins and samples to add various features. I'd recommend you go through Romain Guy's Blog & Read his book Filthy Rich Clients. I found this blog really cool.
Swing won't disappoint you.
Swing's L&F can help you in this case.
The traditional way to customize L&F is to write your own UI classes for all components, which is not easy.
The Synth L&F is included in JRE5 and become mature in JRE6. With Synth L&F you can customize your own look and feel with images and painter classes. You can also take a look at this IDE for Synth based L&F.
Also checkout my entry to the JFXStudio challenge last year:
http://jfxstudio.wordpress.com/2009/11/10/challenge-five-winners/
This is a very simple "Video Poker" game written in just less than 3,000 characters (ie 30 lines of code). Note that 90% of the graphical elements are images, which gives you an idea of the scope you have for producing "sexy" UIs.
I'll also add that the main elements of this application were written in one evening. JavaFX is a very powerful tool for UI creation once you get used to it.
Yes, you can do that with JavaFX by writing your own CSS files. Learn more at: JavaFX CSS Documentation
It is actually not that hard if you are familiar with CSS.
you can get colorful original GUI with LookAndFeelMetalizer.
For example phoyo was done with it.

Categories

Resources