Swing Renaissance - Cool Java UI Examples

These days, there are two popular toolkits for building graphical user interfaces in Java: Swing (from Sun) and the Standard Widget Toolkit (SWT) (from IBM/Eclipse). Different developers often have strong opinions about which is best, but in truth they both have their strengths.


Swing, part of the Java Foundation Classes (JFC) first introduced with Java 2 (J2SE 1.2), is the “official” (if you will) GUI framework for Java. It’s built into the desktop version of Java (J2SE). Swing’s approach is to make user interface components (widgets) as customizable and extensible as possible without sacrificing cross-platform consistency.

To do this, it avoids using the operating system’s built-in widgets and instead uses pure Java code to draw the user interface in blank windows and respond to interface events.

The upshot of this is that all of its components are fully skinnable, and can be extended with custom appearance and behaviour. The downside is that the user interface often doesn’t quite match the look and feel of the native operating system (although Sun is getting better and better at this). Additionally, the API can get quite complex as soon as you want to do something not-quite-standard, because of Swing’s amazing flexibility.

Also, because of Swing’s complexity, it’s easy for beginners to do things “the wrong way,” producing applications that work but seem slow or unresponsive while responding to user requests.

Because Swing is built into Java, it’s ideal for situations where application size must me minimized and cross-platform deployment must be completely transparent. For this reason, Swing remains the best choice for Web developers who need to build applets or applications launched via Java Web Start.


From the application developer’s standpoint, SWT is a much simpler API for building GUIs in Java. Instead of avoiding the operating system’s native user interface features, it embraces them, making use of native widgets to provide optimal performance and ease of coding. SWT was first developed for use in the Eclipse Project, but developers have since harnessed it to build all kinds of desktop applications.

The upsides of SWT are clear: it’s an easy API to write for, which means you can produce impressive results more quickly, and because the widgets are all handled by the native operating system, users will find the interface appearance and behaviour completely familiar. It’s also easier to achieve good interface performance (i.e. response time) with SWT.

Depending on the type of development you do, the downsides of SWT are either insignificant or deal-breakers. It is difficult and usually impractical to extend SWT widgets with custom functionality. Because SWT makes use of native operating system functionality, an SWT application must be bundled with native libraries that interface with the operating system on which the program will run. This means you’ll usually have to distribute different versions of your application for Windows, Linux with GTK, Linux with Motif, and Mac OS X. Due to the size of the libraries, it will usually be impractical to deploy applets that use SWT, and support for Java Web Start is problematic.

Swing’s Renaissance

Although for awhile it seemed Swing was standing still while SWT, the new kid on the block, got all the attention, Swing is experiencing a renaissance as curious developers explore the range of customization and eye candy that can be implemented with Swing UI components.

Here are a few of my favourite examples:

  • Creating a custom UI delegate for JTabbedPane
    Implements Adobe-style “mini-tabs”, demonstrating how easy it is to change the look and feel of a widget without implementing an entire look and feel.
  • Data Tips
    Slicker than most native implementations, displays the full label for a list item on mouseover when it is clipped by the list width.
  • Help Your Shelf (waiting dialog for Swing)
    Though a little gratuitous, this example only scratches the surface of the kind of eye candy that can be achieved by blending Java2D effects with Swing components.
  • Swing in 3D
    If only to prove that there are no limits, this example shows off a Swing look and feel that appears in 3D when viewed with 3D glasses!

An excellent place to watch for the latest practical and not-so-practical Swing experiments is the blog at ClientJava.com.


Category: java Time: 2005-06-14 Views: 0

