AWT中是这样用的,你看一下swing中能不能这样用
TextField = new TextField(20)
JTextField = new JTextField(20)

解决方案 »

  1.   

    第一个不知道
    第二个可以试试下面的方法
    import javax.swing.text.PlainDocument;
    import javax.swing.text.AttributeSet;
    import javax.swing.text.BadLocationException;textField.setDocument( new PlainDocument() {
        public void insertString(int offs, String str, AttributeSet a) throws BadLocationException{
            if ((getLength() + str.length()) <= 10 ) {
                 super.insertString(offs, str, a);
            } else {
                 throw new BadLocationException("Insertion exceeds max size ofdocument", offs);
            }
       }
    });
      

  2.   

    忘了说了 ((getLength() + str.length()) <= 10 ) 这里的10 是允许的最长的字符数
      

  3.   

    你的JDialog加个最小化后,不是和JFrame没什么区别了吗?干什么不用JFrame
      

  4.   

    我也觉得设置一个jTextfield输入长度,只能判断内容长度来限制
      

  5.   

    DDrddr方法不错,可以的。关于第一个问题,主要是一级一级的弹出画面,也要求一级一级的返回,所以用了Dialog.
      

  6.   

    1.可以。
    2.自己作一个类实现JTextField类的所有功能+你自己想实现的功能
      

  7.   

    1。写个类:class  NewDocument extends PlainDocument
         {
          public void insertString(int offs, String str, AttributeSet a) throws
              BadLocationException {
            if (this.getLength() == 100)
              str = "";
            super.insertString(offs, str, a);
          }    }
    2。  jP6TextField.setDocument(new NewDocument());