Sign in to follow this  

Swing help please

This topic is 4694 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The height of my JTextField is too high and I'm using box layout. The setpreferredsize, setminsize and setmaxsize methods don't work. Here's a pic of my problem. http://www.student.cs.uwaterloo.ca/~thalamya/trouble.JPG Any help please?

Share this post


Link to post
Share on other sites
I don't know this widget, and I don't know java, but it looks like your window is cut in half by the layout, and that the box you're talking about is stretched to that limit.

Perhaps if you try to set a pixel size for the top half of your window layout, the textbox will be smaller in size.

Albert

Share this post


Link to post
Share on other sites
Your layout manager is screwing it up, I think (one reason I find layout managers annoying). If you don't want to try an alternate layout (which would/could definitely fix this), try also messing around with that button on the right. Maybe it has a border size set? A bad "preferred" size? If that button has a huge border around it a box layout manager (going from memory here) would probably behave like this. (I'm a little surprised the button isn't huge too, which is what makes me think about the border.)

If it's not a border for the button causing it and you're stumped, you could always try a GridLayout or GridBagLayout.

This is from the java docs:
Quote:

BoxLayout attempts to arrange components at their preferred widths (for horizontal layout) or heights (for vertical layout). For a horizontal layout, if not all the components are the same height, BoxLayout attempts to make all the components as high as the highest component.


Note the last sentence...so maybe it's your button in the same row causing it?

Share this post


Link to post
Share on other sites

This topic is 4694 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this