Tema: Java Basico
Ver Mensaje Individual
  #4 (permalink)  
Antiguo 03/03/2015, 06:08
hagapito
 
Fecha de Ingreso: septiembre-2005
Mensajes: 7
Antigüedad: 18 años, 7 meses
Puntos: 0
Respuesta: Java Basico

Cita:
Iniciado por Xerelo Ver Mensaje
putValue ¿de qué objeto?
es un JButon, y putValue corresponde a la clase AbstracAccion


class PanelAccion extends JPanel{

public PanelAccion(){

AccionColor accionAzul= new AccionColor("Azul",new ImageIcon("src/pruebas/azul.png"),"Ctrl-B", Color.BLUE);

AccionColor accionAmarillo= new AccionColor("Amarillo",new ImageIcon("src/pruebas/amarillo.png"),"Ctrl-Y", Color.YELLOW);

AccionColor accionRojo= new AccionColor("Rojo",new ImageIcon("src/pruebas/rojo.png"),"Ctrl-R", Color.RED);


add(new JButton(accionAzul));

add(new JButton(accionAmarillo));

add(new JButton(accionRojo));

}

private class AccionColor extends AbstractAction{

public AccionColor(String nombre, Icon icono, String atajo, Color colorBoton){

putValue(Action.NAME, nombre);
putValue(Action.SMALL_ICON, icono);
putValue(Action.SHORT_DESCRIPTION, "Cambia el color de la fuente seleccionada al color " + nombre );
putValue("colorDeFondo", colorBoton);


}

public void actionPerformed(ActionEvent e) {

Color c = (Color) getValue("colorDeFondo");

setBackground(c);

}


}


}