⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.java

📁 《Java2图形设计卷II:Swing》配套光盘源码
💻 JAVA
字号:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class Test extends JApplet {
	private String pw = "dol42ce";
	private JPasswordField passwordField = new JPasswordField(8);

	public void init() {
		Container contentPane = getContentPane();
		JPanel panel = new JPanel();

		panel.add(new JLabel("Password:"));
		panel.add(passwordField);

		passwordField.setEchoChar('?');

		contentPane.add(panel, BorderLayout.CENTER);

		passwordField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String password = new String(
								  passwordField.getPassword());

				if(pw.equals(password))
					showStatus("Access Granted");
				else
					showStatus("Wrong password - security " +
							   "has been called");
			}
		});
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -