Prezados Amigos:
Sou iniciante no Java e estou c/ difuldades em fazer c/ que uma determinada instância delcarada no inicio da classe, seja ‘vista’ pelos demais métodos da classe. O meu problema está na conversão de dados para o método drawOval da classe Graphics.
este é o meu código:
import java.awt.Graphics;
import javax.swing.*;
public class Cap03Ex18 extends JApplet
{
Integer x,y,width, height;
public void init ()
{
String n1,n2,n3,n4;
n1 = JOptionPane.showInputDialog
(“Enter the value of x”);
n2 = JOptionPane.showInputDialog
(“Enter the value of y”);
n3 = JOptionPane.showInputDialog
(“Enter the value of width”);
n4 = JOptionPane.showInputDialog
(“Enter the value of height”);
x = Integer.parseInt(n1);
y = Integer.parseInt(y);
width = Integer.parseInt(width);
height = Integer.parseInt(height);
}
public void paint (Graphics g)
{
g.drawOval (x,y,width,height);
}
}