0

我正在尝试从本地目录打开一个 jpg 图像文件,然后简单地将其绘制到屏幕上。

这是代码,但是图像位置没有引用并出现各种错误!

错误是:“找不到符号变量 g”,指的是我努力绘制图像的位置(见代码底部附近)

我是一个学习者——很抱歉,如果它很明显!感谢帮助:-)

import comp102.*;
import java.util.Scanner;
import java.awt.*;


/** A program that plays Rock-Paper-Scissors with the user.
*/
public class RPS{

    String paper = "paper";
    String rock = "rock";
    String scissors = "scissors";    

        /** Play one round of RPS and print out the choices and the result */
    public void playRound(){

        String paper = "paper";
        String rock = "rock";
        String scissors = "scissors";    

        System.out.print ('\f'); // clears screen
        Scanner currentUserSelection = new Scanner(System.in);

        UI.initialise();
        String enterText = null;
        System.out.println("Make your Selection; Paper, Rock or Scissors: ");
        enterText = currentUserSelection.next();

        if(enterText == paper){
        drawImage("paper-left.jpg", 100, 100, null);
        }

    }

}
4

1 回答 1

0

用 Graphics 设置变量

public void paint(Graphics g){
//image code
}
于 2013-10-29T07:41:49.587 回答