import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.*;
import javax.swing.text.View;
public class MyFrame extends JFrame {
private JPanel p1 = new JPanel();
private JPanel p2 = new JPanel();
private JPanel p3 = new JPanel();
private static String titolo = "Prima finestra";
private JButton bott1 = new JButton("1");
private JButton bott2 = new JButton("2");
private JButton bott3 = new JButton("3");
private JButton bott4 = new JButton("4");
private JButton bott5 = new JButton("5");
private JButton bott6 = new JButton("6");
private JButton bott7 = new JButton("7");
private JButton bott8 = new JButton("8");
private JButton bott9 = new JButton("9");
private JButton bott10 = new JButton("10");
private JButton bott11 = new JButton("11");
private JButton bott12 = new JButton("12");
private JButton bott13 = new JButton("13");
private JButton bott14 = new JButton("14");
private JButton bott15 = new JButton("15");
public MyFrame () {
super (titolo);
p1.setLayout(new FlowLayout());
p1.add(bott1);
p1.add(bott2);
p1.add(bott3);
p1.add(bott4);
p1.add(bott5);
p2.setLayout(new BorderLayout());
p2.add(bott6, "Nord");
p2.add(bott7, "Sud");
p2.add(bott8, "Ovest");
p2.add(bott9, "Est");
p2.add(bott10, "Centro");
p3.setLayout(new GridLayout(3,2));
p3.add(bott11);
p3.add(bott12);
p3.add(bott13);
p3.add(bott14);
p3.add(bott15);
setLayout(new GridLayout(6,1));
add(new JLabel ("FLOWLAYOUT",JLabel.CENTER));
add(p1);
add(new JLabel("BORDERLAYOUT", JLabel.CENTER));
add(p2);
add(new JLabel("GRIDLAYOUT",JLabel.CENTER));
add(p3);
pack();
setSize(600, 600);
setLocation(0,0);
setVisible(true);
}
public static void main(String[] args) {
MyFrame f = new MyFrame();
}
}