We may earn an affiliate commission when you visit our partners.
Course image
John Purcell

This course teaches you how to create desktop and web-based applications using Java Swing, Java's built-in user interface toolkit. Each tutorial is fairly self-contained; but we'll also build two complete applications step by step along the way, so you can choose either to work through the whole course or to dip in and out.

Read more

This course teaches you how to create desktop and web-based applications using Java Swing, Java's built-in user interface toolkit. Each tutorial is fairly self-contained; but we'll also build two complete applications step by step along the way, so you can choose either to work through the whole course or to dip in and out.

Among other things we'll look at nearly all Swing widgets, we'll take a look at JDBC for database access, the graphics API, model-view-controller (MVC) architecture, serialization for saving data, the listener-event model and even basic animation.

When you finish the course, you'll be an advanced Swing developer, capable of creating complex and scalable Swing GUI applications.

Enroll now

What's inside

Learning objectives

  • Learn how to write gui (graphical user interface) applications in java
  • Understand the java swing framework
  • Discover how to create database applications

Syllabus

Desktop Applications

This is an overview both of the course and of user interface programming in Java. I'll also show you some useful resources that will help you write great programs, including where to find free software to create your program with (both by hand and visually) and where to find useful documentation.

Read more

How to create a minimal "Hello World" Swing application in Java. In this tutorial we'll create an application that just pops up a window with a title.

  • The "Hello World" application
  • Using Eclipse
  • The JFrame class

How to add components to your main window. One of the hardest things about Swing programming is dealing with layout managers. This tutorial begins a gentle introduction to using layout managers to layout your components in a resize-friendly way.

  • BorderLayout and introducing layout managers
  • JButton
  • JTextArea
  • Customising JFrame with your own derived class

How to make stuff happen when you click buttons! 

  • ActionListener: adding listeners to buttons
  • Anonymous classes as listeners
  • Adding text to text areas

How to divide your application up into separate self-contained components by subclassing other classes -- in this case, the JPanel class.

  • JPanel
  • Custom Components
  • Scroll bars with JScrollPane

How to create a simple panel-based toolbar. In this tutorial we build on our knowledge of creating custom components to add a toolbar with two buttons.

  • Creating simple toolbars
  • FlowLayout for laying out components horizontally
Note: in a later tutorial we'll cover the JToolbar class; this tutorial covers a technique for creating a simple toolbar-like panel, illustrating the useful FlowLayout.

How to cause something to happen in one component in response to something that happens in another component. In this tutorial we look at setting a listener on your custom component and we begin to look at MVC (Model-View-Controller) architecture.

  • Creating listeners for custom components
  • Beginning MVC
  • Disadvantages of making your components tightly coupled

How to improve a basic custom "listener" by using interfaces to eliminate tight coupling between your components. In this tutorial I'll show you how to make your inter-component communication clean and scalable using some standard Java techniques.

  • Custom event listeners
  • Using interfaces to eliminate tight coupling

How to change the sizes of your components.

  • Preferred Size
  • The Dimension class
  • setPreferredSize() vs. setSize()
  • How layout managers handle component sizing

Setting your components' borders.

  • The BorderFactory and Border classes
  • Titled borders
  • Empty borders
  • Etched borders
  • Compound borders

Using the JTextField and JLabel classes to add text fields (one line text entry controls) and labels to your application.

  • JTextField
  • JLabel

How to tame the ferocious GridBagLayout to flexibly add your controls to panels and windows in such a way that they will still look great even if you resize your forms. Unveiling the mysteries of anchors, weights, insets and fills; in this tutorial you'll learn very powerful techniques used by many professional developers to design in-house and commercial Swing applications.

  • The GridBagLayout and GridBagConstraints classes
  • Creating forms
  • The Insets class

Using your own EventObject derived class to transmit information from one component to another. This tutorial also covers basic form handling; getting text from text fields in response to button clicks.

  • The EventObject class
  • Getting the text from text fields
  • Implementing your own event handlers

List boxes allow you to select items from a list. Also in this tutorial, a bit more about MVC architecture.

  • The JList class
  • The DefaultListModel class

How to unhook the text visible in list boxes from the underlying data, so that you can safely change the text in text boxes without messing up your functionality. This technique also makes it easier to interface with databases.

  • Working with list box model data

How to use the handy JComboBox widget. Combo boxes are drop-down list boxes that can also optionally allow you to edit them directly, hence the name combo box -- they are sort of like a combination of a list box and a text field.

  • How to use combo boxes
  • The JComboBox class
  • The DefaultComboBoxModel class
  • Making combo boxes editable
  • A few small tips and tricks with GridBagLayout

