Do I have to learn AWT before learning Swing? - java

If I want to code an desktop application in Windows with Java, should I buy a book about Swing and just skip reading books/tutorials about AWT?
Or do I have to learn AWT before using Swing?

Just go straight to Swing.
Ignore awt.
There is no benefit getting your head around awt, as Swing is essentially a replacement for it.

There's really no point in learning AWT first. Swing replaces a lot of AWT's concepts and components, but integrates many others unchanged (such as layout managers). If you learn Swing, you'll learn those parts of AWT that still matter (and how they are used in Swing) pretty much automatically.
Sun's Swing tutorial is a pretty good starting point.

If you're doing this for yourself (and not part of work), might I suggest trying out the Qt or Gtk Java ports?
I don't know much about the Gtk one, but the Qt one is called Qt Jambi, and it's development is currently community driven, LGPL licensed. I've used both Swing (in Java) and Qt (for C++ apps), but if I ever had to develop java desktop applications again, I'd definitely give Qt Jambi a look before I decided what to pursue.
As for the Swing vs AWT - Swing straight away I would say.

Well, Swing is richer in terms of out-of-the-box components than AWT. I have used both, and i prefer Swing over AWT. Also, you do not need to learn AWT to learn Swing basics.Sun's Swing tutorial
is a good source to start learning Swing framework.

As other answers have already mentioned there is no need to learn AWT and you can
get your GUI coding with Swing alone.
As you develop your GUI code invariably you will bump across some
AWT class (for example java.awt.event.ActionEvent) and you can comfortably use it by reading
its API documentation. However your application need may make you to use a layout manager
like GridBagLayout(java.awt.GridBagLayout), in which case you may have to study the layout manager
documentation bit more in detail. I found this book on AWT Java AWT Reference, which is available online freely, to be quite useful when I needed to dig a bit more in detail about layout managers.

There is no need to learn AWT before learning Swing.
Net Beans is a good IDE to learn Swing.

Related

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.

What are the Java GUIs

I'm too far from Java technologies.
Just for curiosity what is the name of the technology/API/class which let us develop desktop applications with Java (like windows forms)?
I heard a toolkit named Swing. Is that the official GUI toolkit and is there any alternatives of Swing?
Is there a technology in Java corresponding to WPF of C#?
Java Swing is the most commonly used GUI toolkit for Java. There are alternatives (JavaFX, AWT, SWT), but Swing is a very good starting point if you start devolping desktop applications with Java. The only thing I would consider is looking at alternative LayoutManagers like MigLayout. But you can easily begin with the standard ones. There is a great visual guide to start off with Java Swing and the various LayoutManagers.
There is AWT, Swing, SWT, JavaFX, Android GUI.
The most common is Swing and while its not the prettiest, I would start with that unless you have specific requirements.
Java FX 2.x demo http://www.oracle.com/technetwork/java/javafx/samples/index.html
Java has the following options for GUI development:
(1) AWT
This is the old GUI development library
(2) Swing
This is the new GUI development library
(3) JavaFX
This is the latest GUI technology of Java,
it comes with FXML for fast UI development.
FXML is not compatible with XAML of .NET, but it can be considered equivalent.
Yes, Swing is the official GUI toolkit of the Java Runtime Environment.
in Java you can use many differen GUI technologies.
Swing is one of the technologies you can use. It is lightweight and it is the offical toolkit for Java.
Furthermore you can take a look at SWT, AWT or JMonkey for 3D stuff.
What do you mean with similar with WPF? The MVVM Pattern?
Something similar to Silverlight but better is the GWT Toolkit.

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)

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.

Has anyone got an example of aerith style swing mixed with GUI maintainability of SWT editing?

My boss loves VB (we work in a Java shop) because he thinks it's easy to learn and maintain. We want to replace some of the VB with java equivalents using the Eclipse SWT editor, because we think it is almost as easy to maintain. To sell this, we'd like to use an aerith style L&F.
Can anyone provide an example of an SWT application still being able to edit the GUI in eclipse, but having the Aerith L&F?
Like Heath Borders said, SWT doesn't support L&Fs, so you have to use Swing for that. Aerith however does not base on a look and feel, but on custom painting on the components with a lot of gradients.
If you are looking for a Swing GUI Editor that is (nearly) as easy to use as VB, try the Matisse GUI Builder in NetBeans. There is also a version for Eclipse, but it is shipped with the commercial MyEclipse. If you want to learn more about writing apps with cool a cool GUI, have a look at the Filthy Rich Clients book by Chet Haase and Romain Guy.
If this does not convince your boss, try to resize the VB GUI and then resize the Swing GUI. ;-) And I would say a VB is really not very good to maintain in the long run...
SWT doesn't support look & feels. You can get different L&F's by altering your OS native L&F. The only exception is to using the eclipse forms toolkit. It still has the OS native feel, but strives for a web-browser-like look. It does this mostly by setting everything to SWT.FLAT, and using white backgrounds on everything. Occassionally, they have to manually draw outlines around controls that don't natively support it. If you're looking for custom L&F's that will appear across platforms, you really want Swing.

Categories