简体   繁体   English

在 java 的 GUI 中,除了 .north、.south、.east、.west、.center 之外,我还能使用什么?

[英]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.

相关问题 如何将Enum与其相反的值相关联,如在主要方向(南北,东西等)? - How can I associate an Enum with its opposite value, as in cardinal directions (North - South, East - West, etc)? java:将char [] []数组中的元素向北,向南,向东,向西等方向移动一个空格。 - java: Move elements in a char[][] array by one space either north, south, east, west, etc. Android-Google Maps V2-计算当前不在视野中的标记是屏幕的北,东,南还是西 - Android - Google maps V2 - Calculate whether a marker currently not in view is North, East, South or West of screen 如何阻止BorderLayout的中心向东和向西移动? - How do I stop center of BorderLayout from taking up east and west? 如何将 JPanel 从应用程序的东侧移动到西侧? - How do I move a JPanel from the East side of an application to the West? BorderLayout西中心东全部相等的宽度 - BorderLayout West Center East all Equal width JAVA 可以用BorderLayout在JPanel的NORTH和SOUTH之间重叠对象吗? - JAVA Can we overlap objects between NORTH and SOUTH in JPanel with BorderLayout? 用于SOUTH和NORTH面板的布局管理器? - Which Layout Manager to use for SOUTH and NORTH panels? 我有什么办法可以使BorderLayout的东,南和西边界变大? - Is there any way for me to make BorderLayout's east, south and west border bigger? 如果在BorderLayout.CENTER中,JButton只出现在JFrame上,而不是出现在SOUTH或NORTH中 - JButtons only appear on JFrame if in BorderLayout.CENTER, not SOUTH or NORTH
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM