Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. package botonesappletflowlayout;
  2.  
  3. import java.awt.Color;
  4. import java.awt.FlowLayout;
  5. import javax.swing.JApplet;
  6. import javax.swing.JButton;
  7.  
  8. /**
  9.  *
  10.  * @author Rafa
  11.  */
  12. public class BotonesAppletFlowLayout extends JApplet{
  13.     //declaramos los botones que mostraremos en el applet
  14.     private JButton boton1;
  15.     private JButton boton2;
  16.     private JButton boton3;
  17.     private JButton boton4;
  18.    
  19.     public void init(){
  20.         //establecemos el tipo de composicion
  21.         setLayout(new FlowLayout());
  22.        
  23.         //Creamos los botones
  24.         boton1 = new JButton("Boton1");
  25.         boton2 = new JButton("Boton1");
  26.         boton3 = new JButton("Boton1");
  27.         boton4 = new JButton("Boton4");
  28.        
  29.         //Establece colores a los botones
  30.         boton1.setBackground(Color.green);
  31.         boton2.setBackground(Color.yellow);
  32.         boton3.setBackground(Color.red);
  33.         boton4.setBackground(Color.black);
  34.        
  35.         //agregamos los botones al applet
  36.         add(boton1);
  37.         add(boton2);
  38.         add(boton3);
  39.         add(boton4);
  40.     }
  41.    
  42.     public void start(){
  43.         //eventos(); //en caso que queramos crear eventos para los botones
  44.     }
  45. }