title: Image files and relative paths in scala
body: <p>I am trying to access some images for from image panel using a relative path.  In the Eclipse project I have a folder named images with on image inside.  Here is my code:</p>
  
  <pre><code>  val top = new MainFrame {
  
      title = "Predator and Prey Agent simulation"
  
      val buttonExit = new Button {
        text = "Exit"
        action = Action("Exit") {
          WorldActor.run(false)
          closer
        }
      }
  
      val buttonStart = new Button {
        text = "Start"
        action = Action("Start") {
          switchPanes()
        }
      }
  
      val s = new Dimension(500, 700)
  
      contents = new ImagePanel(0, 1) {
        for (i &lt;- 0 until 5){
          contents+= new Label("")
        }
        contents += buttonStart
        contents += buttonExit
        contents+= new Label("")
  
        minimumSize = s
        maximumSize = s
        preferredSize = s
        imagePath = ("\\PredatorPrey\\images\\gnp-canadian-lynx-kitten.jpg")
  
        }
      }
  </code></pre>
  
  <p>Every time the above code runs I get a javax.imageio.IIOException.  Here is the imapePanel class:</p>
  
  <pre><code>case class ImagePanel(rows0: Int, cols0: Int) extends GridPanel(rows0, cols0) {
    private var _imagePath = ""
    private var bufferedImage: BufferedImage = null
  
    def imagePath = _imagePath
  
    def imagePath_=(value: String) {
      _imagePath = value
      bufferedImage = ImageIO.read(new File(_imagePath))
    }
  
    override def paintComponent(g: Graphics2D) = {
      if (null != bufferedImage) g.drawImage(bufferedImage, 0, 0, null)
      }
    }
  </code></pre>
  
  <p>Does anyone know how to fix that path?</p>