
package interfazgrafica12;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.WindowConstants;

public class InterfazGrafica12 extends JFrame {

    public InterfazGrafica12() {
        Dimension dimension = getToolkit().getScreenSize();
        setSize(dimension);
        setMinimumSize(new Dimension(700, 500));
        setExtendedState(this.MAXIMIZED_BOTH);
        setTitle("Prueba Layouts");
        ubicarComponentes();
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        pack();
        setVisible(true);
    }
 
    private void ubicarComponentes() {
        //   JFrame configurado BorderLayout
        setLayout(new BorderLayout());
        JButton[] jButton = new JButton[10];
        JLabel[] jLabel = new JLabel[20];
        //   JPanel ocupa BorderLayout.NORTH configurado FlowLayout
        JPanel jPanel1 = new JPanel();
        jPanel1.setLayout(new FlowLayout());
        jPanel1.setBackground(Color.CYAN);         
        add(jPanel1, BorderLayout.NORTH); 
        for (int i=0; i<3; i++)
        {
           jButton[i] = new JButton("botón "+i);
           jPanel1.add(jButton[i]);
        }
        //   JPanel ocupa BorderLayout.SOUTH configurado FlowLayout
        JPanel jPanel2 = new JPanel();
        jPanel2.setLayout(new FlowLayout());
        jPanel2.setBackground(Color.CYAN);
        add(jPanel2, BorderLayout.SOUTH);        
        for (int i=3; i<6; i++)
        {
           jButton[i] = new JButton("botón "+i);
           jPanel2.add(jButton[i]);
        }     
        //   JPanel ocupa BorderLayout.WEST configurado FlowLayout
        JPanel jPanel3 = new JPanel();
        jPanel3.setLayout(new FlowLayout());
        jPanel3.setBackground(Color.green);
        add(jPanel3, BorderLayout.WEST);        
        for (int i=6; i<8; i++)
        {
           jButton[i] = new JButton("botón "+i);
           jPanel3.add(jButton[i]);
        }     
        //   JPanel ocupa BorderLayout.EAST configurado FlowLayout
        JPanel jPanel4 = new JPanel();
        jPanel4.setLayout(new FlowLayout());
        jPanel4.setBackground(Color.green);
        add(jPanel4, BorderLayout.EAST);       
        for (int i=8; i<10; i++)
        {
           jButton[i] = new JButton("botón "+i);
           jPanel4.add(jButton[i]);
        }               
        //   JPanel ocupa BorderLayout.CENTER configurado GridLayout
        JPanel jPanel5 = new JPanel();
        jPanel5.setLayout(new GridLayout(5, 4));
        add(jPanel5, BorderLayout.CENTER);        
        for (int i=0; i<20; i++)
        {
           jLabel[i] = new JLabel("etiqueta "+i);
           jPanel5.add(jLabel[i]);
        }                       
    }
    
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
              @Override
              public void run() {
                 new InterfazGrafica12();
              }
           });  
    }        
}