How to use the JCheckBox class to add checkboxes to your forms.

  • The JCheckBox class
  • Enabling and disabling form fields

How to use radio buttons, those little round controls that allow you to choose between small numbers of exclusive options.

  • The JRadioButton class
  • The ButtonGroup class
  • Action commands

How to create menus for your applications. Almost every true GUI needs a menu, or else the user will feel lost. Menus are fairly easy to implement too.

  • Creating menus
  • The JMenuBar, JMenu and JMenuItem classes

How to create menu items that you can check and uncheck, like a checkbox. In this tutorial we'll also add a bit of code that shows and hides a form panel.

  • The JCheckBoxMenuItem class
  • Adding ActionListeners to menu items
  • Some notes on using anonymous classes
  • Showing and hiding panels

You can use mnemonics and accelerators to make your menus and other items more keyboard accessible, both for expert users who happen to like shortcuts and for people who don't like to, or can't, use the mouse.

  • What are mnemonics and accelerators?
  • Adding mnemonics to menus, buttons and form fields
  • Setting accelerators for menu items
  • The KeyEvent and ActionEvent classes

You know message boxes? Those little messages that pop up asking you if you really want to do something or other, or warning you about something? This tutorial is about those. In Swing, message boxes are implemented via the JOptionPane class. Also in this tutorial; how to set minimum sizes for components.
  • The JOptionPane class
  • Confirm and Message option dialogs
  • The setMinimumSize() method

How to create dialogs that let you browse to a file location, so that you can open or save a file. File Choosers give you a lot of functionality for free and, in their most basic form, are very easy to use.

  • Using File Choosers
  • The JFileChooser class

How to add filters to your file chooser dialogs, so that the user can choose from particular types of files, for example (but not necessarily) having particular extensions.

  • Filtering JFileChooser
  • The FileFilter class
  • How to get the file extension from the file name

In this tutorial we'll take a brief detour from Swing to look at structuring your application by create a data model package, separate from your GUI (Graphical User Interface) code.

  • Some MVC tips
  • Working with data and packages in Java
  • Creating a simple data model

The controller bit of MVC architecture is the bit that contains all the stuff that's left after you've finished creating that data bit (the model) and the view bit (the user interface). There isn't a whole lot of "business logic" in our sample application, but in this tutorial we'll create a placeholder controller anyway.

  • Some tips on MVC architecture
  • Creating a controller

Creating tables in Swing. The powerful JTable component can help you create simple spreadsheet-like applications with relatively little code.

  • The JTable class
  • Implementing table models and AbstractTableModel
  • How to update your table when the model changes
  • Adding column headers to your tables

Serialization is an easy way to implement saving and loading in your Swing application. Whether you're writing a business-oriented desktop application or a game, serialization makes saving and loading as easy as pie. For that reason I decided to cover it in this tutorial series, even though it's not part of Swing.

  • Saving and Loading objects to and from files
  • The Serializable interface
  • ObjectOutputStream and ObjectInputStream
  • Type erasure in Java
  • Converting arrays to and from Lists

Learn how to create those little menus that appear when you right-click on things.

  • The JPopupMenu class
  • Intercepting mouse clicks 
  • Introduction to mouse listeners and mouse events
  • The MouseAdapter class
  • A note on those pesky serialization id warnings in Eclipse

If you're using a JTable, you might want to be able to select table rows, for instance so that you can delete rows from a popup menu in response to a right mouse click. In this tutorial we look at selecting table rows.

  • Selecting rows in tables
  • Finding the row at a particular point
  • Querying tables to find out which rows are selected

How to delete rows from tables. There's just one little gotcha here, which is that deleting a row from a model doesn't automatically refresh the table. We'll look at how to fix that here. Also in this tutorial, how to protect a list from modification and when to use LinkedList.

  • Deleting table rows
  • Creating unmodifiable lists
  • When to use LinkedLists rather than ArrayLists
  • Another listener-event example

Find out how to create dialog boxes. While message boxes are enough for many simple situations, if you want to put your own controls in a dialog box, you need the JDialog class. Dialog boxes are often used to allow the user to customise program settings, but you can use them for all kinds of things.

  • Creating dialogs with the JDialog class

The JSpinner class allows you to create a little control for entering numbers, complete with up/down buttons for incrementing and decrementing the value. Also in this tutorial, a tip for positioning dialogs and more GridBagLayout examples.

  • Entering numbers in forms
  • The JSpinner and SpinnerNumberModel classes
  • Positioning dialogs relative to parent windows
  • More using GridBagLayout for positioning form controls
  • Making dialogs go away on clicking OK or Cancel

How to create one of those password fields that allow you to enter passwords, but don't show the characters while you're typing them --- just dots or asterisks or something instead.

  • The JPasswordField class
  • Converting arrays of characters to String objects

Preferences allow you to save small amounts of data between runs of your application; for example, form settings, window state, registration details and so on. Preferences are extremely easy to use and take all the work out of saving state and settings.

  • The Preferences class
  • Another example of communicating between objects using the event-listener model
  • Saving dialog form data using preferences

This tutorial discusses some techniques for using layouts and panels to make your forms and dialogs look nicer. Even if you're using a visual designer, you might find the techniques here useful to know.

  • Using panels to arrange forms
  • Line Borders
  • Combining layouts
  • Right-aligning FlowLayout
  • Sizing buttons
  • More GridBagLayout examples
  • A note on spanning rows and columns in GridBagLayout (via gridwidth and gridheight)

This is a tutorial on connecting to a database in Java; I'll use MySQL in this tutorial, but the same ideas work with Oracle, Sqlite and others. JDBC isn't part of Swing, but so many people who write Swing programs want to connect to a database that I thought I'd cover it briefly in this tutorial series. NB: You'll need to install a database on your own machine, or somewhere accessible to you, if you want to run the code covered in this part of the tutorial. Of course you'll need to change the settings as appropriate for your database too.

  • JDBC basics
  • Connecting to a database
  • Using external APIs in Eclipse (by including jar files)
  • Organising a class that connects to a database

In this tutorial we'll look at the simple case of retrieving a count from a SQL database.

  • Getting a count of rows from a database
  • The PreparedStatement and ResultSet classes
  • Working with prepared statements
  • Protecting against weird characters and SQL injection attacks

A tutorial on saving a Java object's fields to a database. 

  • Inserting database rows
  • Using PreparedStatement to do an insert
  • Converting enum values to strings

This tutorial adds to our JDBC code by drawing on what we've already seen to update database rows.

  • Updating database rows
  • More on prepared statements

This tutorial completes our database code by creating code that loads multiple rows from a database and uses the data to instantiate the corresponding data objects.

  • Instantiating objects using information from a database
  • More on the ResultSet class
  • Retrieving data via column names
  • Calling one constructor from another in Java
  • Loading enum types from strings

This tutorial brings together our database code with our GUI code, implementing save and refresh buttons on the toolbar.

  • Wiring in the database code
  • Using Eclipse to refactor code

Want to disconnect from a database when your application closes? Or maybe you want to clean up resources, or ask the user if he or she really wants to quit? You need to intercept the window closing event.

  • Disconnecting from databases
  • Stopping the window exiting automatically when the close widget is clicked
  • Intercepting the Window Closing event
  • The WindowAdapter class
  • Stop Swing throwing a weird stack trace on quitting by running the garbage collector manually
  • A nicer way to quit your Swing application than using System.exit(0)
  • Firing a Window Closing event manually

Want to set icons on your buttons or labels? This tutorial covers loading images and icons and setting them on buttons. You can also set icons on labels using the same technique -- in fact images will display even large images if you want. And of course, you can set an icon on your main JFrame using a similar technique (check out the ImageIcon getImage() and JFrame  setIconImage()  methods).
  • Loading images from packages using the class loader
  • URLs and the getResource() method
  • The ImageIcon class
  • Where to find a great free source of icons

So far we've been working with a rough-and-ready panel-based toolbar, but in this tutorial we'll look at the JToolbar class, which allows you to create draggable toolbars with nice-looking graphical toolbar buttons. We'll also look at tooltips.

  • The JToolbar class
  • Making your toolbar draggable
  • Adding tooltips to buttons

Many applications have main windows that contain separate resizeable areas with draggable borders. In this tutorial we look at how to create such areas, using JSplitPane

  • The JSplitPane class
  • Changing the size of split panes programmatically
  • Adding "one touch expandable" buttons to your split pane.

If you want to be able to switch between different views using tabs, or you want to let the user open multiple sub-windows, tabbed panes are a good option. In this tutorial I show you how to use a tabbed pane to create two separate "views" in your application.

  • The JTabbedPane class

