how to auto-size JComponents
I'm sure there's a real easy way to do this so this might sound like a stupid question but... there's got to be a way to get a JComponent to automatically adjust it's width and height such that all its child components are all visible and fit nicely. I need this for both complex components (several levels of subcomponents within it) and simple components (JLabels, JButtons, etc). For the simple components, what I'm looking for is something such that I can call the constructor with an variable sized string, like a JLabel, and have the width automatically set its value so that no "..." appear at the end (ie. the whole string is visible). Any suggestions?
when you put the components in a frame, call the pack() method
sukuri.. you need to use a layout manager for that to work..
gibby.. see my signature, GridBag tutorial
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL