ToolWindow JButton Font/Size overridden
My plug-in features a ToolWindow that displays a series of JButtons to the user. Upon ToolWindow initialization my buttons are set with:
for (int i = 0; i < codeButtons.size(); i++) {
codeButtons.get(i).setFont(new Font("Segoe UI", Font.PLAIN, 15);
codeButtons.get(i).setPreferredSize(new Dimension(190,30));
}
This works perfect when I test it with tool_window run configuration and everything is the right size. However, when I install the plug-in and use it in my main IDE, the JButton font sizes/preferred sizes are overridden and appear larger than normal.
请先登录再写评论。
What is your screen scaling factor? If it's not 100% but 150% or 200% font size would be automatically adjusted in main IDE and wouldn't be adjusted in debug IDE as it probably run with different JRE. Please check it.
Thanks for the response, that is exactly what was happening. Let me know if there is any API I can call to reject the custom scale factor being applied to my ToolWindow as it messes it up (or if not I'll have to reprogram to support it).
Your custom ToolWindow is a part of the whole UI, and you should not reject scaling factor (there's no API for that). To support scaling, please wrap UI constants with JBUI.scale(<size>), or JBDimension(<w>, <h>).