📄 loginjapplet.java
字号:
//【例8.2】 Applet中的邮箱登录界面。
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import javax.swing.*;
public class LoginJApplet extends JApplet implements ActionListener
{
private JTextField text_user; //用户名文本行
private JPasswordField password; //口令文本行
private JComboBox combobox_mailbox; //邮箱组合框
private JButton button_login; //登录按钮
public void init() //初始化Applet
{
this.setBackground(Color.white); //设置背景颜色
this.setLayout(new FlowLayout(FlowLayout.LEFT)); //行布局
this.add(new JLabel("邮箱"));
text_user = new JTextField("用户名",10);
text_user.addActionListener(this); //为文本行注册单击事件监听器
this.add(text_user);
this.add(new JLabel("@"));
Object box[]={"263.net", "x263.net"};
combobox_mailbox = new JComboBox(box);
this.add(combobox_mailbox);
this.add(new JLabel("密码"));
password = new JPasswordField("******",10);
this.add(password);
button_login = new JButton("登录");
this.add(button_login);
button_login.addActionListener(this); //为按钮注册单击事件监听器
}
public void actionPerformed(ActionEvent e) //单击按钮或文本行中单击Enter键时
{
if ((e.getSource()==button_login) || (e.getSource()==password))
{}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -