如何在JFrame中对齐comboPanel?

时间:2023-01-27 20:23:50

I am trying to create a simple GUI using NetBeans. I have multiple comboPanels in my JFrame, but I cannot seem to fit them properly. I have the tried using BorderLayout.NORTH, SOUTH etc. but they end up overriding each other or just discombobulated in general. Below is the code I am using for the comboPanel. I have tried re arranging and playing around with the positioning but no luck.

我正在尝试使用NetBeans创建一个简单的GUI。我的JFrame中有多个comboPanel,但我似乎无法正确使用它们。我尝试过使用BorderLayout.NORTH,SOUTH等,但最终会相互覆盖,或者只是在一般情况下进行混乱。下面是我用于comboPanel的代码。我已经尝试重新安排和玩定位但没有运气。

guiFrame.add(comboPanel,   BorderLayout.NORTH );
guiFrame.add(comboPanel_2, BorderLayout.EAST);
guiFrame.add(comboPanel_3, BorderLayout.SOUTH);
guiFrame.add(comboPanel_4, BorderLayout.WEST);

1 个解决方案

#1


Try using GridBagLayout. Check this link: https://docs.oracle.com/javase/tutorial/uiswing/layout/gridbag.html

尝试使用GridBagLayout。检查此链接:https://docs.oracle.com/javase/tutorial/uiswing/layout/gridbag.html

#1


Try using GridBagLayout. Check this link: https://docs.oracle.com/javase/tutorial/uiswing/layout/gridbag.html

尝试使用GridBagLayout。检查此链接:https://docs.oracle.com/javase/tutorial/uiswing/layout/gridbag.html