Мне нужна пользовательская всплывающая подсказка в текстовой области.
Мне нужен специальный инструмент, в котором он будет устанавливать цвет текста, например, в первой строке, как красный, во-вторых, как желтый, в-третьих, как зеленый.
Это в одной подсказке.
Вот мой код:
package org.example;
import javax.swing.*;
import java.awt.*;
import java.io.IOException;
import org.fife.ui.rtextarea.*;
import org.fife.ui.rsyntaxtextarea.*;
public class TextEditorDemo extends JFrame {
public TextEditorDemo() throws IOException {
JPanel cp = new JPanel(new BorderLayout());
RSyntaxTextArea textArea = new RSyntaxTextArea(20, 60);
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
textArea.setCodeFoldingEnabled(true);
RTextScrollPane sp = new RTextScrollPane(textArea);
cp.add(sp);
setContentPane(cp);
setTitle("Text Editor Demo");
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
setLocationRelativeTo(null);
org.fife.ui.rsyntaxtextarea.Theme theme = org.fife.ui.rsyntaxtextarea.Theme.load(getClass().getResourceAsStream("/org/fife/ui/rsyntaxtextarea/themes/vs.xml"));
theme.apply(textArea);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
try {
new TextEditorDemo().setVisible(true);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
}
}
Подробнее здесь: https://stackoverflow.com/questions/780 ... o-textarea