forked from FirmanKurniawan/Java-Projects
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFlowLayoutPane.java
More file actions
23 lines (20 loc) · 756 Bytes
/
FlowLayoutPane.java
File metadata and controls
23 lines (20 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import javax.swing.*;
import java.awt.*;
public class FlowLayoutPane {
public static void main(String[] args) {
JFrame frame = new JFrame("FlowLayoutPane");
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
panel.setPrefereedSize(new Dimension(450, 150));
frame.getContentPane().add(panel);
// Add some buttons to demonstrate the layout.
String spaces = ""; // Used to make the buttons different
for(int i = 1; i <= 9; i++) {
panel.add(new Jbutton("Button #" + i + spaces));
spaces += " ";
}
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}