这是我的代码:
packagejavaproject;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Game implements Runnable {
public void run() {
// Top-level frame display the Title of the game
final JFrame frame = new JFrame("Tron");
frame.setBackground(Color.BLACK);
frame.setPreferredSize(new Dimension(500,560));
frame.setLocation(400, 100);
frame.setResizable(false);
// main menu panel
final JPanel mainMenu = new JPanel();
mainMenu.setLayout(new BorderLayout());
mainMenu.setBackground(Color.BLACK);
// main menu screen image
@SuppressWarnings("serial")
final JComponent pict = new JComponent() {
public void paintComponent(Graphics gc) {
super.paintComponent(gc);
Picture.draw(gc, "image", 0, 0);
}
};
它运行,但是无法显示图像,它显示:“无法读取输入文件!”。如何用完图像?谢谢。 图像文件是
答案 0 :(得分:0)
您是否正在尝试获取最后第三行中引用的“图像”文件?如果是这样,可能是因为没有文件扩展名吗?