This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Resizing components and/or frames in scala swing?

2 replies
Andrei Formiga
Joined: 2009-02-26,
User offline. Last seen 42 years 45 weeks ago.

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.

imaier
Joined: 2008-07-01,
User offline. Last seen 23 weeks 2 days ago.
Re: Resizing components and/or frames in scala swing?

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.
>

Andrei Formiga
Joined: 2009-02-26,
User offline. Last seen 42 years 45 weeks ago.
Re: Resizing components and/or frames in scala swing?

I didn't realize that these properties were directly accessible. Thanks.

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