miércoles, 3 de junio de 2009

CircleTemp




package temperatura;

import javax.swing.JApplet;
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JOptionPane;

public class CircleTemp extends JApplet {

/**
* Initialization method that will be called after the applet is loaded
* into the browser.
*/
public void init() {
// TODO start asynchronous download of heavy resources
}

public void paint(Graphics g){

g.drawString("TEMPERATURA", 120, 30);
g.drawOval(100, 50, 100,100 );
String aux = JOptionPane.showInputDialog(null,"INGRESE EL VALOR DE LA TEMPERATURA","titulo",JOptionPane.DEFAULT_OPTION);
int temp = Integer.parseInt(aux);
g.drawString("+"+temp+" C", 230, 200-temp);
g.setColor(Color.BLUE);
if(temp >80){
g.setColor(Color.RED);

g.drawString("ALERTA", 230 , 90);
g.fillArc(100, 50,100 ,100 ,0, (temp*360)/100);
}
g.fillArc(100, 50,100 ,100 ,0,(temp*360)/100);

}
}

2 comentarios: