📄 password.java
字号:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
/*
<APPLET
CODE = password.class
WIDTH = 350
HEIGHT = 280 >
</APPLET>
*/
public class password extends JApplet
{
String correctpassword = "open sesame";
JPasswordField jpasswordfield = new JPasswordField(10);
public void init()
{
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
contentPane.add(new JLabel("Type your password: "));
contentPane.add(jpasswordfield);
jpasswordfield.setEchoChar('*');
jpasswordfield.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String input = new String(jpasswordfield.getPassword());
if(correctpassword.equals(input))
showStatus("Correct");
else
showStatus("Incorrect");
}
});
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -