JDK-6318144 : PIT:Setting Min Size bigger than current size enlarges the window but fails to revalidate, Sol-CDE
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0,6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux_sun,solaris_10
  • CPU: x86,sparc
  • Submitted: 2005-08-31
  • Updated: 2006-10-04
  • Resolved: 2005-11-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b61Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
The specification for setMinimumSize() claims that calling this method with a size smaller than the current resize would automatically enlarge the window to the specified min size. When I do this with respect to a 'Window' object, the window gets enlarged but the components inside the window are not re-aligned properly according to the new size. Basically it fails to invalidate and validate the components present inside the window. 

This is reproducible only on SolarisSparc10-CDE and not reproducible on GNOME. This is reproducible only for java.awt.Window and not reproducible for Frame and Dialog. This is not reproducible on Win32 as well.

Here is the PIT build:
java version "1.6.0-internal"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-internal-df153228_24_aug_2005_01_49-b00)
Java HotSpot(TM) Server VM (build 1.6.0-ea-b48, mixed mode)

I have attached a sample test. Execute the sample test. 
1. You would see a frame with 4 buttons. 
2. Click on 'Show Dialog' button. A dialog will appear. 
3. Click on 'Show Window' button. A window will appear. 
4. Click on 'Toggle Min Size' button. The default min size will be reset. 
5. Click on 'Reduce Size' button repeatedly a few times until Window becomes smaller than 100, 100. 
6. Click on 'Toggle Min Size' button now. This would set the min size to 200, 200. 

Now you would see window being resized to 200, 200 but components are still aligned within the old bounds.

Comments
SUGGESTED FIX ------- XWindowPeer.java ------- *** /tmp/sccs.2W7qfO 2005-10-11 15:02:38.000000000 +0400 --- XWindowPeer.java 2005-10-11 15:02:26.000000000 +0400 *************** *** 220,225 **** --- 220,248 ---- return ownerPeer; } + //Fix for 6318144: PIT:Setting Min Size bigger than current size enlarges + //the window but fails to revalidate, Sol-CDE + //This bug is regression for + //5025858: Resizing a decorated frame triggers componentResized event twice. + //Since events are not posted from Component.setBounds we need to send them here. + //Note that this function is overriden in XDecoratedPeer so event + //posting is not changing for decorated peers + public void setBounds(int x, int y, int width, int height, int op) { + Rectangle oldBounds = getBounds(); + super.setBounds(x, y, width, height, op); + Rectangle bounds = getBounds(); + //System.out.println("Bounds, old : " + oldBounds + ", new : " + bounds); + if (!bounds.getSize().equals(oldBounds.getSize())) { + System.out.println("XWindowPeer.setBounds.postResized"); + postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_RESIZED)); + } + if (!bounds.getLocation().equals(oldBounds.getLocation())) { + System.out.println("XWindowPeer.setBounds.postMoved"); + postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_MOVED)); + } + + } + void updateFocusability() { XToolkit.awtLock(); try {
11-10-2005

EVALUATION Revalidating also fails if window is resized by setSize(). This can be demonstrating on following test import java.awt.*; import java.awt.event.*; public class WindowTest { public static void main(String[] args) { Frame f = new Frame(); Window w = new Window(f); w.setLayout(new BorderLayout()); w.add(new Button("CENTER"), BorderLayout.CENTER); w.add(new Button("NORTH"), BorderLayout.NORTH); w.pack(); try { w.setVisible(true); w.setSize(200, 200); Thread.sleep(1000); w.setSize(300, 300); } catch (Exception ex) { } } } This test works fine on b50 and doesn't revalidate on b51. Most likely this is regression of fix for 5025858: Resizing a decorated frame triggers componentResized event twice.
26-09-2005

EVALUATION Also reproducible on KDE and GNOME.
26-09-2005

WORK AROUND calling the following 2 lines after setMinSize() solves the problem: window.setMinimumSize(200, 200); window.invalidate(); window.validate();
31-08-2005