谁来帮我看一下这个Java applet程序那里出错了
编译是通过了但就是显示的都重在一起了啊importjava.applet.Applet;importjava.awt.*;publicclassshowresultsex...
编译是通过了 但就是显示的都重在一起了啊
import java.applet.Applet;
import java.awt.*;
public class showresults extends Applet
{
Label prompt;
TextField input1,input2;
float addition=0,
subtraction=0,
multiplication=0,
division=0,
average=0,max=0;
public void init()
{
prompt=new Label("Enter the int and float:");
input1=new TextField(3);
input2=new TextField(3);
add(prompt);
add(input1);
add(input2);
}
public void paint(Graphics g)
{
g.drawString("x+y="+addition,50,80);
g.drawString("x-y="+subtraction,50,80);
g.drawString("x*y="+multiplication,50,80);
g.drawString("x/y="+division,50,80);
g.drawString("Average="+average,50,80);
g.drawString("Max="+max,50,80);
}
public boolean action(Event e,Object o)
{
int x;
float y;
if(e.target==input2)
{
x=Integer.parseInt(input1.getText());
y=Float.valueOf(input2.getText()).floatValue();
addition=x+y;
subtraction=x-y;
multiplication=x*y;
division=x/y;
average=(x+y)/2;
max=x>y?x:y;
repaint();
}
return true;
}
} 展开
import java.applet.Applet;
import java.awt.*;
public class showresults extends Applet
{
Label prompt;
TextField input1,input2;
float addition=0,
subtraction=0,
multiplication=0,
division=0,
average=0,max=0;
public void init()
{
prompt=new Label("Enter the int and float:");
input1=new TextField(3);
input2=new TextField(3);
add(prompt);
add(input1);
add(input2);
}
public void paint(Graphics g)
{
g.drawString("x+y="+addition,50,80);
g.drawString("x-y="+subtraction,50,80);
g.drawString("x*y="+multiplication,50,80);
g.drawString("x/y="+division,50,80);
g.drawString("Average="+average,50,80);
g.drawString("Max="+max,50,80);
}
public boolean action(Event e,Object o)
{
int x;
float y;
if(e.target==input2)
{
x=Integer.parseInt(input1.getText());
y=Float.valueOf(input2.getText()).floatValue();
addition=x+y;
subtraction=x-y;
multiplication=x*y;
division=x/y;
average=(x+y)/2;
max=x>y?x:y;
repaint();
}
return true;
}
} 展开
1个回答
展开全部
g.drawString("x+y="+addition,50,80);
g.drawString("x-y="+subtraction,50,80);
g.drawString("x*y="+multiplication,50,80);
g.drawString("x/y="+division,50,80);
g.drawString("Average="+average,50,80);
g.drawString("Max="+max,50,80);
=======================================
怎么全是50,80呀,
坐标全部重叠了,
把它们改成不同的数字就行了。
g.drawString("x-y="+subtraction,50,80);
g.drawString("x*y="+multiplication,50,80);
g.drawString("x/y="+division,50,80);
g.drawString("Average="+average,50,80);
g.drawString("Max="+max,50,80);
=======================================
怎么全是50,80呀,
坐标全部重叠了,
把它们改成不同的数字就行了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询