This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes making resizable components? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "making resizable components?" Watch "making resizable components?" New topic

making resizable components?

Geoffrey Falk
Ranch Hand

Joined: Aug 17, 2001
Posts: 171
I am making a Panel using BorderLayout. In the
center of the layout is a custom Canvas.
When the user resizes the window, I want the
canvas to get resized automatically according
to its preferred size in the BorderLayout.
What is the mechanism to achieve this? I notice
that buttons, etc. already do it automatically.

Sun Certified Programmer for the Java 2 Platform
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299

Are you setting bounds on the Canvus or is it set to the BorderLayout as well?
What do you mean by Custom?

GenRocket - Experts at Building Test Data
Geoffrey Falk
Ranch Hand

Joined: Aug 17, 2001
Posts: 171
I don't know what you mean by setting bounds on the canvas. I am just setting an initial size for the canvas when it is created.
"custom Canvas" means I extended Canvas.
Geoffrey Falk
Ranch Hand

Joined: Aug 17, 2001
Posts: 171
I have a solution, but it requires my panel to have something like this
new ComponentAdapter() {
public void componentResized(ComponentEvent e) {
which is ugly, and besides, Buttons don't need this trick!!
It is sorta covered in the JavaRanch Style Guide.
subject: making resizable components?
Similar Threads
a curious problem about canvas
Canvas hiding away menubar
Get Drawable from Canvas
Problem in drawing block using java3d
resizing the JLabel in java3d