- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Resizing components and/or frames in scala swing?
Thu, 2009-02-26, 16:07
Hi,
I want to do a simple swing app that draws to the window using
Graphics2D. I can create a Component subclass and override the paint
method for that, but the only way to set the component's preferred
size is with a call to peer.setPreferredSize. Also, as far as I know
there only way to resize the whole frame is calling peer.setSize in
the frame. I discovered how to do these things reading the source code
for scala.swing, and it's not very intuitive. Maybe methods could be
added in the wrappers to make this easier? (or is there a better way
that I don't know ?) From a quick look at the code this seems to be
simple to do.
Thu, 2009-02-26, 16:57
#2
Re: Resizing components and/or frames in scala swing?
I didn't realize that these properties were directly accessible. Thanks.
Why can't you use comp.preferredSize = s and comp.size = s? See
scala.swing.test.ButtonApp for example.
Ingo
Andrei Formiga wrote:
> Hi,
>
> I want to do a simple swing app that draws to the window using
> Graphics2D. I can create a Component subclass and override the paint
> method for that, but the only way to set the component's preferred
> size is with a call to peer.setPreferredSize. Also, as far as I know
> there only way to resize the whole frame is calling peer.setSize in
> the frame. I discovered how to do these things reading the source code
> for scala.swing, and it's not very intuitive. Maybe methods could be
> added in the wrappers to make this easier? (or is there a better way
> that I don't know ?) From a quick look at the code this seems to be
> simple to do.
>