JEditorPane如何插入多行文本实现就像?JTextArea中的apend方法一样

解决方案 »

  1.   

    看这个:
    http://blog.csdn.net/BYsWeAT/archive/2010/11/07/5993877.aspx
    http://wenku.baidu.com/view/8eb199284b73f242336c5fc8.html
      

  2.   

    我看了一下API,貌似JEditorPane继承JTextComponent,这个类采用Swing推崇的mvc模式,把所有的数据(模型)放到Document中,Document.insertString方法可以插入内容。而可以通过JEditorPane.getDocument方法得到相应的Documentlz,试试看可不可以
      

  3.   


    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;public class MainFrame extends JFrame { private JEditorPane editorPane; public MainFrame() {
    editorPane = new JEditorPane();
    // 加入多行文本
    for (int i = 0; i < 100; i++) {
    editorPane.setText(editorPane.getText() + "第" + i + "行数据\n");
    } JScrollPane jsp = new JScrollPane(editorPane); this.setTitle("JEditorPanel多行文本");
    this.setSize(800, 600); this.add(jsp);
    this.setVisible(true);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    } public static void main(String[] args) {
    new MainFrame();
    }
    }简单写了一个例子,楼主可以看看!
      

  4.   


    它支持styled text,你加入 \n 就OK了。
      

  5.   

    我用JEditorPane主要是来显示超级链接,不知道这些链接怎么多行显示.....
      

  6.   

    比如像下面这样的
    http://www.baidu.com
    http://sina.com
      

  7.   

    问题已解决,但碰到了新的问题.先把这个贴子给接了
    http://topic.csdn.net/u/20110520/10/117f3cfc-f7ee-46d2-967d-94efb6b65594.html