不知道下面的代码有什么错误的地方,我设想使用图形界面来运行的
importjava.applet.*;importjava.awt.*;;importjava.awt.event.*;importjava.util.*;public...
import java.applet.*;
import java.awt.*;;
import java.awt.event.*;
import java.util.*;
public class JavaAppGraphicsInOut extends Applet implements ActionListener
{
Label prompt;
TextField input,output;
Button btn;
Image myImage;
JavaAppGraphicsInOut()
{
prompt=new Label("请输入您猜的数字");
input=TextField(6);
output=TextField(6);
btn=new Button("关闭");
myImage=getImage(getDocumentBase(),"congratuations.gif");
setLayout(new FlowLayout());
add(prompt);
add(input);
add(output);
add(btn);
input.addActionListener(this);
btn.addActionListener(this);
setSize(600,450);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
output.setText(input.getText());
}
public void paint(Graphics g)
{
g.drawString("您要加油啊",20,60);
g.drawImage(myImage,30,80,this);
}
}
public void GuessNumber()
{
System.out.println("请输入一个数字:");
int lintTargetNum=30;
后面的补充不上来了 展开
import java.awt.*;;
import java.awt.event.*;
import java.util.*;
public class JavaAppGraphicsInOut extends Applet implements ActionListener
{
Label prompt;
TextField input,output;
Button btn;
Image myImage;
JavaAppGraphicsInOut()
{
prompt=new Label("请输入您猜的数字");
input=TextField(6);
output=TextField(6);
btn=new Button("关闭");
myImage=getImage(getDocumentBase(),"congratuations.gif");
setLayout(new FlowLayout());
add(prompt);
add(input);
add(output);
add(btn);
input.addActionListener(this);
btn.addActionListener(this);
setSize(600,450);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
output.setText(input.getText());
}
public void paint(Graphics g)
{
g.drawString("您要加油啊",20,60);
g.drawImage(myImage,30,80,this);
}
}
public void GuessNumber()
{
System.out.println("请输入一个数字:");
int lintTargetNum=30;
后面的补充不上来了 展开
展开全部
while(true)
{
int lintGuessNumber=scaner.nextInt();
if(lintGuessNumber>lintTargetNum)
{
System.out.println("太大了");
continue;
}else if(lintGuessNumber<lintTargetNum)
{
System.out.println("太小了");
continue;
}else
{
System.out.println("祝贺你猜对了");
break;
}
}
//每种情况都要考虑到
{
int lintGuessNumber=scaner.nextInt();
if(lintGuessNumber>lintTargetNum)
{
System.out.println("太大了");
continue;
}else if(lintGuessNumber<lintTargetNum)
{
System.out.println("太小了");
continue;
}else
{
System.out.println("祝贺你猜对了");
break;
}
}
//每种情况都要考虑到
2011-03-09
展开全部
好的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询