All pastes #716582 Raw Edit

Miscellany

public text v1 · immutable
#716582 ·published 2007-09-26 23:23 UTC
rendered paste body
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.lang.*;
 
 
public class HelloWorld extends JFrame implements ActionListener{
        JLabel myL = new JLabel("Name: ");
        JTextField myT = new JTextField(15);
        JButton myB = new JButton("Launch!");
        public HelloWorld(){
                super("Frame Title");
                setSize(300, 300);
                myB.addActionListener(this);
                setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                FlowLayout flow = new FlowLayout();
                setLayout(flow);
                add(myL);
                add(myT);
                add(myB);
               
                setVisible(true);
        }
       
        public class R implements Runnable  {
        public void run()  {
                JOptionPane.showMessageDialog(null, "Test");
        }
	
        }
 
        public void actionPerformed(ActionEvent evt) {
                Object source = evt.getSource();
                if(source == myB){
			R r;
                        r = new R();
			Thread t = new Thread(r);
			t.start();


                }
                repaint();
        }
               
       
        /**
         * @param args
         */
        public static void main(String[] args) throws Exception{
                HelloWorld frame = new HelloWorld();

        }

}