This page is no longer maintained — Please continue to the home page at

Mixin question

No replies
Joined: 2008-12-18,
User offline. Last seen 45 weeks 4 days ago.

I try to do something like this:
new MyFrame with BlueTheme

abstract class MyFrame extends JFrame with Theme {

trait Theme { def aColor:Color }

trait BlueTheme extends Theme { def aColor = Color.BLUE }

That works when I use defs. If I use vals instead in Theme and BlueTheme (or only in BlueTheme) it prints null. OK, I kind of understand this, it's obviously some initialization order issue. What I don't understand is why even this doesn't work:

trait BlueTheme extends Theme { private val blue = Color.BLUE; def aColor = blue }

I just don't grok it :-/

Could you please enlight me? I have the feeling I'm doing something stupid...

Merry Christmas!
View this message in context: Mixin question
Sent from the Scala - User mailing list archive at

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland