简体   繁体   English

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

[英]How do you organize objects in a flow layout?

I would like to have a jframe with the text on the left(JLabel) and button on the right. 我想有一个jframe,左边的文本(JLabel)和右边的按钮。 I added the text first and would like to try not to set the frame to right to left. 我首先添加了文本,并希望尽量不要将框架设置为从右到左。

EndFrame code ... uses information from other class and other classes update the 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);
}
}

MadProgrammer向我展示了使用Container#add(Comonent,int)允许您按照所需的正确顺序移动对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM