在Java中用行高亮显示选定文本(Swing)
当我选择两行或更多行时,如何在swing(JTextPane)中突出显示(Highlighter)而不仅仅是文本(带行)。我需要强调Intellij IDEA中的选择
SwingUtilities.invokeLater(new Runnable() {
JTextPane textPane = new JTextPane();
JScrollPane textPaneWithScroll = new JScrollPane(textPane);
this.getContentPane().add(textPaneWithScroll);
this.setVisible(true);
});
# 1 楼答案
我猜您希望突出显示延伸到文本窗格的右侧
如果是这样,您可以使用:
将突出显示添加到文本窗格时,偏移量必须大于行上的最后一个字符,以便在突出显示中包含换行符