我有 3 个面板。一个是主面板,其中包含 2 个较小的面板。
对于主面板,我使用了
setPreferredSize(new Dimension(350, 190));
对于较小的左侧面板,我使用了
setPreferredSize(new Dimension(100, 190));
对于较小的右侧面板,我使用了
setPreferredSize(new Dimension(250, 190));
但较小的面板保持相同的尺寸。我怎样才能解决这个问题?
这是我在主面板中的代码。
import model.*;
import java.awt.*;
import javax.swing.*;
public class Panel extends JPanel
{
public Panel(Prison prison)
{
setup();
build(prison);
}
private void setup()
{
setBorder(BorderFactory.createLineBorder(Color.blue));
setLayout(new BorderLayout(1, 1));
setPreferredSize(new Dimension(350, 190));
}
private void build(Prison prison)
{
JTabbedPane tab = new JTabbedPane();
tab.addTab("Input", null, new InputPanel(), "Input");
tab.addTab("Display", null, new DisplayPanel(), "Display");
add(tab);
}
}