import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Swing1 {
public static void main(String args[])
{
JFrame frame = new JFrame("Simple Swing Application");
JButton button=new JButton("Click Me");
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(frame,"Button Clicked!");
}
});
frame.getContentPane().add(button);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300,150);
frame.setVisible(true);
}
}import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Swing1 {
public static void main(String args[])
{
JFrame frame = new JFrame("Simple Swing Application");
JButton button=new JButton("Click Me");
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(frame,"Button Clicked!");
}
});
frame.getContentPane().add(button);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300,150);
frame.setVisible(true);
}
}