
Quick Contact
Java Tutorial
- What is Java?
- History of Java
- Hello Java Program
- Features of Java
- Basic Syntax
- Java Setup
- Data Types in Java
- Java Variables
- Operators in Java
- JVM
- Java If-else Statement
- Switch Case Statement
- Java Loops
- Do-While Loop
- Java While Loop
- Continue Statement
- Break Statement in Java
- Constructors in Java
- Oops Concept in Java
- Features of OOPs
- Inheritance
- Exeception handeling
- Aggregation (HAS-A relationship) in Java
- Method Overriding in Java
- Method Overloading
- Java Static Keyword
- Java This Keyword
- Java Final Keyword
- Polymorphism
- Static Binding and Dynamic Binding
- Abstract class in Java
- Access Modifiers in Java
- Difference between abstract class and interface
- Interface in Java
- Garbage Collection in Java
- Java Package
- Encapsulation
- Serialization and Deserialization in Java
- Java Inner Classes
- Java Applets
- Multithreading in Java
- Thread Priorities in Java
- Thread Creation
- Inter Thread Communication
- Wrapper Classes in Java
- Java Input Output
- Java AWT Introduction
- Java Layout Manager
- Java Layout Policy
- Java AWT Events
- Collection Framework
- Collection Framework List Interface
- Swing in Java
- Swing Utility Classes
- Swing Layout Managers
- Java JDBC
- Hibernate Framework Overview – Architecture and Basics
Springboot
- Spring Environment Setup
- Spring Boot CRUD REST API Project using IntelliJ IDEA | Postman | MySQL
- Dockerizing Spring Boot Application | Spring Boot Docker Tutorial
- spring-boot-restapidocumentation with swagger
- Spring Boot HttpClient Overview
- Apache HttpClient POST HTTP Request Example
- Apache HttpClient PUT HTTP Request Example
- Apache HttpClient DELETE HTTP Request Example
- Apache HttpClient HTML Form POST Request Example
- Spring Boot JSP Exampl
- Deploying Spring Boot WAR file with JSP to Tomcat
- Spring Boot Annotations
- Spring Core Annotations
- Spring MVC Annotations with Examples
- Spring Scheduling Annotations
- Spring - Java-based Container Configuration
- Spring Java Based Configuration Example
Hibernate
- Hibernate 5 hello world
- Hibernate- One to One Unidirectional Mapping Annotation Example
- Hibernate - Batch Processing
- Hibernate - Interceptors
- Hibernate 5 - Create, Read, Update and Delete (CRUD) Operations Example
- Hibernate Transaction Management
- Hibernate One to Many Unidirectional Mapping Example
- Hibernate One to Many Bidirectional Mapping Example
- Hibernate Many to Many Annotation Mapping Example
- Hibernate Primary KeyJoin Column
- Hibernate First Level Cache with Example
- Hibernate XML Configuration Example with Maven + Eclipse + MySQL Database
- Hibernate Java Configuration Example
- JPA 2 with Hibernate 5 Bootstrapping Example
- JPA and Hibernate Cascade Types
- Hibernate/JPA - Primary Key Generation
- Hibernate 5 - Enum Type Mapping Example
- Hibernate Component Mapping
- Hibernate Object States – Transient,Persistent and Detached
- Hibernate 5 - Save an Entity Example
- Hibernate 5 - Persist an Entity Example
- Hibernate 5 - saveOrUpdate() Method Example
- Hibernate 5 - get(), load() and byId() Method Examples
- Hibernate 5 - merge() Example
- Hibernate 5 - Delete or Remove an Entity Example
- Hibernate 5 - load() Method Example
- Hibernate Session Interface Methods
- Hibernate Session.clear() Method Example
- Introduction Of Java strutes to Architecture
- Struts 2 - Architecture
- Struts 2 - Configuration Files
- Struts 2 - Actions
- Struts 2 - Interceptors
- Struts 2 - Results & Result Types
- Struts 2 - Value Stack/OGNL
- Struts 2 - File Uploading
- Struts 2 - Database Access
- Struts 2 - Validations Framework
JAVA FX
- JavaFX Tutorial
- Introduction to JavaFX Pane
- JavaFX Popup
- JavaFX group
- JavaFX Controller
- JavaFX Gradient Color
- JavaFXAnchorPane
- JavaFXTabPane
- JavaFX Scene
- JavaFX Stage
- JavaFXWebView
- JavaFX Timeline
- JavaFX Timer
- JavaFX Image
- JavaFX Background
- JavaFX dialog
- JavaFX Font
- JavaFXTextArea
- JavaFXObservableList
- JavaFX GUI
- JavaFX FXML
- JavaFXEventHandler
- JavaFXGradle
- JavafxScrollpane
- JavaFXAPI
Swing in Java
What is Swing?
Swing provides graphical user interface (GUI) components to develop Java applications with a rich set of graphics such as windows, buttons, checkboxes, etc. What is a GUI? Before we define a GUI, let us first explain a user interface (UI).
A program does three things:
- Accepts inputs from the user
- Processes the information, and
- Produces outputs
A user interface provides a means to exchange information between a user and a program, regarding inputs and outputs. In other words, a user interface defines the way the interaction between the user and a program takes place. Typing text using a keyboard, selecting a menu item using a mouse, or clicking a button can provide input to a program. A program’s output can be displayed on a computer monitor in the form of character-based text, a graph such as a bar chart, a picture, etc.
You have written many Java programs. You have seen programs where users had to provide inputs to the program in the form of text entered on the console, and the program would print the output on the console. A user interface where the user’s input and the program’s output are in text form is a character-based user interface. A GUI lets users interact with a program using graphical elements called controls or widgets, using a keyboard, a mouse, and other devices.
The Simplest Swing Program
Let’s start with the simplest Swing program. You will display a JFrame, which is a top-level container with no components in it. To create and display a JFrame, you need to do the following:
- Create a JFrame object.
- Make it visible.
To create a JFrame object, you can use one of the constructors of the JFrame class. One of the constructors takes a string, which will be displayed as the title for the JFrame. Classes representing Swing components are in the javax.swing package, so is the JFrame class. The following snippet of code creates a JFrame object with its title set to “Simplest Swing”:
Create a JFrame object
JFrame frame = new JFrame(“Simplest Swing”);
When you create a JFrame object, by default, it is not visible. You need to call it’s setVisible(boolean visible) method to make it visible. If you pass true to this method, the JFrame is made visible, and if you pass false, it is made invisible.
Make the JFrame visible on the screen
frame.setVisible(true);
That is all you have to do to develop your first Swing application! In fact, you can wrap the two statements, to create and display a JFrame, into one statement, like so:
new JFrame(“Simplest Swing”).setVisible(true);
Example
//SimplestSwing.java package com.jdojo.swing; import javax.swing.JFrame; public class SimplestSwing { public static void main(String[] args) { //Create a frame JFrame frame = new JFrame("Simplest Swing"); //Display the frame frame.setVisible(true); } }

