Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.*;
- public class mySelf2 {
- public mySelf2(){
- frame();
- }
- public void frame(){
- JFrame frame = new JFrame("Test");
- frame.setSize(500, 500);
- frame.setVisible(true);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- JPanel panel = new JPanel();
- panel.setLayout(null);
- JButton btn = new JButton("This is a button");
- btn.setBounds(168, 150, 120, 35);
- btn.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent e){
- int i;
- for (i = 1; i < 6; i++){
- JOptionPane.showMessageDialog(null, "Test " + i);
- }
- }
- });
- panel.add(btn);
- frame.add(panel);
- }
- public static void main(String args[]){
- new mySelf2();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement