Monday, June 15, 2020

Java Swing - How to make a GUI in Java

Hi, Everyone! If you're interested in a Java GUI How To series, I have created a series of videos on YouTube that teaches you the basics of creating a Graphical User Interface (GUI) in Java using the Java Swing (javax.swing) and Abstract Window (java.awt) toolkits. The full playlist can be found here:

Part 1 - Introduction
This is the first video in this Java Swing How To series. In this part, I teach you how to make a JFrame (i.e. a window) using the Java Swing toolkit.

Part 2 - JButtons
In this Java Swing How To video, I teach you how to add a button to your GUI using the JButton class.

Part 3 - Event Handlers
This Java GUI How To video explains the concept of event handlers so that we can make the program do something when the user clicks on the button in our GUI.

Part 4 - Applying the Event Handlers Concepts
In this Java GUI How To video, we implement what we learned about event handlers and make our program print out a message whenever the button in our GUI is clicked.

Part 5 - Introduction to Layout Managers
In this video, I introduce what a layout manager is, which will allow us to set the layout of the components of our GUI. This video also introduces what the contentPane is.

Part 6 - The FlowLayout
In this video, we learn how to implement a simple FlowLayout Layout Manager to help layout the components of java GUI.

Part 7 - Adding another ActionListener for our second button
In this Java GUI How To video, we create another ActionListener object so that we can make our second button also do something when it is clicked on.

Part 8 - The ActionEvent object and the getSource() method
In this part, we will edit the event handler code so that we only use one event listener object for both of our JButton components. In the actionPerformed method, we will make use of if statements and the getSource() method of the ActionEvent object so that the program can figure out which button was clicked and respond accordingly.

Part 9 - Grabbing the contents of a JTextField and setting the text in a JLabel
In this video, we'll learn how to use the getText() and setText() methods. We'll use getText() to retrieve the text typed inside a JTextField, and the we'll place the retrieved text inside a JLabel using the setText() method.

Part 10 - Converting strings to numbers and numbers to strings
In this video, we'll convert values from Strings to numerics and vice versa ( e.g. Double.parseDouble() and Double.toString() ), so that we can perform arithmetic operations on values taken from text fields, and then display the result in labels.

Part 11 - The BorderLayout
In this video, we'll talk about the BorderLayout manager. We'll also add a JTextArea to our GUI. A JTextArea is similar to a JTextField, but it can handle multiple lines.

Part 12 - The GridLayout
In this Java GUI How To video, we'll talk about the GridLayout manager. This allows us to layout our components in a grid (i.e. in rows and columns).

Part 13 - How Do I Add a JPanel to a JFrame?
In this Java GUI How To video, we introduce the JPanel class and show you how to add one to a JFrame.

(more videos to be added in the future).

No comments:

Post a Comment