Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4.  
  5. class HelloSwing5 extends JFrame implements ActionListener
  6. {
  7.  
  8.     HelloSwing5()
  9.     {
  10.         setTitle("Hello Swing5");
  11.         setLayout(new FlowLayout());
  12.         setSize(400,300);
  13.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  14.  
  15.         Container c=getContentPane();
  16.         JButton btn=new JButton("Click me!");
  17.         c.add(btn);
  18.         btn.addActionListener(this);
  19.  
  20.         setVisible(true);
  21.     }
  22.  
  23.     public void actionPerformed(ActionEvent e)
  24.     {
  25.         int i=JOptionPane.showConfirmDialog(this,"Hello");
  26.     }
  27. }
  28.  
  29. public class Ex5
  30. {
  31.     public static void main(String[] args)
  32.     {
  33.         new HelloSwing5();
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement