java作业

import javax.swing.;
import java.awt.Window;
import java.awt.event.
;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JRadioButton;
import javax.swing.JLabel;
import javax.swing.ButtonGroup;
public class Homework {

protected static final Window dlg1 = null;

public static void main(String[] args) {
// TODO Auto-generated method stub
final JFrame frm = new JFrame("登陆");
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frm.setLayout(null);

JLabel userLabel = new JLabel();
userLabel.setText("账号:");
userLabel.setBounds(40, 20, 80, 30);

JLabel userLabel1 = new JLabel();
userLabel1.setText("密码:");
userLabel1.setBounds(40, 20, 80, 110);

JLabel slabel = new JLabel("服务区:");
slabel.setBounds(40, 20, 80, 170);
frm.add(slabel);

ButtonGroup btnGroup = new ButtonGroup();

JRadioButton aRadioButton = new JRadioButton("网通");
aRadioButton.setBounds(100, 90, 70, 30);
aRadioButton.setSelected(true);
JRadioButton bRadioButton = new JRadioButton("电信");
bRadioButton.setBounds(190, 90, 70, 30);

btnGroup.add(aRadioButton);
btnGroup.add(bRadioButton);
frm.add(aRadioButton);
frm.add(bRadioButton);

JTextField userText = new JTextField();
userText.setEditable(true);
userText.setHorizontalAlignment(SwingConstants.LEFT);
userText.setColumns(20);
userText.setBounds(100, 20, 120, 30);

JTextField userText1 = new JTextField();
userText1.setEditable(true);
userText1.setHorizontalAlignment(SwingConstants.LEFT);
userText1.setColumns(20);
userText1.setBounds(100, 60, 120, 30);

final JDialog dlg = new JDialog(frm,"窗口");
dlg.setBounds(470, 220, 200, 150);
dlg.setLayout(null);
dlg.setModal(true);

JButton obtn = new JButton("登陆");
obtn.setBounds(60, 125, 60, 30);
obtn.addActionListener(new ActionListener(){

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
dlg.setVisible(true);
}
});
frm.add(obtn);

JButton btn = new JButton("进入游戏");
btn.setBounds(50, 40, 100, 25);
btn.addActionListener(new ActionListener(){

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
dlg.setVisible(false);
}
});
dlg.add(btn);

final JDialog dlg1 = new JDialog(frm,"窗口");
dlg1.setBounds(470, 220, 200, 150);
dlg1.setLayout(null);
dlg1.setModal(true);

JButton obtn1 = new JButton("退出");
obtn1.setBounds(180, 125, 60, 30);
obtn1.addActionListener(new ActionListener(){

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
dlg1.setVisible(true);
}
});
frm.add(obtn1);

JButton btn1 = new JButton("确认退出");
btn1.setBounds(50, 40, 100, 25);
btn1.addActionListener(new ActionListener(){

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
dlg1.setVisible(false);
}
});
dlg1.add(btn1);

frm.add(userLabel);
frm.add(userText);
frm.add(obtn1);
frm.add(obtn);
frm.add(userLabel1);
frm.add(userText1);
frm.setBounds(450, 200, 325, 200);
frm.setVisible(true);
}

}
j'a

posted @ 2016-03-19 18:50  zhangfeng1137906105  阅读(171)  评论(0)    收藏  举报