`getComponent` of my custom `FileEditor` is never called

Answered

I wish to make my own file type to edit some lineage graphs graphically.

I have derived from `FileEditor` class 

public class LineageFileEditor implements FileEditor {

@Override public @NotNull JComponent getComponent() {
return new JExample();
}

...

and also wrote a custom component, which draws a circle

public class JExample extends JComponent {

@Override protected void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D)g;

g.fillOval(10, 10, 100, 100);
}

public static void main(String[] args) {
JFrame frame = new JFrame();

frame.add(new JExample(), BorderLayout.CENTER);

frame.setSize(800, 600);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

frame.setVisible(true);
}
}

This component works from it's main.

Unfortunately, my editor acts as just text editor in IntelliJ

and `#getComponent()` method is never called according to the debugger.

Why and how to fix?

0
3 comments

Please always show full context. Did you register/implement com.intellij.openapi.fileEditor.FileEditorProvider as well?

1

Context is full :) I did only what I wrote, I am a newbiew and didn't knew about FileEditorProvider at all! Thank you, will dig at this direction!

0

It worked. I was to notice, that there was no connection between editor and type before...

0

Please sign in to leave a comment.