How to mirror editor behavior in a custom tool window?

已回答

I'm trying to create a custom tool window where the user can edit a specific Java method. I want the editor in the tool window to look exactly like the regular Java editor, with the same font, syntax highlighting, and code completion. I thought that maybe I could use an EditorTextField object and give it the text of the method, but I can't figure out how to add that object to the JavaFX scene used by the tool window, since the EditorTextField is not of the required Node type.

What would be a good way to get the editor functionality into a tool window?

0

You can create an Editor using one of the EditorFactory.createEditor methods. Editor object contains a method that provides JComponent which you can render inside the ToolWindow.

panel.add(editor.getComponent())
1
Avatar
Permanently deleted user

Thanks, that's just what I was looking for. Since I'm using JavaFX I had to put the JComponent into a SwingNode before adding it to my scene.

SwingNode editorNode = new SwingNode();
editorNode.setContent(editor.getComponent());
root.getChildren().add(editorNode);
0

请先登录再写评论。