Pergunta

I have the following code below:

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 1;
    c.gridy = 0;
    config.add(first = new JTextArea(), c);

    c.gridx = 1;
    c.gridy = 2;
    config.add(second = new JTextArea(), c);

    c.gridx = 1;
    c.gridy = 10;
    c.anchor = GridBagConstraints.PAGE_END;

    config.add(bottom, c);

And currently I get the following Screenshot: enter image description here

"bottom" is by button panel. For starters, the two text fields are merged together, and the buttons should be on the bottom. Looking at the Oracle instructions on GridBagLayout didn't help too much. Any ideas?

Foi útil?

Solução

assuming that your class extends from JPanel then calling super(new GridBagLayout()) at the first line of your constructor may solve the issue...

Try adding this line as well c.width=GridBagConstaints.REMAINDER;

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top