***************************************************************************
COMPLETE SOURCE CODE FOR : FlowLayoutForJFrame.java
***************************************************************************
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.FlowLayout;
public class FlowLayoutForJFrame
{
public static void main(String[]args)
{
//Create a JFrame with title ( Set JFrame layout manager using Flow Layout )
JFrame frame=new JFrame("Set JFrame layout manager using Flow Layout");
//Set JFrame layout to Flow Layout
frame.setLayout(new FlowLayout());
//Create 6 buttons that want to add into JFrame
JButton button1=new JButton("BUTTON 1");
JButton button2=new JButton("BUTTON 2");
JButton button3=new JButton("BUTTON 3");
JButton button4=new JButton("BUTTON 4");
JButton button5=new JButton("BUTTON 5");
JButton button6=new JButton("BUTTON 6");
//Add all button into JFrame
frame.add(button1);
frame.add(button2);
frame.add(button3);
frame.add(button4);
frame.add(button5);
frame.add(button6);
//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Set JFrame size with
//Width = 600 pixels
//Height = 400 pixels
frame.setSize(600,400);
//Make JFrame visible. So we can see it.
frame.setVisible(true);
}
}
***************************************************************************
JUST COMPILE AND EXECUTE IT
***************************************************************************