0

I have a JScrollPane that has a JTextArea in it. I also have a JPanel panel = new JPanel(new GridBagLayout) and a GridBagConstraints constraints = new GridBagConstraints() and this GridBagLayout is a 4x9. I am trying to insert the JScrollPane onto the first column, and taking up the bottom 8 tiles, however, I can only get it to fill its width and

constraints.gridx = 0;
constraints.gridy = 1;
constraints.gridwidth = 1;
constraints.gridheight = 8;
constraints.fill = GridBagConstraints.HORIZONTAL;

Setting constraints.fill = GridBagConstraints.BOTH does not do anything. I have tried setting contraints.ipady = 100 which works in filling out multiple rows however this is a fixed integer and I can't seem to get the grid cell size anywhere. The GridBagLayout.getLayoutDimensions() returns an empty integer double array.

How can I make the JScrollPane fill the whole 8 rows?

I've tried everything described above.

2
  • 3
    maybe better include a minimal reproducible example in the question - gridheight = 8 is correct, but not fill = ...HORIZONTAL ||| most probably the cells (rows) are not the size you expect
    – user85421
    Commented Jun 30 at 16:34
  • 1
    You can only specify a gridheight of 8 if one of your other columns has 8 rows with components in each row. You can't just say say you have a grid of 4x9.
    – camickr
    Commented Jul 1 at 1:06

0

Browse other questions tagged or ask your own question.