Skip to main content

First Java Swing GUI

This post is to create a Java Swing GUI. Here, I will create a typical window having title of “First Swing GUI” and size of 300 by 200. The window can be resized into larger or smaller one. It also allows dragging anywhere in your desktop window.  The close operation is EXIT_ON_CLOSE which includes ‘minimize’, ‘maximize’ and ‘close’ buttons.import  


java.awt.EventQueue;
import javax.swing.JFrame;
public class FirstSwingGUI extends JFrame{
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    FirstSwingGUI gui = new FirstSwingGUI();
                   gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    gui.setSize(300, 200);
                    gui.setVisible(true);
                    gui.setTitle("First Swing GUI");
                } catch(Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
}

That’s it!
Any comments and/or suggestions are encouraged. Thank you.

Comments

  1. I am so proud of you and your efforts and work make me realize that anything can be done with patience and sincerity. Well I am here to say that your work has inspired me without a doubt.
    Java training in Chennai

    Java training in Bangalore

    ReplyDelete

Post a Comment

Popular posts from this blog

Guestbook in PHP and MySQL

Introduction I'm going to create an example of guestbook system using in PHP and MySQL. On the Web, guestbook is a logging system that lets visitor post their message. A visitor can post their thoughts or expressions. In general, it's not a requirement that a visitor create an account.

Phonebook Application with PHP and MySQL CRUD Operation

Definition It is a simple Web-based phonebook application which stores and displays ID, Name, Contact No, and Address of a person. It is also capable of updating/editing and deleting phonebook entries. Database CREATE TABLE `phonebook` (     `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,     `name` VARCHAR(50) NOT NULL,     `phone_no` VARCHAR(15) NOT NULL,     `address` VARCHAR(50) NOT NULL,     `date_created DATETIME` NOT NULL DEFAULT ‘0000-00-00 00:00:00’,     PRIMARY KEY(`id`) );

CRUD in Spring Boot with Spring Data JPA

T utorial about CRUD operations in Spring Boot with Spring Data JPA. Application developed in this tutorial performs adding, editing, updating and deleting contacts. Continue reading here .