标题:有段代码不明白
取消只看楼主
dukai5302885
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2008-7-24
 问题点数:0 回复次数:0 
有段代码不明白
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class JPasswordFieldDemo extends JFrame
{
    JTextField userName;
    JPasswordField passWord;
    JButton logonButton;
    JButton cancelButton;
    
    public JPasswordFieldDemo()
    {
        super("JPasswordField演示");
        Container container=getContentPane();
        container.setLayout(new GridLayout(3,2,2,2));
        
        userName=new JTextField(16);
        passWord=new JPasswordField(16);
        logonButton=new JButton("登录");
        logonButton.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent evt)
            {
                char[] pw=passWord.getPassword();
                String message="您的用户名:"+userName.getText()+"\n你的密码:"+new String(pw);
                JOptionPane.showMessageDialog(JPasswordFieldDemo.this,  message);
            }    
        });
        cancelButton=new JButton("退出");
        cancelButton.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent evt)
            {
                System.exit(0);
            }
        });
        
        container.add(new JLabel("   用户名:"));
        container.add(userName);
        container.add(new JLabel("   密码:"));
        container.add(passWord);
        container.add(logonButton);
        container.add(cancelButton);
        setResizable(false);
        setSize(300,120);
        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    public static void main(String[] args)
    {
        new JPasswordFieldDemo();
    }
}

中的JPasswordFieldDemo.this 指的是什么啊
搜索更多相关主题的帖子: import awt container new java 
2008-08-16 17:48



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-228624-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.243454 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved