non-re sizable swing component

T

toton

Hi,
I want to create a swing component (from JComponent ) which can have
a fixed size which I specify (default to 700,300). I want it to have
same size when I put it in a layout. and when I set a new size for it
I want it to set itself to the new size, and make itself fully
visible. How to make that work ?
 
A

Andrew Thompson

toton wrote:
..
I want to create a swing component (from JComponent ) which can have
a fixed size which I specify (default to 700,300).

setPreferredSize(), then..
..I want it to have
same size when I put it in a layout.

..put in a layout and position in the layout that
honours the preferred size..
..and when I set a new size for it
I want it to set itself to the new size, and make itself fully
visible.

..then pack() the root window.
How to make that work ?

See above, and probably also the Swing and layouts
sections of the 'Java Tutorial'.

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,197
Latest member
Sean29G025

Latest Threads

Top