View unanswered posts | View active topics It is currently Sat May 27, 2017 9:06 am

Reply to topic  [ 2 posts ] 
 Shrink JTextfield 
Author Message

Joined: Mon Oct 18, 2010 8:25 pm
Posts: 1
Post Shrink JTextfield
This is my code trimmed and easied down.

//add(new BigJLabel("I am a JLabel but with big font, and take alot of space"), "span, wrap");

add(new JLabel("Width"));
add(textfield1, "wrap");

add(new JLabel("Height"));
add(textfield2, "wrap");

add(new JSeparator(), "grow, span, wrap");

add(new JLabel("Width"));
add(textfield3, "wrap");

add(new JLabel("Height"));
add(textfield4, "wrap");

All JTextfields have setColumn=4, and it is drawn correct. And if I drag the window to become so small that the texfields cannot be shown with it's default width, then the textfields are shrunked.

So far so good. The problem occurs when I uncomment the first line... The JTextfield is the same width, but if I shrink the window the JTextfields won't shrink because BigJLabel is larger than both the JLabel and JTextfield together... Is there anyway to fix this?

Mon Oct 18, 2010 8:35 pm
Site Admin

Joined: Mon Dec 06, 2004 4:24 pm
Posts: 2485
Location: Sweden
Post Re: Shrink JTextfield
It depends what you want to do. Add "wmin 0" to the big label which mean it can also shrink. By default JLabel reports a minimum size that is the same as the preferred size.


Mon Oct 18, 2010 11:31 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.