How are colors of custom editor set? How to intercept/listen it?


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() {

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?

1 comment

This is done via Look and Feel, and this case Darcula. Some customization is possible via Custom Themes and access via corresponding "named color" (com.intellij.ui.JBColor#namedColor)


Please sign in to leave a comment.