[英]What can I use aside from .north, .south, .east, .west, .center in a GUI in java?
add(banner, BorderLayout.NORTH);
add(bread, BorderLayout.CENTER);
add(sandwiches, BorderLayout.EAST);
add(drinks, BorderLayout.WEST);
add(buttonPanel, BorderLayout.SOUTH);
I currently have a GUI and have used these 5 location allocation.我目前有一个 GUI,并使用了这 5 个位置分配。 Is there another one I can use if I want to add another panel on the right side?
如果我想在右侧添加另一个面板,是否可以使用另一个?
I want to add another panel on the right side?
我想在右侧添加另一个面板?
So you create another child JPanel with the appropriate layout manager:因此,您使用适当的布局管理器创建另一个子 JPanel:
JPanel east = new JPanel( new BorderLayout() );
east.add(sandwiches, BorderLayout.LINE_START);
JPanel anotherPanel = new JPanel( new GridLayout(0, 1) );
anotherPanel.add( new JButton("Button1") );
anotherPanel.add( new JButton("Button2") );
east.add(anotherPanel, BorderLayout.LINE_END);
//add(sandwiches, BorderLayout.EAST);
add(east, BorderLayout.EAST);
So the "east" panel becomes a nested panel that contains two other panels.因此,“东”面板变成了一个嵌套面板,其中包含另外两个面板。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.