Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

resize jdialog

 
Cy Bird
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to resize a component on a JDialog at the same time the user is resizing the JDialog itself to match dimensions?
Is this possible? (Without using GridBagLayout)
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many other layout managers will also resize components in respect to their parents. BorderLayout is also very good at this. (at least for the component in the CENTER region) Even if you have no layout manager, you can attach a ComponentListener to the parent component and listen for resize events and resize the child component.

A lot of layout managers work off the preferred size of the child components... if you are having trouble with a component not sizing correctly, see what dimensions getPreferredSize() is returning.
 
Cy Bird
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess that is my question. Is there an example of how to listen for resize events? I tried WindowAdapter and didn't find I want I neeeded there.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would use the componentResized( ComponentEvent ) method of ComponentListener.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic