- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
scala.swing documentation
Thu, 2009-02-19, 19:50
hi,
i'm looking for a substantial scala.swing documentation, tutorial if
possible. google doesn't help. the API docs are more or less empty...
simple things like how is supposed to work panel composition etc.
thanks for pointers!
ciao, -sciss-
Thu, 2009-02-19, 20:17
#2
Re: scala.swing documentation
perfect!
the approach with "content +=" looks quite awkward to me, though...
why was this design chosen?
ciao, -sciss-
Am 19.02.2009 um 19:52 schrieb Alex Cruise:
> Sciss wrote:
>> i'm looking for a substantial scala.swing documentation, tutorial
>> if possible. google doesn't help. the API docs are more or less
>> empty... simple things like how is supposed to work panel
>> composition etc.
> I'm not aware of any documentation per se, but the source code from
> the Programming in Scala book is available at http://
> booksites.artima.com/programming_in_scala/examples/ (ch. 32 & 33)
> and should get you off and running.
>
> -0xe1a
Thu, 2009-02-19, 20:37
#3
Re: scala.swing documentation
What in particular do you find awkward about content? It is a Seq in
container, and a Buffer for sequential containers. Unlike Java Swing,
the Scala wrappers intregate with existing collections.
I will try to improve documentation for 2.7.4.
Ingo
Sciss wrote:
> perfect!
>
> the approach with "content +=" looks quite awkward to me, though...
> why was this design chosen?
>
> ciao, -sciss-
>
>
> Am 19.02.2009 um 19:52 schrieb Alex Cruise:
>
>> Sciss wrote:
>>> i'm looking for a substantial scala.swing documentation, tutorial
>>> if possible. google doesn't help. the API docs are more or less
>>> empty... simple things like how is supposed to work panel
>>> composition etc.
>> I'm not aware of any documentation per se, but the source code from
>> the Programming in Scala book is available at http://
>> booksites.artima.com/programming_in_scala/examples/ (ch. 32 & 33)
>> and should get you off and running.
>>
>> -0xe1a
>
>
Thu, 2009-02-19, 21:07
#4
Re: scala.swing documentation
well... if a Panel is a Container and hence should integrate with a
MutableSeq, i would guess the most elegant way would be something like
new FlowPanel {
+= new Label( "Hallo" )
+= new Button( "Welt" )
}
or
new FlowPanel {
++ List( new Label( "Hallo" ), new Button( "Welt" ))
}
whatever, not so important...
Am 19.02.2009 um 20:24 schrieb Ingo Maier:
> What in particular do you find awkward about content? It is a Seq
> in container, and a Buffer for sequential containers. Unlike Java
> Swing, the Scala wrappers intregate with existing collections.
>
> I will try to improve documentation for 2.7.4.
>
> Ingo
>
> Sciss wrote:
>> perfect!
>> the approach with "content +=" looks quite awkward to me,
>> though... why was this design chosen?
>> ciao, -sciss-
>> Am 19.02.2009 um 19:52 schrieb Alex Cruise:
>>> Sciss wrote:
>>>> i'm looking for a substantial scala.swing documentation,
>>>> tutorial if possible. google doesn't help. the API docs are
>>>> more or less empty... simple things like how is supposed to
>>>> work panel composition etc.
>>> I'm not aware of any documentation per se, but the source code
>>> from the Programming in Scala book is available at http://
>>> booksites.artima.com/programming_in_scala/examples/ (ch. 32 &
>>> 33) and should get you off and running.
>>>
>>> -0xe1a
>
Thu, 2009-02-19, 21:27
#5
Re: scala.swing documentation
I would regard this bad design. First, it looks strange, second, panels
as well as collections are fairly large biests in terms of method count.
The chance of method collision is too high. Size comes to my mind.
Component count or visual size?
Ingo
Sciss wrote:
> well... if a Panel is a Container and hence should integrate with a
> MutableSeq, i would guess the most elegant way would be something like
>
> new FlowPanel {
> += new Label( "Hallo" )
> += new Button( "Welt" )
> }
>
> or
>
> new FlowPanel {
> ++ List( new Label( "Hallo" ), new Button( "Welt" ))
> }
>
>
> whatever, not so important...
>
>
> Am 19.02.2009 um 20:24 schrieb Ingo Maier:
>
>> What in particular do you find awkward about content? It is a Seq
>> in container, and a Buffer for sequential containers. Unlike Java
>> Swing, the Scala wrappers intregate with existing collections.
>>
>> I will try to improve documentation for 2.7.4.
>>
>> Ingo
>>
>> Sciss wrote:
>>> perfect!
>>> the approach with "content +=" looks quite awkward to me,
>>> though... why was this design chosen?
>>> ciao, -sciss-
>>> Am 19.02.2009 um 19:52 schrieb Alex Cruise:
>>>> Sciss wrote:
>>>>> i'm looking for a substantial scala.swing documentation,
>>>>> tutorial if possible. google doesn't help. the API docs are
>>>>> more or less empty... simple things like how is supposed to
>>>>> work panel composition etc.
>>>> I'm not aware of any documentation per se, but the source code
>>>> from the Programming in Scala book is available at http://
>>>> booksites.artima.com/programming_in_scala/examples/ (ch. 32 &
>>>> 33) and should get you off and running.
>>>>
>>>> -0xe1a
>
> .
>
Thu, 2009-02-19, 21:47
#6
Re: scala.swing documentation
BTW, note that there is also the scala.swing.test package with sample
code. People seem to miss that all the time.
Ingo
Alex Cruise wrote:
> Sciss wrote:
>> i'm looking for a substantial scala.swing documentation, tutorial if
>> possible. google doesn't help. the API docs are more or less empty...
>> simple things like how is supposed to work panel composition etc.
> I'm not aware of any documentation per se, but the source code from the
> Programming in Scala book is available at
> http://booksites.artima.com/programming_in_scala/examples/ (ch. 32 & 33)
> and should get you off and running.
>
> -0xe1a
>
Thu, 2009-02-19, 22:17
#7
Re: scala.swing documentation
ok thanks!
Am 19.02.2009 um 21:38 schrieb Ingo Maier:
> BTW, note that there is also the scala.swing.test package with
> sample code. People seem to miss that all the time.
>
> Ingo
>
> Alex Cruise wrote:
>> Sciss wrote:
>>> i'm looking for a substantial scala.swing documentation, tutorial
>>> if possible. google doesn't help. the API docs are more or less
>>> empty... simple things like how is supposed to work panel
>>> composition etc.
>> I'm not aware of any documentation per se, but the source code
>> from the Programming in Scala book is available at http://
>> booksites.artima.com/programming_in_scala/examples/ (ch. 32 & 33)
>> and should get you off and running.
>> -0xe1a
>
Fri, 2009-02-20, 00:37
#8
Re: scala.swing documentation
On Thu, Feb 19, 2009 at 5:15 PM, Ingo Maier <ingo.maier@epfl.ch> wrote:
I would regard this bad design. First, it looks strange, second, panels as well as collections are fairly large biests in terms of method count. The chance of method collision is too high. Size comes to my mind. Component count or visual size?
Talk of design options. I recently did a MigPanel to wrap the MigLayoutManager. I have to say I was impressed at how easy it was:
class MigPanel(layoutConstrains:String, colConstriants:String, rowConstraints:String) extends Panel with SequentialContainer.Wrapper {
override lazy val peer = new javax.swing.JPanel(new MigLayout(layoutConstrains,colConstriants,rowConstraints))
def this(layoutContraints:String) = this(layoutContraints,"","")
private def layoutManager = peer.getLayout.asInstanceOf[MigLayout]
protected def add(c: Component, l: String) { peer.add(c.peer, l) }
protected def add(c: Component) { peer.add(c.peer)}
}
That's all, mixins and some methods, and it was ready. Really cool way of doing things. My question was that I ended up using two 'add' methods: one just to make it easy to remove contraints, and another that adds the contraints. I used the model of the GridBagPanel. It there a more scala.swing way of doing this?
Thanks,
Thomas
Fri, 2009-02-20, 10:17
#9
Re: scala.swing documentation
I recently ported my more functional layout manager to Scala. The core works, but of the stuff in extras/ I've only tested the percent constraints stuff.
http://github.com/rickyclarkson/anylayout/tree/master
I'm planning to improve it as I work on an old broken project that uses it. You can find its original Java form with some example code on Google Code.
I can't believe that layout based on specifying Strings is good enough.
2009/2/19 Thomas Sant Ana <mailleux@gmail.com>
http://github.com/rickyclarkson/anylayout/tree/master
I'm planning to improve it as I work on an old broken project that uses it. You can find its original Java form with some example code on Google Code.
I can't believe that layout based on specifying Strings is good enough.
2009/2/19 Thomas Sant Ana <mailleux@gmail.com>
On Thu, Feb 19, 2009 at 5:15 PM, Ingo Maier <ingo.maier@epfl.ch> wrote:I would regard this bad design. First, it looks strange, second, panels as well as collections are fairly large biests in terms of method count. The chance of method collision is too high. Size comes to my mind. Component count or visual size?
Talk of design options. I recently did a MigPanel to wrap the MigLayoutManager. I have to say I was impressed at how easy it was:
class MigPanel(layoutConstrains:String, colConstriants:String, rowConstraints:String) extends Panel with SequentialContainer.Wrapper {
override lazy val peer = new javax.swing.JPanel(new MigLayout(layoutConstrains,colConstriants,rowConstraints))
def this(layoutContraints:String) = this(layoutContraints,"","")
private def layoutManager = peer.getLayout.asInstanceOf[MigLayout]
protected def add(c: Component, l: String) { peer.add(c.peer, l) }
protected def add(c: Component) { peer.add(c.peer)}
}
That's all, mixins and some methods, and it was ready. Really cool way of doing things. My question was that I ended up using two 'add' methods: one just to make it easy to remove contraints, and another that adds the contraints. I used the model of the GridBagPanel. It there a more scala.swing way of doing this?
Thanks,
Thomas
Fri, 2009-02-20, 12:47
#10
Re: scala.swing documentation
On Fri, Feb 20, 2009 at 6:06 AM, Ricky Clarkson <ricky.clarkson@gmail.com> wrote:
I recently ported my more functional layout manager to Scala. The core works, but of the stuff in extras/ I've only tested the percent constraints stuff.
http://github.com/rickyclarkson/anylayout/tree/master
I'm planning to improve it as I work on an old broken project that uses it. You can find its original Java form with some example code on Google Code.
Do you have samples of how to get the layout in place? I like Mig Layout because of an excellent demo and documentation( found here http://www.miglayout.com/ )
I can't believe that layout based on specifying Strings is good enough.
This is beyond the question. But Mig layout does have a way to declare constraints using classes and methods. I actually thought of wrapping them with scala code, but to me Strings are good enough (after all that's what you do in CSS).
Thomas
Fri, 2009-02-20, 13:37
#11
Re: scala.swing documentation
There is one example of using PercentConstraints, which mimic a previous layout manager I wrote, and that's in src/anylayout/examples
I deleted the other examples when porting from Java to Scala, as I got fed up of compile errors.
Here's a Scala interpreter session that demonstrates it, placing a label at the top left and a button in the middle. This uses AnyLayout at its most raw, generally you'd want to calculate constraints based on other components as well, etc., which is what the stuff in src/anylayout/extras is for.
ricky@ricky-desktop:~/anylayout$ scala -classpath anylayout.jar
Welcome to Scala version 2.8.0.r17079-b20090210164824 (Java HotSpot(TM) Client VM, Java 1.6.0_11).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import anylayout._
import anylayout._
scala> import javax.swing._
import javax.swing._
scala> val frame = new JFrame
frame: javax.swing.JFrame = javax.swing.JFrame[frame0,0,0,0x0,invalid,hidden,layout=java.awt.BorderLayout,title=,resizable,normal,defaultCloseOperation=HIDE_ON_CLOSE,rootPane=javax.swing.JRootPane[,0,0,0x0,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]
scala> import AnyLayout._
import AnyLayout._
scala> useAnyLayout(frame, 0.5f, 0.5f, Size(400, 400), component => throw null)
scala> frame.add(new JLabel("Hello"), Constraint(c => 10, c => 10, _.preferredSize, _.preferredSize))
scala> frame.add(new JButton("World"), Constraint(c => c.parentSize/2 - c.preferredSize/2, c => c.parentSize/2 - c.preferredSize/2, _.preferredSize, _.preferredSize))
scala> frame.pack
scala> frame setVisible true
2009/2/20 Thomas Sant Ana <mailleux@gmail.com>
I deleted the other examples when porting from Java to Scala, as I got fed up of compile errors.
Here's a Scala interpreter session that demonstrates it, placing a label at the top left and a button in the middle. This uses AnyLayout at its most raw, generally you'd want to calculate constraints based on other components as well, etc., which is what the stuff in src/anylayout/extras is for.
ricky@ricky-desktop:~/anylayout$ scala -classpath anylayout.jar
Welcome to Scala version 2.8.0.r17079-b20090210164824 (Java HotSpot(TM) Client VM, Java 1.6.0_11).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import anylayout._
import anylayout._
scala> import javax.swing._
import javax.swing._
scala> val frame = new JFrame
frame: javax.swing.JFrame = javax.swing.JFrame[frame0,0,0,0x0,invalid,hidden,layout=java.awt.BorderLayout,title=,resizable,normal,defaultCloseOperation=HIDE_ON_CLOSE,rootPane=javax.swing.JRootPane[,0,0,0x0,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]
scala> import AnyLayout._
import AnyLayout._
scala> useAnyLayout(frame, 0.5f, 0.5f, Size(400, 400), component => throw null)
scala> frame.add(new JLabel("Hello"), Constraint(c => 10, c => 10, _.preferredSize, _.preferredSize))
scala> frame.add(new JButton("World"), Constraint(c => c.parentSize/2 - c.preferredSize/2, c => c.parentSize/2 - c.preferredSize/2, _.preferredSize, _.preferredSize))
scala> frame.pack
scala> frame setVisible true
2009/2/20 Thomas Sant Ana <mailleux@gmail.com>
On Fri, Feb 20, 2009 at 6:06 AM, Ricky Clarkson <ricky.clarkson@gmail.com> wrote:
I recently ported my more functional layout manager to Scala. The core works, but of the stuff in extras/ I've only tested the percent constraints stuff.
http://github.com/rickyclarkson/anylayout/tree/master
I'm planning to improve it as I work on an old broken project that uses it. You can find its original Java form with some example code on Google Code.
Do you have samples of how to get the layout in place? I like Mig Layout because of an excellent demo and documentation( found here http://www.miglayout.com/ )
I can't believe that layout based on specifying Strings is good enough.
This is beyond the question. But Mig layout does have a way to declare constraints using classes and methods. I actually thought of wrapping them with scala code, but to me Strings are good enough (after all that's what you do in CSS).
Thomas
Sciss wrote:
> i'm looking for a substantial scala.swing documentation, tutorial if
> possible. google doesn't help. the API docs are more or less empty...
> simple things like how is supposed to work panel composition etc.
I'm not aware of any documentation per se, but the source code from the
Programming in Scala book is available at
http://booksites.artima.com/programming_in_scala/examples/ (ch. 32 & 33)
and should get you off and running.
-0xe1a