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

📄 jpasswordfield4.java

📁 java关于编辑器的非常实用软件
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class JPasswordField4 implements ActionListener
{final JPasswordField t1;final JLabel l3;JButton b1;
	public JPasswordField4()
	{
		JFrame f = new JFrame("JPasswordField4");
		Container contentPane = f.getContentPane();
		contentPane.setLayout(new BorderLayout());

		JPanel p1 = new JPanel();
		p1.setLayout(new GridLayout(3,2));
		p1.setBorder(BorderFactory.createTitledBorder("JPasswordField 事件处理范例"));
		JLabel l1 = new JLabel("输入:");
		JLabel l2 = new JLabel("输入后,按下 Enter ==>");
		l3 = new JLabel("");
		t1 = new JPasswordField();
		t1.addActionListener(this);
		b1=new JButton("确定");
		b1.addActionListener(this);
		p1.add(l1);
		p1.add(t1);
	    p1.add(l2);
		p1.add(l3);
		p1.add(b1);

		contentPane.add(p1);
		f.pack();
		f.show();
		f.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		});
	}
	public void actionPerformed(ActionEvent e)
	{
		if(e.getSource()==b1)
		{
			final char [] theStr = t1.getPassword();
			final String str = new String(theStr);
			l3.setText(str);
		}
	}
    public static void main(String args[])
    {
		new JPasswordField4();
	}

}

⌨️ 快捷键说明

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