The FlowLayout class:
The next layout we will examine is FlowLayout. This is the default layout for JPanel, but has to be explicitly requested for JFrame. This layout places the items in the order in which they are added. If there isn't enough room on a line to include all of the components then they will flow onto the next line.
public class FrameDemoTest
{
public static void main (String [] args)
{
FrameDemo fd = new FrameDemo("We Love Java");
fd.setVisible(true);
}
}
import java.awt. *;
import javax.swing. *;
public class FrameDemo extends JFrame
{
private final int numOfBut = 20;
private JButton [] buttons = new JButton [numOfBut ];
public FrameDemo (String title)
{
setSize(300, 300);
setTitle(title);
/* Create some buttons. */
for (int i = 0; i < numOfBut; i++)
{
buttons [i ] = new JButton("Button " + i);
}
/* Place some buttons. */ Container cp = getContentPane( ); cp.setLayout(new FlowLayout( )); for (int i = 0; i < numOfBut; i++)
{
cp.add(buttons [i ]);
}
}
}
The resulting display is shown in Figure (overleaf).
![1757_flow layout class.png](https://www.expertsmind.com/../CMSImages/1757_flow layout class.png)
Java Assignment Help - Java Homework Help
Struggling with java programming language? Are you not finding solution for your The FlowLayout class homework and assignments? Live The FlowLayout class experts are working for students by solving their doubts & questions during their course studies and training program. We at Expertsmind.com offer The FlowLayout class homework help, java assignment help and The FlowLayout class projects help anytime from anywhere for 24x7 hours. Computer science programming assignments help making life easy for students.
Why Expertsmind for assignment help
- Higher degree holder and experienced experts network
- Punctuality and responsibility of work
- Quality solution with 100% plagiarism free answers
- Time on Delivery
- Privacy of information and details
- Excellence in solving java programming language queries in excels and word format.
- Best tutoring assistance 24x7 hours