aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes programatically size JFrame after data in JLabel changes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "programatically size JFrame after data in JLabel changes" Watch "programatically size JFrame after data in JLabel changes" New topic
Author

programatically size JFrame after data in JLabel changes

Jim Harrison
Ranch Hand

Joined: Mar 16, 2007
Posts: 30
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

Joined: Oct 27, 2005
Posts: 19760
    
  20

Call pack().


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Shrinath M Aithal
Ranch Hand

Joined: May 20, 2009
Posts: 82
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..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: programatically size JFrame after data in JLabel changes