JFrame with FlowLayout

The FlowLayout arrange the components from the upper left corner, left to right and top to bottom. When no more components fit on a line, the next one appears on the next line. A small space is left between every components on each side.

Program 

1 - Copy

 

 

 

Program Source

import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.FlowLayout;

class Frame extends JFrame{
 
    Frame()
    {
        setTitle("FlowLayout");
        setLayout(new FlowLayout());
        JLabel jl = new JLabel("JLabel");
        add(jl);
        setSize(700, 200);
        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}

public class Javaapp {
 
    public static void main(String[] args) {
     
        Frame frame = new Frame();
    }
}

Leave a Comment