我想要一个 jframe,其文本在左侧(JLabel),按钮在右侧。我首先添加了文本,并且想尝试不要将框架设置为从右到左。
EndFrame 代码...使用其他类的信息,其他类更新 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);
}
}
最佳答案
Mad Programmer 向我展示了使用 Container#add(Component, into) 可以让您按照所需的正确顺序移动对象。
关于java - 如何在流布局中组织对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51913263/