AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

prevent JList from automatically resizing itself

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits
View previous topic :: View next topic  
Author Message
Adam Sandler
Guest





PostPosted: Thu May 17, 2007 7:05 pm    Post subject: prevent JList from automatically resizing itself Reply with quote



Hello,

I've looked at:

http://groups.google.com/group/comp.lang.java.gui/browse_thread/thread/8f2784a481defe49/8e5402c334e46ad7
http://groups.google.com/group/comp.lang.java.gui/browse_thread/thread/f1bdc29ee376c36/4ed497533441e301

and still have a question about JList resizing. In most of the JList
threads I found, there were issues with the items becoming hidden or
visible; that's not a problem here. I'd like to prevent a JList from
resizing itself. In the first URL above, I don't have the container
hierarchy problems they did. In the second URL above, I'm not sure
about setting the preferred size. Aren't the layout managers supposed
to take care sizing? If I set preferred size, does that conflict with
the layout manager? And what impact could setting the preferred size
have on different resolutions... especially if someone is using
something different than 4:3 or 16:9?

On my panel, there are two radio buttons. Depending on what radio
button is selected, different items are sent to the JList. There are
no default items for the JList; when the application is run for the
first time the JList takes up all of its region. When a radio button
is clicked, then the JList resizes itself (usually shrinking) to the
width of the longest item. Well, all this resizing is not very
aesthetically appealing to say the least.

Here is the code for the components and how they are placed on the
container:

private JLabel interferenceDirectoryLabel = new
JLabel("Interference Directory: ");
private JRadioButton ObjectRadioButton = new
JRadioButton("Object");
private JRadioButton VectorRadioButton = new
JRadioButton("Vector");
private ButtonGroup linkButtonGroup = new ButtonGroup();
private JList interferenceConstellationList = new JList();
private JScrollPane jsp = new
JScrollPane(interferenceConstellationList);
private JCheckBox sunRFICheckBox = new JCheckBox("Include Sun
RFI");

private JPanel jp = new JPanel(new BorderLayout());
jp.setBorder(new TitledBorder("Select interference directory"));

jp.add(interferenceDirectoryLabel, BorderLayout.NORTH);
jp.add(ObjectRadioButton, BorderLayout.WEST);
jp.add(VectorRadioButton, BorderLayout.CENTER);
jp.add(jsp, BorderLayout.EAST);
jp.add(sunRFICheckBox, BorderLayout.SOUTH);

Any suggestions on how to proceed are greatly appreciated.

Thanks!
Back to top
Andrew Thompson
Guest





PostPosted: Thu May 17, 2007 7:42 pm    Post subject: Re: prevent JList from automatically resizing itself Reply with quote



Adam Sandler wrote:
...
Quote:
...I'd like to prevent a JList from
resizing itself.
... Aren't the layout managers supposed
to take care sizing?

Yes - they take their strongest tip from the preferred size
of components. If practical - a component is set to its
preferred size.

Quote:
...If I set preferred size, does that conflict with
the layout manager?

No.

Quote:
...And what impact could setting the preferred size
have on different resolutions... especially if someone is using
something different than 4:3 or 16:9?

If we set the preferred size, it is up to the us to
calculate a sensible value. This might be based
on the the content (list items), screen size, other
things, or combinations.

Quote:
Any suggestions on how to proceed are greatly appreciated.

As far as the resolution goes, see Toolkit.getScreenSize().

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-gui/200705/1
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.