如何在流布局中组织对象?



我想有一个jframe,左边是文本(JLabel(,右边是按钮。我首先添加了文本,并想尽量不要将框架设置为从右到左。

结束帧代码...使用来自其他类的信息,其他类更新 JLabel。

public class endFrame extends JFrame
{
public endFrame()
{
setSize(500,75);
setLayout(new FlowLayout());
add(board.winner);
JButton r = new JButton("Reset");
r.addActionListener(board.mouse);
add(r);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
}
}

MadProgrammer向我展示了使用Container#add(Comonent,int(可以让你按照你想要的正确顺序移动对象。

最新更新