import
java.awt.Container;
import
java.awt.FlowLayout;
import
java.awt.GridLayout;
import
java.awt.event.ActionEvent;
import
java.awt.event.ActionListener;
import
javax.swing.JButton;
import
javax.swing.JFrame;
import
javax.swing.JLabel;
import
javax.swing.JTextField;
public
class
dengru
extends
JFrame
implements
ActionListener {
private
static
final
long
serialVersionUID = 1L;
private
Container c =
null
;
private
JButton jb =
null
;
public
dengru() {
this
.setLayout(
new
FlowLayout());
jb =
new
JButton(
"登入"
);
jb.addActionListener(
this
);
this
.add(jb);
this
.setSize(
500
,
400
);
this
.setVisible(
true
);
this
.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
public
static
void
main(String[] args) {
new
dengru();
}
@Override
public
void
actionPerformed(ActionEvent e) {
if
(e.getSource() == jb) {
JFrame jf=
new
JFrame();
c = jf.getContentPane();
c.setLayout(
new
GridLayout(
3
,
2
,
2
,
2
));
JLabel jl1 =
new
JLabel(
"用户名:"
);
JLabel jl2 =
new
JLabel(
"密 码:"
);
JTextField jtf1 =
new
JTextField();
JTextField jtf2 =
new
JTextField();
jtf1.setSize(
200
,
40
);
jtf2.setSize(
200
,
40
);
c.add(jl1);
c.add(jtf1);
c.add(jl2);
c.add(jtf2);
c.add(
new
JButton(
"登入"
));
jf.setVisible(
true
);
jf.setSize(
300
,
100
);
jf.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
}
}