JLabel icon = new JLabel();
icon.setIcon(new ImageIcon("back.jpg"));
back.jpg难道只能用绝对路径吗?这样在当前目录下居然找不到文件.
请教为什么...

解决方案 »

  1.   

    public ImageIcon(String filename)Creates an ImageIcon from the specified file. The image will be preloaded by using MediaTracker to monitor the loading state of the image. The specified String can be a file name or a file path. When specifying a path, use the Internet-standard forward-slash ("/") as a separator. (The string is converted to an URL, so the forward-slash works on all systems.) For example, specify: 
        new ImageIcon("images/myImage.gif") The description is initialized to the filename string.
      

  2.   

    icon.setIcon(new ImageIcon(getClass().getResource("/account/back.jpg")));
    改成这样应该可以了说.
      

  3.   

    再请教一下,在NetBeans下"运行环境"里的数据库连接应该如何写?
    "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=mon.mdb"
    提示"无法连接到".
      

  4.   

    忘了说,连接的是ACCESS数据库.