Return to Snippet

Revision: 61112
at November 28, 2012 23:44 by remyor09


Initial Code
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ejerciciorectangulo;

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

/**
 *
 * @author Admin
 */
public class FillRect extends Applet implements AdjustmentListener {

    Scrollbar deslizador1,deslizador2,deslizador3;
    String etiq_desl1,etiq_desl2,etiq_desl3;
    int val_desl1 = 0;
    int val_desl2 = 0;
    int val_desl3 = 0;
    
    /**
     * Initialization method that will be called after the applet is loaded
     * into the browser.
     */
    public void init() {
        deslizador1 = new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,255);
        deslizador2 = new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,255);
        deslizador3 = new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,255);
        add(deslizador1);
        add(deslizador2);
        add(deslizador3);
        deslizador1.addAdjustmentListener(this);
        deslizador2.addAdjustmentListener(this);
        deslizador3.addAdjustmentListener(this);
    }
    
    public void paint(Graphics g) {
        g.setColor(new Color(val_desl1,val_desl2,val_desl3));
        g.drawRect(0,0,150,300);
        g.fillRect(0,0,150,300);
        
        g.setColor(Color.black);
        g.drawString(etiq_desl1,30,100);
        g.drawString(etiq_desl2,30,150);
        g.drawString(etiq_desl3,30,200);
       
    }
    
    
    public void adjustmentValueChanged(AdjustmentEvent ae) {
        val_desl1 = deslizador1.getValue();
        val_desl2 = deslizador2.getValue();
        val_desl3 = deslizador3.getValue();
        etiq_desl1 = "deslizador 1 " + val_desl1;
        etiq_desl2 = "deslizador 2 " + val_desl2;
        etiq_desl3 = "deslizador 3 " + val_desl3;
        repaint();
    }

      
}

Initial URL

                                

Initial Description
Ejercicio 1 Semana 1 - Curso Desarrollo de aplicaciones con Interfaz Gráfica, Manejo de Eventos, Clases y Objetos : Java.
www.senavirtual.edu.co

Initial Title
Ejercicio 1 Semana 1 - Curso Desarrollo de aplicaciones con Interfaz Gráfica, Manejo de Eventos, Clases y Objetos : Java

Initial Tags

                                

Initial Language
Java