/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package miaplee;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
//
public class dibujartarropintura2288 extends Applet implements AdjustmentListener {
Scrollbar s;
int barra = 0;
int barra2=99;
public dibujartarropintura2288() {
s = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, 100);
add(s);
s.addAdjustmentListener(this);
}/*
public void repaint2(Graphics g) {
g.drawRect(40, 80, 60, 120);
g.fillRect(40, 80, 60, barra);
}
*/
public void paint(Graphics g) {
if(barra<99){
g.drawRect(40, 80, 60, 100);
g.fillRect(40, 80, 60, barra);
String barrita=String.valueOf(barra);
g.drawString(barrita, 200, 130);
g.drawRect(130, 80, 60, 100);
if(barra2<-1){
g.setColor(Color.BLUE);
g.fillRect(130, 180, 60, barra2);}
}
if(barra==99){
g.setColor(Color.red);
g.fillRect(40, 80, 60, barra);
g.drawString("lleno", 60, 60);
//g.fillRect(40, 80, 60, barra);
// g.fillOval(40, 80, 60, barra);
if(barra2==-99){
g.drawString("100%", 200, 130);
}
}
}
public void adjustmentValueChanged(AdjustmentEvent ae) {
barra = s.getValue();
barra2=-barra;
System.out.println("barra2 es"+barra2+"barra normal es"+barra);
repaint();
}
}
aqui una imagen
0 Comments