How to make a Scala Applet whose Applet class is a singleton?

Posted by Jamie on Stack Overflow See other posts from Stack Overflow or by Jamie
Published on 2010-03-27T18:37:53Z Indexed on 2010/03/27 18:43 UTC
Read the original article Hit count: 250

Filed under:
|
|
|
|

Hi, I don't know if a solution exists but it would be highly desirable.

I'm making a Scala Applet, and I want the main Applet class to be a singleton so it can be accessed elsewhere in the applet, sort of like:

object App extends Applet {
  def init {
    // do init here
  }
}

Instead I have to make the App class a normal instantiatable class otherwise it complains because the contructor is private. So the ugly hack I have is to go:

object A {
  var pp: App = null
}

class App extends Applet {
  A.pp = this
  def init {
    // do init here
  }
}

I really hate this, and is one of the reasons I don't like making applets in Scala right now.

Any better solution? It would be nice...

© Stack Overflow or respective owner

Related posts about scala

Related posts about applet