The Artima Developer Community
Sponsored Link

Java Answers Forum
how to auto-size JComponents

1 reply on 1 page. Most recent reply: Jun 23, 2004 3:16 AM by mausam

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Gibran Shah

Posts: 27
Nickname: gibby
Registered: Jun, 2004

how to auto-size JComponents Posted: Jun 22, 2004 6:47 AM
Reply to this message Reply
Advertisement
Hey all,

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?

Gib


mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: how to auto-size JComponents Posted: Jun 23, 2004 3:16 AM
Reply to this message Reply
there are three methods.

setMaximumSize()/setMinimumSize()/setPreferredSize() given honour by borderlayout.

if u are using null layout, use setBouds(x,y,width,height)

Flat View: This topic has 1 reply on 1 page
Topic: Is there a JParagraph? Previous Topic   Next Topic Topic: Service Data Object (SDO)

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use