Java JEditorpane 与 JTextPane
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19093851/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JEditorpane vs. JTextPane
提问by Sachin Kumar
i have to create a project in java swing for my college. An editor of java files with proper text highlighting i.e different colors and fonts for java keywords, java commentsand for normal text.
Help me to select one of two styled text component JEditorpaneand JTextPaneprovided by java so that i can full-fill the requirements.
Please tell me suitable difference between these two that in which kind of situation i have to use one of these.
我必须为我的大学在 java swing 中创建一个项目。具有适当文本突出显示的 java 文件编辑器,即java 关键字、java 注释和普通文本的不同颜色和字体。
帮我选择java提供的两个样式文本组件JEditorpane和JTextPane之一,这样我就可以完全满足要求。
请告诉我这两者之间的适当区别,在哪种情况下我必须使用其中之一。
采纳答案by Dan D.
回答by Masudul
Although both support rich text. But there is difference.
虽然两者都支持富文本。但是有区别。
JEditorPanesupports display/editing of HTML.
JEditorPane支持 HTML 的显示/编辑。
JTextPaneis an extension of JEditorPane which provides word processing features like fonts, text styles, colors, etc.
JTextPane是 JEditorPane 的扩展,它提供字体、文本样式、颜色等文字处理功能。