-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6.FlowLayout.java
More file actions
35 lines (29 loc) · 1.19 KB
/
6.FlowLayout.java
File metadata and controls
35 lines (29 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import javax.swing.*;
import java.awt.*;
public class Main{
public static void main(String[] args){
//Layout Manager = Defines the natural layout for components within a container..
//FlowLayout = Place components in a row,sized at their prefer size. If the horizontal space in the
// container is too small the flowlayout class uses the next available row..
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500,500);
frame.setTitle("Hello");
frame.setLayout(new FlowLayout(FlowLayout.CENTER,10,10));
JPanel panel = new JPanel();
panel.setPreferredSize(new Dimension(250,250));
panel.setBackground(Color.darkGray);
panel.setLayout(new FlowLayout());
panel.add(new JButton("1"));
panel.add(new JButton("2"));
panel.add(new JButton("3"));
panel.add(new JButton("4"));
panel.add(new JButton("5"));
panel.add(new JButton("6"));
panel.add(new JButton("7"));
panel.add(new JButton("8"));
panel.add(new JButton("9"));
frame.add(panel);
frame.setVisible(true);
}
}