How are colors of custom editor set? How to intercept/listen it?
Answered
I wrote my example of custom editor
public class LineageFileEditor implements FileEditor {
...
@Override public @NotNull JComponent getComponent() {
return new JSwingExample02();
}
and it returns my custom JComponent:
public class JSwingExample02 extends JComponent {
public JSwingExample02() {
populate();
}
private void populate() {
setLayout(new BorderLayout());
add(new JLabel("Hello World"), BorderLayout.CENTER);
}
It works and draws
As you see, I am using dark theme and my component has inherited it.
How was it done? I have intercepted calls to `setBackground` and `setForeground` methods, but they haven't called.
How to intercept stting of colors in order to have my own derived drawings?
Please sign in to leave a comment.
This is done via Look and Feel, and this case Darcula. Some customization is possible via Custom Themes https://plugins.jetbrains.com/docs/intellij/themes-intro.html and access via corresponding "named color" (com.intellij.ui.JBColor#namedColor)