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

📄 testjpassword.java

📁 这是一张java应用教程的随书光盘
💻 JAVA
字号:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TestJpassword extends JApplet implements ActionListener
{ JTextField text1;JPasswordField text2; JTextArea textarea;
  JSplitPane split1,split2;
  public void init()
  { Container con=getContentPane();
    text1=new JTextField(8);text2=new JPasswordField(8);
    text2.setEchoChar('#');textarea=new JTextArea(8,8);
    textarea.setEditable(false);
    JPanel p1=new JPanel();JPanel p2=new JPanel();
    p1.add(new Label("输入姓名"));p1.add(text1);
    p2.add(new Label("输入密码"));p2.add(text2);
    split1=new JSplitPane(JSplitPane.VERTICAL_SPLIT,true,p1,p2);
    JScrollPane pane=new JScrollPane(textarea); 
    split2=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,split1,pane);
    text1.addActionListener(this);text2.addActionListener(this);
    con.add(split2,BorderLayout.CENTER);
  }   
 public void actionPerformed(ActionEvent e)
  {  
    if(e.getSource()==text2)
       { String s=new String(text2.getPassword());
         if(s.equals("54321"))
           {textarea.setText("欢迎光临,你可以聊天啦"); 
            textarea.setEditable(true);}
         else 
          {textarea.setText("密码不正确");}
       }
     else if (e.getSource()==text1)
          {textarea.setText("请输入密码");} 
  }
}

⌨️ 快捷键说明

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