Luc*_*cas 11 java swing jbutton
我需要在一个空的JPanel的右下角放一个按钮
+-----------------------------------+
| |
| |
| |
| |
| |
| |
| |
| |
| +-----------+|
| | Click Me! ||
| +-----------+|
+-----------------------------------+
Run Code Online (Sandbox Code Playgroud)
我怎么做?它应该很容易吗?我想找到正确的布局管理器,而不是使用一系列嵌套面板.
JPanel panel = new JPanel();
panel.setLayout(new SomeKindOfLayoutManagerThatDoesThis());
panel.add(new JButton("Click Me!"), SETTINGS);
Run Code Online (Sandbox Code Playgroud)
小智 21
我建议使用带有Flow Layout的Border Layout管理器.
就像是:
this.setLayout(new BorderLayout());
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
JButton clickmeButton = new JButton("Click Me");
buttonPanel.add(clickmeButton);
this.add(buttonPanel,BorderLayout.SOUTH);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
17255 次 |
最近记录: |