Search code examples
javaswingoopuser-interfaceflowlayout

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. 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.

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);
}
}

Solution

  • MadProgrammer showed me that using Container#add(Comonent, int) allows you to move the objects in the correct order that you want.