I have a simple problem here in Java Swing. I simplified my code to the following snippet. I am not sure how I can minimize the gap size between the horizontal JSeparator with the next JTextField, as current code generates a huge gap between the two.
GroupLayout layout = new GroupLayout(jPanel1);
jPanel1.setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup()
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createSequentialGroup()
.addComponent(button)
))
.addComponent(jSeparator)
.addComponent(jTextField)
);
layout.setVerticalGroup(layout.createSequentialGroup()
.addComponent(button)
.addComponent(jSeparator)
.addComponent(jTextField)
);
And also in general, how can I control the gap size to any integer represented value, instead of using the addPreferredGap
?
Thank you.
Okay, this is the window generated from the code posted above:
You can see the space between the JSeparator and JTextField is very wide.