This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 201717 - Widget.calculateClientArea() affects widget bounds when it should not
Summary: Widget.calculateClientArea() affects widget bounds when it should not
Status: NEW
Alias: None
Product: platform
Classification: Unclassified
Component: Graph (show other bugs)
Version: 7.0
Hardware: PC Linux
: P3 normal (vote)
Assignee: issues@platform
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-07 01:10 UTC by _ tboudreau
Modified: 2011-09-07 01:12 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ tboudreau 2011-09-07 01:10:50 UTC
Say you have a widget which is a pure container - its bounds should only be as large as its contents (which in my case can be dragged around to make the container larger or smaller).

This should be the default behavior - and it is clear that is the intention since an empty rectangle is returned from calculateClientArea() by default.

However, in the private method Widget.calculatePreferredBounds(), the return value of calculateClientArea() is used - it is added to with Rectangle.add().

Result:  If all the children of a container have non-zero offsets, you get unnecessary whitespace because the x,y position of the 0,0 rectangle returned from calculateClientBounds() is used.

Clearly this is not what is intended.  A simple fix is for calculatePreferredBounds to test Rectangle.isEmpty(), and if true, ignore the client bounds.  It is also obvious that this is what this method was intended to do - however

new Rectangle(0,0,0,0).add(new Rectangle (20, 20, 20, 20))

gets a Rectangle (0, 0, 40, 40).
Comment 1 _ tboudreau 2011-09-07 01:12:32 UTC
Ugly workaround:  Override calculateClientBounds() to find the coordinates of the first child and return a zero width, zero height rectangle using its x/y coordinates.