Trees let you view hierarchical entities, for instance the folders on your hard drive. The JTree class is one of the most complex Swing components, but sometimes only a tree will really do the trick. In this tutorial we look at 

  • Creating trees
  • The JTree and DefaultMutableTreeNode classes
  • Building up tree branch-leaf hierarchies

Learn how to detect when someone clicks one of the nodes in your JTree.

  • JTree selection events
  • Making your tree single-selection only
  • The TreeSelectionListener interface

In the last tutorial we saw how to retrieve the text from tree nodes. In this tutorial we look at how to separate the text the user sees from the data that you bring back when the node is selected.

  • JTree user objects

The JTree class allows you to use custom icons for your tree nodes. In this tutorial, we'll see how to do just that.

  • Using custom tree node icons
  • The DefaultTreeCellRenderer class

In this tutorial we'll look at using a custom tree cell renderer, which displays tree leaves as checkboxes. You can use the same techniques to render your tree nodes in whatever way you like.

  • Custom tree cell renderers
  • The TreeCellRenderer interface
  • Displaying tree leaf nodes using checkboxes

Want to use checkboxes or other editors to edit values in tree leaf nodes? This is the tutorial for you. We'll explore techniques that will allow you to use any kind of custom editor in a JTree, using checkboxes as a particular example. Using custom editors in trees is one of the more complex things you can do in Swing, but we'll break it down into methodical steps, and hopefully you'll have no problem developing your own tree node editors.

  • Using custom editors in JTrees
  • The TreeCellEditor interface
  • The AbstractCellEditor class

If you've implemented your own tree cell editor along the lines of the code we looked at in the last tutorial, you'll want to know how to tell when your tree nodes have been edited. We'll look at that in this tutorial.
  • Listening to tree cell editor events
  • The TreeCellEditor class

We're not going to look at anything Swing-specific in this tutorial; but to support more Swing stuff in future tutorials, we're going to take a bit of a detour to implement a fake message server using standard Java.

  • An example of a Map of Lists: a TreeMap containing ArrayLists
  • An example of using a Set (TreeSet)
  • Make a container class iterable using the Iterable and Iterator interfaces

