Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. package appletbotones;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.Button;
  5. import java.awt.Color;
  6. import java.awt.Font;
  7. import javax.swing.JApplet;
  8. import javax.swing.JButton;
  9.  
  10. /**
  11.  *
  12.  * @author Rafa
  13.  */
  14. public class AppletBotones extends JApplet{
  15.     public JButton bt1, bt2, bt3, bt4, bt5;
  16.    
  17.     public AppletBotones() {
  18.         //Crea los botones
  19.         bt1 = new JButton("Norte");
  20.         bt2 = new JButton("Sur");
  21.         bt3 = new JButton("Este");
  22.         bt4 = new JButton("Oeste");
  23.         bt5 = new JButton("Centro");
  24.        
  25.         //Establece colores a los botones y al nombre
  26.         bt1.setBackground(Color.red);
  27.         bt2.setBackground(Color.CYAN);
  28.         bt3.setBackground(Color.YELLOW);
  29.         bt4.setBackground(Color.ORANGE);
  30.         bt5.setBackground(Color.black);
  31.         bt1.setForeground(Color.GREEN);
  32.         bt4.setForeground(Color.WHITE);
  33.     } //fin del constructor
  34.    
  35.     //Se ejecuta al cargar el Applet
  36.     public void init() {
  37.         setLayout(new BorderLayout());
  38.         setFont(new Font("Arial", Font.PLAIN, 14)); //Establece tipo, tamano de letra
  39.        
  40.         //Agrega los botones al Applet
  41.         add(bt1, BorderLayout.NORTH);
  42.         add(bt2, BorderLayout.SOUTH);
  43.         add(bt3, BorderLayout.EAST);
  44.         add(bt4, BorderLayout.WEST);
  45.         add(bt5, BorderLayout.CENTER);
  46.        
  47.     } //Fin metodo init()
  48.    
  49. } //Fin de la clase