Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4903046
Votes 2
Synopsis Geater control needed for component set*size() methods
Category java:classes_swing
Reported Against 1.4
Release Fixed
State 3-Accepted, request for enhancement
Priority: 4-Low
Related Bugs 6179559
Submit Date 07-AUG-2003
Description




A DESCRIPTION OF THE REQUEST :
I think it would be useful to have more control over the sizing of a component.

Currently, there are three methods available...

setPreferredSize()
setMaximumSize()
setMinimumSize()

...that require you to set both dimensions at the same time.

It would be much more powerful if you could also set the dimensions independently using separate methods...

setPreferredWidth()
setPreferredHeight()
setMaximumWidth()
setMaximumHeight()
setMinimumWidth()
setMinimumHeight()


JUSTIFICATION :
In my application, I have the need to limit the width of a JTextField within a GridBagLayout to make sure that other dynamically added content will fit within my window.  I'd like to set ONLY the preferred width and allow the height to size itself as needed to adjust for larger fonts and other platform differences.
(Incident Review ID: 193678) 
======================================================================
Work Around
N/A
Evaluation
Yep, this is especially important for text widgets where you want to force a
particular axis to a size.
  xxxxx@xxxxx   2003-08-12
Contribution forum : https://jdk-collaboration.dev.java.net/servlets/ProjectForumMessageView?forumID=1463&messageID=14802
Posted Date : 2006-08-15 02:51:17.0
Comments
  
  Include a link with my name & email   

Submitted On 01-FEB-2005
jessewilson
I think I have a workaround:
If you call setBounds() with your preferred width and some maximum height, I believe the preferred height will automatically be what you would expect. You could then use this value to set the min and max height if necessary.


Submitted On 09-MAR-2006
Carsten.Drossel
I always use this workaround:

component.setPreferredSize( new Dimension( newWidth, component.getPreferredSize().height ) );

and yes, I would definitely appreciate a setPreferredWidth()-method


Submitted On 05-SEP-2006
BinaryDigit
I agree, and also I think all the setXXXSize() methods should have a version that takes int,int instead of a Dimension.



PLEASE NOTE: JDK6 is formerly known as Project Mustang