Related post

  • Synchronized statement, unclear java doc example 2015-06-05

    Currently I am trying to understand synchronized in Java getting to this java doc example under synchronized statements the example with the class MsLunch and the two instance variables c1 and c2. It states: Suppose, for example, class MsLunch has tw

  • Java Spring Example Web API 2015-09-17

    I'd like to get some feedback on an example web API I've put together. It's mavenized and available on GitHub here. Setup The only thing you'd have to change to run this locally is line 31 in src/main/java/com.example.config.PersistConfig.java: Strin

  • java desktop example user agent flow OAuth 2012-11-20

    We would want to use the user agent flow for our desktop application that we connect to Salesforce via the REST API. Does anyone have somewhere a working java example of this or point me in the good direction with more information on how this works f

  • Where can I find Java FuelSdk Examples? 2014-09-05

    Where can I find a reasonably complete Java example for connecting to ExactTarget and updating a Data Extension. It isn't in the documention. I've looked there already. ET just says its coming. Does anyone have simple examples they can share? -------

  • how can i make good swing interfaces using java? 2016-02-07

    i am creating a desktop application with java swing,the job is done,but my interfaces look not good, so much gray colors(the default color of swing),i want to make professional interfaces, like web interfaces,is there any library to add that helps me

  • Simple Java animation with Swing 2013-08-12

    I am learning to use Java Swing and have made a simple animation that makes a small shape bounce around the predetermined borders of a panel. The program works well, but I am looking for feedback in terms of quality and any improvements or alternativ

  • Number-guessing game in Java with Swing UI 2013-10-02

    I am trying not to pick up any bad habits while improving the way I write programs. Any suggestions on the following lines of code? package guessGame; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.A

  • Windows 8.1 Swing (Java) applications text rendering 2014-04-14

    The other day, I searched for a free UML editor tool, and as it turns out the best of them are implemented using the popular Swing framework, in Java. As it turns out, Windows 8.1 has some serious problems with text rendering for Swing applications.

  • Simple calculator in Java using Swing and AWT 2015-06-04

    I wrote a simple calculator with general operations. Give me please some advice, suggestions, and criticism about my code: code design, readability, mistakes. Calculator.java import javax.swing.*; public class Calculator { public static void main(Str

  • Click! program in Java Swing 2015-07-03

    I've created a program where the user is, at first, presented with a window with a yellow circle (random size, random coordinates) and a Start button. Once the user presses Start, the circle, when hovered over, will turn red in color and when it is c

  • How to make the movements of rectangles automatic in java swing? 2016-01-27

    Below is my code for a java swing game: You can see how it works, if you run it. You can shoot at last 10 balls to hit the small squares ang gain 20 scores to win, otherwise you will loose. The upper square should be thrown down by hitting balls, and

  • How to switch between JFrames in Java Swing? 2016-02-02

    I'm new to Java Swing and Window Builder, and I'm trying to switch or "change" to another JFrame or window when I click a JButton. First window: import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JButton; import javax.swin

  • Should Swing knowledge be required from Java programmers? 2011-03-01

    Swing is an integral part of the Java API. It is also the most popular GUI framework for Java. I still wonder, should every Java programmer still know, or at least be pretty familiar with, Swing (possibly excluding web developers)? There are alternat

  • Basic Calculator in Java with Swing 2014-03-31

    I used a standard calculator design from Java. I wanted to expand it so I created a class to create buttons for different operations, like +, -, *, /. The original program didn't do this, they just made them individually without a template method. Do

  • "Guess my number" game in Java Swing 2014-05-03

    Also posted at rgcsm.info/blog //Number Guessing Game in Java Swing //Also posted at import javax.swing.*; import java.awt.*; import java.awt.event.*; class Guess extends JFrame { JTextField t1, t2, t3, t4; JLabel j4; ButtonListener bl1; ButtonListen

  • Java Swing JFrame doesn't work in Ubuntu 2015-02-07

    I wrote the following program in Java: import javax.swing.*; import java.awt.*; public class Main { public static void main(String[] args) { JFrame frame = new JFrame("Test"); frame.setSize(new Dimension(800, 600)); frame.setVisible(true); } } H

  • Java Swing JPanel FlowLayout Height Issues 2016-01-14

    I'm busy writing a Java Swing GUI and I need two JPanes Side by Side. I have a Single JPane that I am using as a Parent JPane which holds two Child JPanes that are sitting side by side each one with a border for separation. Each Child JPane has a JPa

  • Java swing application doesnt start 2016-01-15

    I wanted to write an calculator to view the average grade, but it doesn't start. It's written with java swing as you can see, help would be appreciated. The main class: package me.imfrozen; public class TheMainClass { public static void main(String[]

  • How to read maxim iButton via usb in java swing app and display serial number 2016-01-21

    I am trying to make a java based app to read write and erase ibutton.I have made the front end using netbeans.I don't know how to read ibutton in my java app.Below is code of the 1st frame where I want to read ibutton serial when ibutton is connected

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.791 (s). 13 q(s)