package login;
import java.awt.Button;
import java.awt.Frame;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextField;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import login.*;
import javax.swing.JFrame;
public class login extends JFrame
{
public static void main(String[] args) {
Frame nw=new Frame("login");
Panel nn= new Panel();
Label a1=new Label("username");
Label a2=new Label("password");
TextField b1=new TextField(" ");
TextField b2=new TextField(" ");
Button xButton=new Button("确定");
nn.add(a1);
nn.add(b1);
nn.add(a2);
nn.add(b2);
nn.add(xButton);
nw.add(nn);
nw.setSize(300,300);
nw.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e)
{
System.exit(0) ;
}
});
nw.setVisible(true);
}
}
原文:http://www.cnblogs.com/edithfinch/p/7886450.html