如何拥有Scrollable JTextPane? [英] How to have a Scrollable JTextPane?

查看:101
本文介绍了如何拥有Scrollable JTextPane?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有一个带滚动条的JTextPane,我该怎么办?谢谢。

I would like to have a JTextPane that have scroll bar, how can I do so ? Thanks.

推荐答案

要在新的JTextPane上插入滚动条,只需使用JScrollPane:

To insert a scroll bar on your new JTextPane, just use a JScrollPane:

JTextPane txt = new JTextPane();

JScrollPane jsp = new JScrollPane(txt);

JTextPane API: http://download.oracle.com/javase/6/docs/api/javax/swing/JTextPane.html

JTextPane API: http://download.oracle.com/javase/6/docs/api/javax/swing/JTextPane.html

JScrollPane API: http://download.oracle.com/javase/6/docs/api/javax/swing/JScrollPane.html

JScrollPane API: http://download.oracle.com/javase/6/docs/api/javax/swing/JScrollPane.html

如果你有一些问题,请看看这个问题:
Java JTextPane JScrollPane显示问题

If you have some issues, take a look at this SO question : Java JTextPane JScrollPane Display Issue

或者看看: http://www.daniweb.com/software-development/java/threads/30283

这篇关于如何拥有Scrollable JTextPane?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