- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Scala.swing's SimpleGUIApplication creates TWO frames ??
Tue, 2009-03-10, 09:33
Hello all,
Today I started trying out scala.swing to get
an impression about how Scala simplifies the
annoying Swing boilerplate coding.
The stairway book as well as the examples under scala.swing.test
start by extending SimpleGUIApp and defining the method
'top' to create a new MainFrame.
I wanted to know what the 'initialising the framework' stuff
is about and was surprised to find in the SimpleGUIApplication's
main method:
SwingUtilities.invokeLater {
new Runnable { def run() { init(); top.pack(); top.visible = true
} }
}
So: two times called top ???
And right, if you rewrite the book's first example like this,
you get FRAME printed twice:
def top = new MainFrame {
println ("FRAME" + this.toString())
title = "First Swing App"
contents = new Button {
text = "Click me"
}
}
And with the method defined as:
def top:MainFrame = {
val x = new MainFrame {
title = "First Swing App"
contents = new Button {
text = "Click me"
}
}
x.pack(); x.visible = true;
x
}
both frames get visible (you have to drag the first one
to see the other).
I think that is a bug (unfortunately https is blocked
from my company's net, so no Trac access here) and my question is,
if extending SimpleGUIApplication resp. GUIApplication is indeed
the recommended way to build GUIs with scala.swing?
KR
Det
Oh man, I thought I fixed that. Fixed in trunk now. In the future, top
should probably be a val, but that would break things right now.
Ingo
Detering Dirk wrote:
> Hello all,
>
> Today I started trying out scala.swing to get
> an impression about how Scala simplifies the
> annoying Swing boilerplate coding.
>
> The stairway book as well as the examples under scala.swing.test
> start by extending SimpleGUIApp and defining the method
> 'top' to create a new MainFrame.
>
> I wanted to know what the 'initialising the framework' stuff
> is about and was surprised to find in the SimpleGUIApplication's
> main method:
>
> SwingUtilities.invokeLater {
> new Runnable { def run() { init(); top.pack(); top.visible = true
> } }
> }
>
> So: two times called top ???
>
> And right, if you rewrite the book's first example like this,
> you get FRAME printed twice:
>
> def top = new MainFrame {
> println ("FRAME" + this.toString())
> title = "First Swing App"
> contents = new Button {
> text = "Click me"
> }
> }
>
> And with the method defined as:
>
> def top:MainFrame = {
> val x = new MainFrame {
> title = "First Swing App"
> contents = new Button {
> text = "Click me"
> }
> }
> x.pack(); x.visible = true;
> x
> }
>
> both frames get visible (you have to drag the first one
> to see the other).
>
> I think that is a bug (unfortunately https is blocked
> from my company's net, so no Trac access here) and my question is,
> if extending SimpleGUIApplication resp. GUIApplication is indeed
> the recommended way to build GUIs with scala.swing?
>
> KR
> Det
>
>
>
>
>
>