版块权限查看
发表帖子
  限 100 字节
WindCode所见即所得
字体 字号 格式
撤消 恢复 复制 剪切 粘贴 去除字体格式 插入图片 插入多媒体 发表交易帖 插入表格 插入引用 插入代码 隐藏内容,回复可见 出售内容
粗体 斜体 下划线 删除线 插入水平线 换行 左对齐 居中 右对齐 左右平等 字体颜色 背景颜色插入url链接 删除链接 有序列表 无序列表 取消缩进 缩进
下标 上标
限 500000 字节
自动分析url 使用签名 Wind Code自动转换 匿名帖 隐藏此帖(回复可见)
加密此帖,会员拥有 以上才能看到帖子内容.
出售此帖,会员需付 才能看到帖子内容.(不能大于:)
认证码 点此显示验证码
 

主题回顾
疾风之狼:

还可以混混,以后有钱不要忘记兄弟们就可以了

jowen:

恩!!! 能多就好!!!

八运会:JTextField 和 JPasswordField 总结

如果不设置 textField1 = new JTextField( 10 ); textField1的文本输入框长度不会是10,会是很短的一个 也可以用   textField2 = new JTextField( "Enter the Text here"); 这样本文输入框中出现的时候就是有文字的; 还可以使用 setEditable( false )方法, 设置文本框的是否可编写状态。 用 event.getSource() == ??来捕获当前焦点的位置。

八运会:显示效果图

显示效果如下:

八运会:JTextField 和 JPasswordField

JTextField 和 JPasswordField 只有一行, 他们接受来自键盘的输入或输出显示信息。 在JPasswordField中,输入的字符是加密的(变成星号); 注意 JTextField 和 JPasswordField 拼写的时候 F   要大写!!! 下面是有关JTextField 和 JPasswordField 使用的源代码 import java.awt.*; import java.awt.event.*; import javax.swing.*; public class TextFieldTest extends JFrame {    private JTextField textField1,textField2,textField3;    private JPasswordField passwordField;    public TextFieldTest()    {        super ( " Sinbad Testing JTextField and JPasswordField " );        Container container = getContentPane();        container.setLayout( new FlowLayout() );        textField1 = new JTextField( 10 );        container.add( textField1 );        textField2 = new JTextField( "Enter the Text here");        container.add( textField2 );        textField3 = new JTextField ( "Uneditable TextField(不可编辑状态)",20);        textField3.setEditable( false );        container.add( textField3 );        passwordField = new JPasswordField (" Hiden Text ");        container.add ( passwordField );                TextFieldHandler handler = new TextFieldHandler();        textField1.addActionListener( handler );        textField2.addActionListener(handler);        textField3.addActionListener(handler);        passwordField.addActionListener( handler);        setSize( 325,100 );        setVisible( true );    }    public static void main( String args[] )    {        TextFieldTest application = new TextFieldTest();        application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);    }    private class TextFieldHandler implements ActionListener    {        public void actionPerformed (ActionEvent event)        {            String string = "";            if ( event.getSource() == textField1 )            {                string = "TextField1: " + event.getActionCommand();            }            if ( event.getSource() == textField2 )            {                string = "TextField2: " + event.getActionCommand();            }            if ( event.getSource() == textField3 )            {                string = "TextField3: " + event.getActionCommand();            }            else if ( event.getSource() == passwordField )            {                JPasswordField pwd = (JPasswordField)event.getSource();                string = "passwordField: " + new String(passwordField.getPassword());            }            JOptionPane.showMessageDialog(null,string);        }    } }