Need help with Setting layout
Hello,
I have been developing some settings for my plugin and have been following the Settings Tutorial. However, I can't get the layout the way I want using the FormBuilder. I have also tried using regular JPanel with GridBagLayout. I am sure that there is something fundamental that I am missing to create a nice looking settings panel in IntelliJ.
What I am trying to do is have two labels at the top, stacked one on top of the other, with a table with two columns of check boxes. If I used the FormBuilder, the labels are left justified, but the columns of check boxes appear somewhere near the middle of the labels. If I use GridBagLayout in a separate JPanel and add it as a component to the FormBuilder panel, everything is moved to the right, with the check boxes still near the middle of the labels. Something similar occurs when using the JPanel with GridBagLayout without the FormBuilder panel.
My code is in several methods, so it is not practical to post at this point.
Any suggestions are greatly appreciated.
Thanks in advance,
Todd
请先登录再写评论。
Hi Todd,
It's difficult to understand the issue without the screenshots and the code. Building complex layouts with Swing may require experimenting with the Form Builder, so the answer won't be obvious probably.
If there is any similar UI control existing in IDE, you can try using UI Inspector (https://plugins.jetbrains.com/docs/intellij/internal-ui-inspector.html) to check its implementation.
As can be seen in the attached image, the text and checkboxes are far from the left side of the panel where most settings UI panels are normally anchored.
The code below has very few FormBuilder elements since I wasn't making progress with the FormBuilder and refactored to Swing to see if that would help in some way. So, if you have any suggestions regarding FormBuilder or Swing, please don't hesitate as I am not afraid of refactoring.