4

I'd like to use swing for a scala GUI. The application state is handled by akka actors and may be restored with its fault tolerance.

I'd like to restore application after a swing fault. I've found several recipes for java programmers for establishing EDT exceptions handler as well as creating EDT proxy. What is the scala way for handling swing exceptions? Does scala wrapper provide better tools?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
ayvango
  • 5,867
  • 3
  • 34
  • 73
  • If there is a solution in Java then you can apply it directly in scala unless your code needs to be 100% scala. – Syed Ali Jul 02 '12 at 10:50
  • it is ok, I'd converted the java code to scala and it workd perfectly. But it is quite verbose. Just like my code for passing works to EDT thread until I discovered built-in onEDT function introduced in scala swing wrapper. So I was hopping that a ready to use wrapper is already packed to scala swing – ayvango Jul 29 '13 at 02:40

1 Answers1

0

Scala permits a Java-like style of coding in most circumstances. More specifically, a try/catch block can be used in scala. However, the syntax is slightly different for the catch block.

catch {
  case e: ExceptionTypeOne => //fill in
  case e: ExceptionTypeTwo => //fill in
  case e: ExceptionTypeThree => //fill in
}

As you can see, the catch catches all exceptions, then sets up a Scala style switch.

I'm not quite a Scala expert or anything, I owe the exact syntax of my answer to this site