用Frame实现的画的播放,部分代码:
public static void main(String [] args){
  Frame f = new Frame("卡片式布局");
  CardLayout c = new CardLayout();
  f.setLayout(c);
  Image im [] = new Image[4];
  for(int i=0;i<4;i++){
  im[i] = getImage(getDocumentBase(),"images\\"+i+".jpg");
  f.add(im[i],"page"+i);
  }
用getImage(getDocumentBase()添加图片出错,报错“The method getDocumentBase() is undefined for the type TestCarLayout”,不知道是怎么回事???

解决方案 »

  1.   

    The method getDocumentBase() is undefined for the type TestCarLayout  意思指在TestCarLayout 中找不到getDocumentBase()这个方法,你就重写一下一个方法好了,在方法中实现你想实现的方法就可以了吧
      

  2.   

    换别的读取方法不行么?我记得有个imageIO
      

  3.   

    其实我的意思就是在Frame中怎么载入一张图片???
      

  4.   

    javax.imageio.ImageIO 或者
    java.awt.Toolkit 的 getImage方法