Although you can use standard multithreading techniques in Swing (see http://www.caveofprogramming.com for free tutorials on multithreading), there is also a specialised SwingWorker class for doing multithreading in Swing that removes some of the drawbacks with using the standard variety in a GUI program. In particular, the SwingWorker done() and process() methods allow you to update the GUI directly, something which can't be done from a conventional thread. I'll show you how to use SwingWorker in this tutorial.

  • Multithreading in Swing: running tasks in the background
  • The SwingWorker class

Dialogs in GUI systems can be modal (prevent you from doing anything else until they are closed) or non-modal. We've already seen some simple modal dialogs in the form of message boxes with JOptionPane, but in this tutorial we'll look at creating your own, arbitrarily complex modal dialogs.

  • Creating modal dialogs
  • The JDialog class modal constructor
  • Using SwingUtilities invokeLater to schedule code to run on the event dispatch thread

Progress bars are an important tool for giving feedback to your user. Most users would prefer that a task takes a longer time but indicates its progress, than a shorter time with no feedback. They are also pretty simple to use, the main complication being the business of getting feedback from your background task --- which we covered in the tutorial on multithreading.

  • Progress bars
  • Setting the position of your dialogue relative to its parent window
  • The JProgressBar class
  • Another FlowLayout example
  • Using the pack() method
  • Indeterminate vs. determinate progress bars

If you want to distribute your application, you probably want to create a runnable jar file. Then you can send the file to your users, who can deploy it by (with a bit of luck) clicking on it. It's also possible to use a tool such as JSmooth to wrap the jar in a .exe for Windows, which will automatically download the JRE if necessary. In this tutorial we cover generating a runnable jar from within Eclipse.

  • Creating runnable jars
  • Run configurations in Eclipse

This is just a quick tutorial on adding text to progress bars (such as "loading 85% ...."), which is a nice extra touch.

  • Adding text to progress bars with setStringPainted() and setString()
  • Formatting a percentage with String.format()

In this tutorial we'll implement the cancel button on our progress dialog, making it cancel the SwingWorker background thread.

  • Cancelling threads
  • Another example of a listener
  • Adding a cancel button to your progress dialog
  • Intercepting dialog closing
  • InterruptedExceptions

Setting the cursor to a wait cursor is another great way of giving progress feedback to the user. We'll see how to set the cursor to any one of a number of predefined cursors in this tutorial.

  • Setting the cursor
  • The Cursor class

Want to divide your application into multiple resizeable areas, just like Eclipse? Learn how to do it in this tutorial.

  • Nesting multiple split panes
  • More on the JSplitPane class
  • Setting minimum dimensions on controls within split panes
  • Setting resize weights on JSplitPanes

Sometimes you want your application to do something when the user clicks a tab in a JTabbedPane. This tutorial covers adding change listeners to tab controls to detect when the active tab is changed. We'll also look at another JList example.

  • Using ChangeListener to listen to tab selection events
  • Finding out which tab is active
  • Another JList example

You can render the items in a JList control in whatever way you want. Here we look at an example of a custom list renderer. Ours will be pretty simple, but you can put panels or JComponents of an arbitrary degree of fanciness in your lists if you want to. Note: if you want your list to have editable entries, you'll probably want to use a JTable with one column instead.

  • Custom list renderers
  • The ListCellRenderer interface
  • Setting background colors on panels and labels

Sometimes you want to know immediately when a user selects an item in a JList, rather than just getting the selection in response to a submit button being clicked. Getting the list selection right away is as simple as adding a kind of listener to your JList.

  • Detecting selections in JLists
  • The ListSelectionListener interface
  • Setting the text in a text area
  • Programmatically selecting an item in a list

Swing components that display text have a setFont() method which you can use to change the font. We'll look at how to change the font in this tutorial using "logical fonts"; fonts where you specify the general type of font you want, and Swing chooses the actual particular font for you.

  • Setting the font
  • Using logical fonts
  • Sans-serif, serif and monospaced font types

Sometimes you want to load your own file; perhaps one you've found on the Internet somewhere. In this tutorial we'll look at how to load and set your own custom fonts.

  • Setting physical fonts
  • More info on the Font class
  • Creating derived fonts

This is just a quick video explaining how we can retrieve the values from the database preferences dialog and use them to configure the database connection. 

If you've implemented your own table model, you'll need to do just a little work to make your JTable editable. This tutorial shows you how.

  • Setting values in table models
  • More on AbstractTableModel

If your JTable stores a boolean value, getting it to use a checkbox to display the value is very simple; all we need to do is inform the table via the table model what class of object its working with.

  • Displaying checkboxes in tables
  • Working with data types in a table model

If you want to use a combo box or some other component in a table cell, you need a custom table cell renderer. We look at how to do it in this tutorial, using a combo box to render an enum type as an example.

  • Creating custom renderers for table cells
  • Rendering a table column with a combo box
  • Getting all possible values of an enumeration
  • Setting the height of table rows
  • Giving an enumeration user-friendly text values

Note: slight correction to this tutorial -- if you want to set a renderer for a table column (rather than a data class), you need to get the column via the column model: table.getColumnModel().getColumn(index).setCellRenderer(cellRenderer)

Previously we've seen how to draw table cells using a custom renderer, but if you want to be able to actually change the values in your table cells using a custom control, you need to set a custom editor on your table column or data class. We'll see how to do that in this tutorial, using combo boxes in table cells as an example.

  • Creating custom editors for table cells
  • Setting combo boxes as the editors in a table column
  • The TableCellEditor interface
  • Using AbstractCellEditor as the basis of your table cell editor
Applets and Animation
About Applets and the Following Section

Yes, it's true, you can create Java programs that run in web pages, just like a Flash application. In this tutorial we'll look at creating a Swing-based applet. You can use pretty much all the stuff we've seen so far in your Swing applets; desktop Swing vs. applet Swing is largely identical.

  • Creating applets: browser-based Java programs
  • The JApplet class
  • Understanding the applet lifecycle

Sometimes you want to create your own custom components that actually draw themselves, rather than just, say, acting as containers for other components. You can draw your own components from scratch using the Java graphics API, creating anything from tiny custom buttons to entire game screens. In this tutorial we'll start to put together a component that allows you to play a simple game, but the principles we'll see here apply just as well to creating any kind of owner-drawn custom component.

Although we cover drawing stuff from scratch using shapes in these tutorials, you can also use the same techniques to draw loaded images with the graphics API (rather than shapes), allowing you to set an image as a background for a component. And of course you can also draw lines using the line "shape".

  • Creating owner-drawn custom components
  • How Swing paints components
  • Selecting a suitable parent class for your component
  • Drawing filled rectangles

In this tutorial we'll learn how to draw some shapes using the Swing graphics API. We'll also look at how to smooth your drawing.

  • The Ellipse2D and RoundRectangle2D classes
  • Turning on anti-aliasing to smooth your drawing

In this tutorial we'll look at the simplest way to deploy an applet, by writing a little bit of HTML that embeds your Java program, downloading it from a URL or from your local file system.

  • Deploying applets using HTML
  • How to deploy applets on the Internet

If you want to have a recurring task of short duration in your Swing program, you need to use a timer. Timers can be used in many situations where otherwise you'd have to resort to complex multithreading. The only catch is that Swing timers run code in the main Swing thread, so they're not suitable for long-running tasks --- unless you use them in conjunction with threads. In this tutorial I'm going to use a timer to refresh the screen at regular intervals, implementing a simple form of animation.

  • The Swing Timer class
  • The start and stop applet methods

If you want to write games or simulations or any kind of animated program in Swing, this is the tutorial for you. We'll build on the timer code and basic graphics code that we've seen in the last few tutorials to create a simple animation, which we'll refine in subsequent tutorials.

  • Basic animation
  • Triggering component repaints to redraw the screen
  • How to make a "ball" bounce around your window
  • Getting the width and height of your component

Double buffering is a common animation technique that helps to make your animations smoother. Here we'll look at how to do it in Swing.

  • Double buffering
  • The BufferedImage class
  • Drawing images using the graphics API

Learn how to detect mouse clicks and mouse motion. In this tutorial we'll get the position of the mouse so that we can move a "bat" around the screen. That's bat as in cricket, not bat as in vampire. 

  • Mouse listeners
  • Mouse motion listeners
  • The MouseAdapter class

In this tutorial we'll look at how to make the cursor invisible, which you might want to do if you're writing a game for example. The technique we'll look at here will also suffice if you want to set the cursor to an image, since we'll hide the cursor by just setting it to a transparent blank image.

  • Hiding the cursor
  • Setting the cursor to an image
  • Creating custom cursors using the Toolkit

In this tutorial we'll look at how to detect key presses using key listeners. We'll add a "global" key listener here, but I also discuss briefly how to add key listeners to specific components
  • The KeyListener interface
  • The KeyboardFocusManager class
  • Component key listeners vs. global key listeners
  • Handling arrow keys
  • Making components focusable

Sometimes you want to take action when the user resizes one of your components. In the case of our little animation, we want to resize the back buffer when the animation component is resized. We'll look at how to do it in this tutorial.

  • Listening for component resizing
  • The ComponentListener interface
  • The ComponentAdapter class

In this tutorial we'll look at a visual design plugin that can sometimes save you time and make it easier to design the visual aspect of your Swing applications. I'll briefly discuss Netbeans and we'll move on to the excellent free Window Builder Pro plugin for Eclipse, which lets you switch between your code and the design view.

  • Visually designing Swing programs
  • Installing Window Builder Pro
  • The advantages and disadvantages of Netbeans
  • Pros and cons of visual designers
  • Creating a simple panel with Window Builder Pro
  • Some advantages of SWT over Swing

If you want to skip from one "screen" in your application to another, or for example you want a "wizard" dialog in which part of the dialog switches between different forms, you need the excellent CardLayout class.

  • Switching between different panels in your application
  • The CardLayout class
  • The content pane: what is it?
  • A note on setting the background color of JFrame

In this tutorial we'll complete our animated applet by making the bat hit the ball. To do that, we'll look at how you can find out if one shape intersects another; we'll also touch on how you figure out if a particular shape has been clicked.

  • Detecting when one shape intersects another
  • Detecting when a mouse is clicked on a particular shape
  • How to find when a point lies within a particular shape
  • Some final words about the course
Turning an Applet into a Desktop App
Appendix
Setting the Look and Feel

This zip file contains the most important bits of source code for the applications we've created in these tutorials. In particular, you'll find here the applet source code, the finished desktop application source code, and the source code for an early version of the desktop application, back when it still consisted of little more than a text pane and a primitive toolbar.

If there's anything I've missed out, feel free to get in touch.

Projects -- The Source Code Projects You See in the Tutorials
"Swing Test" Database

Good to know

Know what's good
, what to watch for
, and possible dealbreakers
Teaches Java Swing, which is a critical tool for dynamic user interfaces
Taught by John Purcell, who is an experienced programmer and educator
Builds a strong foundation for beginners in Java Swing
Develops professional skills in Java Swing development
Covers a comprehensive range of topics in Java Swing
Requires students to have basic programming knowledge

Save this course

Save Java Swing (GUI) Programming: From Beginner to Expert to your list so you can find it easily later:
Save

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in Java Swing (GUI) Programming: From Beginner to Expert with these activities:
Compile your Swing notes and resources
Organize and centralize your Swing notes, resources, and materials to facilitate efficient review and reference.
Browse courses on GUI Programming
Show steps
  • Gather your Swing notes, assignments, and other relevant materials.
  • Organize and categorize your materials in a logical manner.
Find a mentor who can guide you in Swing development
Seek advice and guidance from an experienced Swing developer to accelerate your learning and development.
Browse courses on GUI Programming
Show steps
  • Identify a potential mentor who has experience in Swing development.
  • Reach out to your potential mentor and ask if they would be willing to mentor you.
Discuss Swing with a classmate
Clarify your understanding and reinforce your learning by discussing Swing concepts with a peer.
Browse courses on GUI Programming
Show steps
  • Find a classmate who is also learning Swing.
  • Meet up with your classmate and discuss the concepts you are learning.
  • Help each other understand the concepts and answer any questions you have.
Four other activities
Expand to see all activities and additional details
Show all seven activities
Follow a Swing tutorial
Supplement your understanding of Swing concepts by following a step-by-step Swing tutorial.
Browse courses on GUI Programming
Show steps
  • Find a Swing tutorial online or in a book.
  • Follow the tutorial and try to implement the concepts in your own code.
Practice using Swing components
Complete practice drills and exercises to improve your understanding of Swing components, such as buttons, labels, and text fields.
Browse courses on GUI Programming
Show steps
  • Find some online tutorials or exercises on using Swing components.
  • Complete the exercises and try to implement the components in your own code.
Write a blog post about Swing
Increase your conceptual understanding and solidify your learning of Swing by writing a short article or blog post.
Browse courses on GUI Programming
Show steps
  • Choose a topic related to Swing that you are interested in.
  • Research the topic and gather information.
  • Write a blog post or article about the topic, explaining the concepts in your own words.
Create a simple Swing application
Start building a Swing application to reinforce what you are learning about GUI programming.
Browse courses on GUI Programming
Show steps
  • Create a new Java project in your IDE.
  • Add the Swing library to your project.
  • Create a new JFrame for your application.
  • Add some components to your JFrame, such as a button and a label.
  • Write some code to handle the button click event.
  • Run your application and test it.

Career center

Learners who complete Java Swing (GUI) Programming: From Beginner to Expert will develop knowledge and skills that may be useful to these careers:
Animator
Animators bring concepts and ideas to life by creating visual effects for television, film, video games, and other digital media. This course teaches you how to build upon foundational programming skills to create graphics programs. By using Java Swing and various drawing shapes, you will get hands-on experience in graphics design.  These skills are directly transferable to the field of animation.
Computer Programmer
Computer programmers design, develop, test and maintain software and applications for computers and other electronic devices. This course provides in-depth training in Java programming. Particularly, you will develop proficiency in Java Swing, which is used to design and create graphical user interfaces (GUIs). This is a key skill for computer programmers who need to create user-friendly and interactive software.
Graphics Designer
Graphics Designers create visual concepts, using computer software or by hand, to communicate ideas that inspire, inform, and captivate consumers. This course will help you develop a strong foundation in Java Swing, which is a widely-used framework for creating graphical user interfaces (GUIs). By learning how to use Java Swing, you will gain valuable skills that are in high demand in the graphics design industry.
Software Developer
Software developers design, develop, test, deploy, maintain, and manage the lifecycle of computer software applications. This course provides a solid foundation in Java programming, with a particular focus on Java Swing. Swing is a key technology for designing and creating graphical user interfaces (GUIs). By gaining proficiency in Java Swing, you will increase your employability as a software developer.
Software Engineer
Software engineers apply engineering principles to the design, development, deployment, and maintenance of software systems. This course will provide you with a strong foundation in Java programming, with a particular focus on Java Swing. Swing is widely used for designing and creating graphical user interfaces (GUIs). By becoming proficient in Java Swing, you will enhance your skills as a software engineer.
UX Designer
User experience (UX) designers research, design, and evaluate the user experience of products and services. This course will provide you with a strong foundation in Java programming, with a particular focus on Java Swing. Swing is widely used for designing and creating graphical user interfaces (GUIs). By becoming proficient in Java Swing, you will enhance your skills as a UX designer.
Web Developer
Web developers design and develop websites and web applications. This course provides training in Java programming and Java Swing in particular. Java Swing is a key technology for creating graphical user interfaces (GUIs) for web applications. By gaining proficiency in Java Swing, you will become more competitive in the web development job market.
Database Administrator
Database administrators manage and maintain databases, ensuring that data is stored, organized, and retrieved efficiently. This course includes a module on connecting to a database in Java. You will also learn how to retrieve, insert, and update data from a database. These skills are essential for database administrators who need to manage and maintain databases effectively.
Data Analyst
Data analysts collect, analyze, interpret, and present data to help businesses make informed decisions. This course includes a module on connecting to a database in Java. You will also learn how to retrieve, insert, and update data from a database. These skills are essential for data analysts who need to access and analyze data from various sources.
IT Support Specialist
IT support specialists provide technical support to computer users, both remotely and on-site. This course may be helpful for IT support specialists who need to troubleshoot software issues. The course covers topics such as operating systems, networking, and hardware troubleshooting. These skills can be valuable for IT support specialists who need to resolve software-related issues for users.
Quality Assurance Analyst
Quality assurance (QA) analysts test and evaluate software to ensure that it meets quality standards. This course may be helpful for QA analysts who need to work with software development teams. The course covers topics such as software testing methodologies, test planning and execution, and defect tracking. These skills can be valuable for QA analysts who need to ensure the quality of software products.
Computer Systems Analyst
Computer systems analysts analyze and design computer systems to meet the needs of businesses and organizations. This course may be helpful for computer systems analysts who need to work with software development teams. The course covers topics such as systems analysis and design, software development methodologies, and quality assurance. These skills can be valuable for computer systems analysts who need to design and implement software systems for businesses and organizations.
Project Manager
Project managers plan, organize, and manage projects to ensure that they are completed successfully. This course may be helpful for project managers who need to work with software development teams. The course covers topics such as project planning and management, software development methodologies, and quality assurance. These skills can be valuable for project managers who need to oversee software development projects.
Business Analyst
Business analysts analyze business processes and develop solutions to improve efficiency and productivity. This course may be helpful for business analysts who need to work with software development teams. The course covers topics such as requirements gathering and analysis, software development methodologies, and quality assurance. These skills can be valuable for business analysts who need to understand and communicate the business requirements for software development projects.
Technical Writer
Technical writers create and maintain technical documentation, such as user manuals, white papers, and training materials. This course may be helpful for technical writers who need to document software products. The course covers topics such as writing for a technical audience, creating user interfaces, and using graphics and multimedia. These skills can be valuable for technical writers who need to create clear and concise documentation for software products.

Reading list

We've selected six books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in Java Swing (GUI) Programming: From Beginner to Expert.
Java Concurrency in Practice is the definitive guide to writing concurrent Java code. It covers everything you need to know about concurrency, from the basics of threads and locks to advanced topics such as thread pools and non-blocking programming. is essential reading for anyone who wants to write high-performance, scalable Java applications.
Effective Java classic book that teaches best practices for writing Java code. It covers essential topics such as inheritance, generics, concurrency, and memory management. must-read for anyone who wants to write high-quality, maintainable Java code.
Swing Hacks collection of tips and tricks for writing Swing-based GUIs. It covers everything from basic Swing components to advanced topics such as performance tuning and internationalization. good choice for learners who want to write high-quality, maintainable Swing-based GUIs.
Head First Java provides a fun and engaging introduction to Java for beginners. It covers the fundamentals of Java programming, including object-oriented programming, data structures, and algorithms. It's an excellent book for learners who are new to Java or programming in general.
Beginning Java beginner-friendly introduction to Java programming. It covers the basics of Java syntax, object-oriented programming, and data structures. good choice for learners who are new to Java or programming in general.
Java: The Complete Reference comprehensive reference manual for Java. It covers all aspects of the Java language, from the basics to the most advanced features. good choice for learners who need a quick reference to the Java language.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Here are nine courses similar to Java Swing (GUI) Programming: From Beginner to Expert.
Use Python and Java to Create a GUI Application
Most relevant
GUI Development with Python and Tkinter
Most relevant
Python Desktop Application Development
Most relevant
Create a Picture Puzzle using Java Swing
Most relevant
Build a Fast Typing Game using Java Swing
Most relevant
Build a Word Jumble using Java Basics
Most relevant
Build Space Invaders Game using Java
Build Your First GUI App With Java
TornadoFX - Build JavaFX Applications With Kotlin
Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2024 OpenCourser