How to dynamically set the width of the Tool Window?
Answered
I have tried toolWindow.getComponent().setSize(), toolWindow.getComponent().setPreferredSize(), as well as the component's parent but it won't change. I need to be able to dynamically set the size on start up, not just with the form.
Please sign in to leave a comment.
Hi, please try this code snippet:
static void setToolWindowWidth(Project project, String toolWindowID, int desiredWidth) {ToolWindowManager instance = ToolWindowManager.getInstance(project);
ToolWindowEx tw = (ToolWindowEx) instance.getToolWindow(toolWindowID);
int width = tw.getComponent().getWidth();
tw.stretchWidth(desiredWidth - width);
}
@...
Very helpful answer. Thanks.