您的位置:首页 > 其它

练习---登陆界面

2015-03-25 09:03 190 查看
package Service;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridLayout;

import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class Service extends JFrame {

public static void main(String[] args) {
// TODO Auto-generated method stub
Service s1 = new Service();
s1.show();
}

Service()
{
this.setSize(300,200);
this.setLocation(150,250);

Container con = this.getContentPane();
con.setLayout( new GridLayout(2,1));

JPanel p1 = new JPanel();
p1.setLayout(new FlowLayout());
con.add(p1);
JPanel p2 = new JPanel();
con.add(p2);

JLabel label1 = new JLabel("用户名:");
JTextField textField1 = new JTextField(20);
JLabel label2 = new JLabel("密 码:");
JTextField textField2 = new JTextField(20);
p1.add(label1);
p1.add(textField1);
p1.add(label2);
p1.add(textField2);

JButton button1 = new JButton("OK");
JButton button2 = new JButton("Cancle");
p2.add(button1);
p2.add(button2);
}
}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: