Skip to main content

Any analogue of setPreferredSize?

1 reply [Last post]
manenkov
Offline
Joined: 2008-01-04

Hello all!

In JDK 1.5, java,awt.Component has a setPreferredSize method.
Because default dimensions of AWT controls is too large (on handheld devices), I want to make them smaller. But setPreferredSize method is not part of Personal Profile specification. I try using a setSize method, but it has no any effect.

Can I somehow resizing a dimension of AWT components? (I already using a smaller fonts, but this is not enought unfortunatelly...)

Thanks!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Hinkmond Wong

phonemeadvanced@mobileandembedded.org wrote:
> Hello all!
>
> In JDK 1.5, java,awt.Component has a setPreferredSize method.
> Because default dimensions of AWT controls is too large (on handheld devices), I want to make them smaller. But setPreferredSize method is not part of Personal Profile specification. I try using a setSize method, but it has no any effect.
>
> Can I somehow resizing a dimension of AWT components? (I already using a smaller fonts, but this is not enought unfortunatelly...)
>

You can write a new Container as a subclass of java.awt.Container and
then at runtime, add your component to that container. Then, you can
control the size of the component inside the container with either a
setSize() call by the container object during runtime or by overriding
the getPreferredSize() method of the subclassed container to return
whatever value you want it to be as the preferred size.

Hinkmond

---------------------------------------------------------------------
To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
For additional commands, e-mail: advanced-help@phoneme.dev.java.net