EditorTextField layout is abnormal after switching themes
Answered
I found this article, https://intellij-support.jetbrains.com/hc/en-us/community/posts/10164279358738-EditorTextFiled-Display-exception, I did it like this, but it had no effect
this is my code.
public class ToolWindow implements ToolWindowFactory {
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull com.intellij.openapi.wm.ToolWindow toolWindow) {
EditorTextField editorTextField = new EditorTextField();
MessageBusConnection busConnection = ApplicationManager.getApplication().getMessageBus().connect();
busConnection.subscribe(EditorColorsManager.TOPIC, new EditorColorsListener() {
@Override
public void globalSchemeChange(EditorColorsScheme scheme) {
editorTextField.revalidate();
editorTextField.repaint();
}
});
JPanel jPanel = new JPanel(new BorderLayout());
JButton button = new JButton("");
jPanel.add(editorTextField);
jPanel.add(button, BorderLayout.EAST);
JPanel root = new JPanel(new BorderLayout());
root.add(jPanel, BorderLayout.NORTH);
toolWindow.getContentManager().addContent(
toolWindow.getContentManager().getFactory().createContent(root, "", false)
);
}
}

After switching the current theme

Please sign in to leave a comment.
I can see that you fixed it by repainting on EDT: https://intellij-support.jetbrains.com/hc/en-us/community/posts/18805521050514-How-to-refresh-the-EditorTextField-ui