我很难弄清楚为什么这个边界布局仍然像流程布局一样......
我先试了这个:
JPanel canvas = new JPanel(new BorderLayout());
add(canvas);
text = new JLabel("hey");
canvas.add(text, BorderLayout.SOUTH);
然后我尝试了这个:
JPanel canvas = new JPanel(new BorderLayout());
add(canvas)
JPanel canvasSouth = new JPanel(new BorderLayout());
canvas.add(canvasSouth, BorderLayout.SOUTH);
text = new JLabel("hey");
canvasSouth.add(text);
然后我说拧了它,我只是想把所有东西都扔掉:
JPanel canvas = new JPanel(new BorderLayout());
add(canvas);
JPanel canvasSouth = new JPanel(new BorderLayout());
canvas.add(canvasSouth, BorderLayout.SOUTH);
JPanel canvasNorth = new JPanel(new BorderLayout());
canvas.add(canvasNorth, BorderLayout.NORTH);
JPanel canvasEast = new JPanel(new BorderLayout());
canvas.add(canvasEast, BorderLayout.EAST);
JPanel canvasWest = new JPanel(new BorderLayout());
canvas.add(canvasWest, BorderLayout.WEST);
text = new JLabel("hey");
canvasSouth.add(text);
我以前遇到过这个问题而且从来没有能够自己解决这个问题。因此,我问你们所有人。谢谢。