package botonesappletgridlayout;
import java.awt.Color;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import javax.swing.JApplet;
import javax.swing.JButton;
/**
*
* @author Rafa
*/
public class BotonesAppletGridLayout extends JApplet{
//declaramos los botones
private JButton boton1;
private JButton boton2;
private JButton boton3;
private JButton boton4;
public void init(){
//establece tipo de composicion y tamano de matriz(2-2)
setLayout(new GridLayout(2,2));
//creamos los botones
boton1 = new JButton("Boton1");
boton2 = new JButton("Boton2");
boton3 = new JButton("Boton3");
boton4 = new JButton("Boton4");
//Establecemos colores
boton1.setBackground(Color.green);
boton2.setBackground(Color.yellow);
boton3.setBackground(Color.red);
boton4.setBackground(Color.black);
//Agregamos los botones
add(boton1);
add(boton2);
add(boton3);
add(boton4);
}
}