i want by flow lay out that after adding two component next component should be added on the next line
That is not the way FlowLayout is designed to work. You need to use a different layout manager or combination of layout managers:
1. You could use a GridLayout. For example.
GridLayout layout = new GridLayout(0, 2); This will wrap components to a new line after 2 columns have been filled. However, all components will be the same size.
2. You could use a GridBagLayout. In this case you need to specify the row/column of each component you add so you manually create your grid.
3. You could use a vertical BoxLayout. Then you create child panels to add to the layout. Each child panel can contain a panel using a FlowLayout with two components.
Read the Swing tutorial on
Layout Managers for more information and examples.
You can also have the FlowLayout dynamically flow components to a new line as the components fill the current line. So as the frame is resized the components will wrap as required. See:
Wrap Layout.