JAVA Swing

Exception handling is the way to handle the unexpected circumstances like runtime errors. So when the unexpected circumstance occurs, the program control is transferred to special functions known as handlers.

Syntax:

import javax.swing.*;
public test
{
public static void main(String args[])
{
JFrame f = new JFrame(); //Creting instance of JFrame

JButton b new button("Click");
b.setBounds(130,100,100,40); //creating instance of JButton
f.add(b); //adding button in JFrame

f.setSize(400,500);
f.setlayout(null);
f.setVisibility(true);
}
}

Java Button: The JButton class is used to create a labeled button that has platform independent implementation. The application result in some action when the button is pushed. It inherits Abstract Button class.

import javax.swing.*;
public test
{
public static void main(String args[])
{
JFrame f = new JFrame(); //Creting instance of JFrame

JButton b new button("Click");
b.setBounds(130,100,100,40); //creating instance of JButton
f.add(b); //adding button in JFrame

f.setSize(400,500);
f.setlayout(null);
f.setVisibility(true);
}
}