Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

programatically size JFrame after data in JLabel changes

 
Jim Harrison
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello...

I have a JFrame whose contents consist of alot of JLabels that can either be text or images or both. The user can also change the font for these (all fonts will be the same size). My problem is how do I resize to ensure the JFrame to ensure all the contents are visible? All the contents are data driven. I'm using JDK 6_13 on Windows machine.

Thanks.Jim
 
Rob Spoor
Sheriff
Pie
Posts: 20550
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Call pack().
 
Shrinath M Aithal
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Rob
I was about to post new thread while I got this..
I am trying a quiz application with swings, so while showing the question,
I wanted to display the question through a Label. (I specifically wanted Label because I am using JDesktopPane with Nimbus background and I like to show it off.. so if i use textarea or textpane, it'll show as white and wouldn't be as good as label..)
So while trying to fit the question inside label, I learn't how to use multiline using html tags..


Problem is that whenever the label would go out of screen size, I couldn't get the desktoppane to scroll to that area, even if the desktop pane was inside a scrollpane.

after i saw your post here, i used pack() after resizing the desktop pane, and it Worked!!.. thanks a lot, and any comments on what i am trying to achieve is welcome..
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic