REALIZAR UN OVALO DEFINIDO POR EL USUARIO
import java.applet.Applet;
import java.awt.Graphics;
import javax.swing.*;
public class Ovala extends Applet {
int x,y,w,h;
public void init(){
String posicionX,posicionY, ancho, altura;
posicionX=JOptionPane.showInputDialog("Ingrese posicion en X");
posicionY=JOptionPane.showInputDialog("Ingrese posicion en Y");
ancho=JOptionPane.showInputDialog("Ingrese ancho del ovalo");
altura=JOptionPane.showInputDialog("Ingrese altura del ovalo");
x=Integer.parseInt(posicionX);
y=Integer.parseInt(posicionY);
w=Integer.parseInt(ancho);
h=Integer.parseInt(altura);
}
//realizando el dibujo
public void paint(Graphics s)
{
s.drawOval(x,y,w,h);
s.drawString("OVALO",x+50,y+50);
}
}
No hay comentarios:
Publicar un comentario