简体   繁体   English

Swing:多面板显示和突出显示文本的对象

[英]Swing: Which objects for a multi panel display and highlighting text

I plan on making a multi comparison program. 我计划制作一个多重比较程序。 It will compare multiple files by displaying N number of files in a grid where N = X * Y. X and Y are the width and height of the grid elements. 它将通过在N = X * Y的网格中显示N个文件来比较多个文件。X和Y是网格元素的宽度和高度。 Easy enough, I know how to do this pretty much. 很容易,我知道如何做到这一点。

The question: How do and in what way is best to highlight individual characters in each of these grid elements? 问题:如何突出显示这些网格元素中的每个字符以及以哪种方式最好? I plan on highlighting matching text that is found in the same position. 我计划突出显示在相同位置找到的匹配文本。

You could use a JTextArea with a Highlighter . 您可以将JTextAreaHighlighter一起使用。 See the second example on this page for how. 有关方法,请参见此页面上的第二个示例。

I'd use a JTextPane rather than a JTextArea, and read up on the StyledDocument class. 我将使用JTextPane而不是JTextArea,并在StyledDocument类上进行阅读。 This will give you all sorts of options. 这将为您提供各种选择。

我不确定“突出显示字符”是什么意思,但是要引起人们对网格元素或网格元素对的关注,可以设置适当组件的背景色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM