请高手指点

解决方案 »

  1.   

    - -
    taT = new JTextArea();
    taT.getLineCount()://
      

  2.   

    看错了是JtextPanel, - - 
      

  3.   

    这样就行:
    System.out.println(tp.getText().split("\\n").length);//tp是一个JTextPane
      

  4.   

    能不能写一个类似于JTextArea的 getLineCount()的方法呢?如果可以的话,怎么写?
      

  5.   


        public int getLineCount() 
        {
            //tp是一个JTextPane
            Element map = tp.getDocument().getDefaultRootElement();
            return map.getElementCount();
        }