Java – converts jtextfield input to integer

I'm a novice in Java. I'm trying to convert the input from jtextfield to an integer. I've tried many options, but there's no work. Eclipse always gives me an error. The error is meaningless to me@ H_ 419_ 7@

public class circle extends Shape{

public int x;
public int y;
public int Radius;

public circle (int Radius,int x,int y,Color c){
    super(c);
    this.x = x;
    this.y = y;
    this.Radius = Radius;
}
    public void draw(Graphics g){
        g.setColor(super.getColor());
        g.fillOval(x-Radius,y-Radius,Radius * 2,Radius * 2);
    }
 }

Solution

Replace: @ h_ 419_ 7@

JTextField f1 = new JTextField("-5");

//xaxis1 = Integer.parseInt(f1);
JTextField f1 = new JTextField("-5");
String text = f1.getText();
int xaxis1 = Integer.parseInt(text);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>