DL1997 2017-02-11 07:53 采纳率: 33.3%
浏览 3666

为什么图片加载不出来?

public class text2 extends Frame{

Image img = GameUtil.getImage("images/fly.jpg");


public void launchFrame(){
    setSize(500,300);
    setLocation(0,0);
    setVisible(true);

    addWindowListener(new WindowAdapter(){
        public void windowClosing(WindowEvent e){
            System.exit(0);
        }//点关闭可以关闭窗口
    });

}
public void paint(Graphics g){
Color c = g.getColor();
g.setColor(Color.blue);
g.drawOval(100, 100, 100, 100);
g.drawImage(img, 200, 200, null);
}

public static void main(String args[]){
    text2 t1 = new text2();
    t1.launchFrame();
}

}
报错跳转为
public static BufferedImage read(URL input) throws IOException {
if (input == null) {
throw new IllegalArgumentException("input == null!");
}

  • 写回答

3条回答 默认 最新

  • ljheee 2017-02-11 08:40
    关注

    setVisible(true);放在main方法里面

    评论

报告相同问题?

悬赏问题

  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题
  • ¥15 github训练的模型参数无法下载
  • ¥15 51单片机显示器问题
  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案
  • ¥50 winform中使用edge的Kiosk模式
  • ¥15 关于#python#的问题:功能监听网页