JEditorPane如何插入多行文本 JEditorPane如何插入多行文本实现就像?JTextArea中的apend方法一样 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 看这个:http://blog.csdn.net/BYsWeAT/archive/2010/11/07/5993877.aspxhttp://wenku.baidu.com/view/8eb199284b73f242336c5fc8.html 我看了一下API,貌似JEditorPane继承JTextComponent,这个类采用Swing推崇的mvc模式,把所有的数据(模型)放到Document中,Document.insertString方法可以插入内容。而可以通过JEditorPane.getDocument方法得到相应的Documentlz,试试看可不可以 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(); }}简单写了一个例子,楼主可以看看! 它支持styled text,你加入 \n 就OK了。 我用JEditorPane主要是来显示超级链接,不知道这些链接怎么多行显示..... 比如像下面这样的http://www.baidu.comhttp://sina.com 问题已解决,但碰到了新的问题.先把这个贴子给接了http://topic.csdn.net/u/20110520/10/117f3cfc-f7ee-46d2-967d-94efb6b65594.html 做过red5 在线直播请进 请进来看看~~我这问题不是很难 java 平台的移植问题 请专家评价一下等差数列相关算法效率问题 几道小小的题目一起和大家更进一步的了解 Java (Ⅱ) 两个问题,进来看看吧 java自由作图 就火:存在字符串里的颜色名如何转换成Color对象! 我用File("c:\windows\a.txt")构造File类时出现有不合法的字符的错误 我今天去一公司面试,他们出了这样一道题,我不会做,请高手指教。 java选择排序问题 求助啊求助啊!!!~~~~为什么有的图片可以显示有的不能~~~~!!!!
http://blog.csdn.net/BYsWeAT/archive/2010/11/07/5993877.aspx
http://wenku.baidu.com/view/8eb199284b73f242336c5fc8.html
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();
}
}简单写了一个例子,楼主可以看看!
它支持styled text,你加入 \n 就OK了。
http://www.baidu.com
http://sina.com
http://topic.csdn.net/u/20110520/10/117f3cfc-f7ee-46d2-967d-94efb6b65594.html