문제

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