Components of JFrame
We will display a JFrame in the previous section. It looked empty; however, it was not empty. When we create a JFrame, the following things are automatically done for us:
- A container, called a root pane is added as the sole child of the JFrame. The root pane is a container. It is an object of the JRootPane class. You can get the reference of the root pane using the getRootPane() method of the JFrame class.
-
Two containers called glass pane, and layered pane is added to the root pane. By default, the glass pane is hidden, and it is placed on top of the layered pane. As the name suggests, the glass pane is transparent, and even if you make it visible, you can see through it. The layered pane is named because it can hold other containers or components in its different layers. Optionally, a layered pane can have a menu bar. However, a menu bar is not added by default when you create a JFrame. You can reference the glass pane and the layered pane by using the getGlassPane() and getLayeredPane() methods of the JFrame class, respectively.
-
A container called a content pane is added to the layered pane. By default, the content pane is empty. This is the container in which you are supposed to add all your Swing components, such as buttons, text fields, labels, etc. Most of the time, you will be working with the content pane of the JFrame. You can get the content pane’s reference by using the getContentPane() method of the JFrame class.

Adding Components to a JFrame
//AddingComponentToJFrame.java package com.jdojo.swing; import javax.swing.JFrame; import javax.swing.JButton; import java.awt.Container; public class AddingComponentToJFrame { public static void main(String[] args) { JFrame frame = new JFrame("Adding Component to JFrame"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); //Add a close button JButton closeButton = new JButton("Close"); contentPane.add(closeButton); //set the size of the frame 300 x 200 frame.setBounds(50, 50, 300, 200); frame.setVisible(true); } }

Apply now for Advanced Java Training Course