I have searched the web for a solution to this problem and didn't find anything that worked.
I have a vertical JSlider inside a JPanel that uses GridBagLayout and a GridBagConstraints for positioning the objects on the panel.
Currently I have the following code:
gbc.gridy = 1;
add(button1,gbc);
gbc.gridy = 2;
add(button2,gbc);
gbc.gridy = 3;
add(slider,gbc);
The objects are positioned vertically along the panel.
The slider always appears in the same size (length). Tried to use setPreferredSize
- didn't work. Tried to use gridheight
in order to have to slider cross two rows - didn't work either. Tried to change the actual min and max values of the slider, didn't help.
Shouldn't GridBagLayout respect preferred size?
EDIT: Also tried creating anoter JPanel inside the main JPanel, set it's layout to FlowLayout, BoxLayout or GridLayout, and add the slider to it. Didn't change a thing. Very weird.
Any ideas?