New Line in FlowLayout
I have an assignment to make a form in an Applet. I have run into a seemingly minimal problem that has cost me about 2 hours. Is it possible to force a component in a FlowLayout to move to the next line down? I want 3 text fields on top, 3 in the middle, and 2 buttons on the bottom. Under the buttons, I need to output what was typed on individual lines. Is this possible?
FlowLayout was not designed for this. Instead try something like this:
Make a separate JPanel for each row of three JTextFields. Use the default FlowLayout for these panels.
You now have three panels each containing three textFields.
Make another JPanel with a GridLayout with zero rows and one column (new Gridlayout(0,1))and add the three panels to it.
Set the layout for the Applet to BorderLayout and add this panel to the center section of the BorderLayout.
You can make up the lower output component(s) and add them to the south section of the BorderLayout.
This is referred to as using nested layouts.