質問

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?

役に立ちましたか?

解決

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;

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top