JDK-6355340 : Contents of frame are not layed out properly on maximize
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-11-24
  • Updated: 2011-03-07
  • Resolved: 2011-03-07
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 7
7 b02Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.5.0_04"

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
In some circumstances, when a Frame is maximize, the contents are not validated, so they stay in the same position and size as prior to the maximizing.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a JFrame with some content
2. Right click on the title bar.
3. Select 'Size' from the menu
4. Left click in the contents of the window
5. Maximize the window.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The window should maximize, and the contents should be layed out according to the layout manager of the window.
ACTUAL -
The content location and size is not changed.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import javax.swing.*;
import java.util.*;

class  test
{
public static void main(String[] args) {
        Frame frame = new Frame("Test Frame");

        JPanel panel = new JPanel();
        panel.setBackground(Color.RED);

		JTextField jf = new JTextField (10);
		JTextField jf1 = new JTextField (10);
		JButton jb = new JButton("Test");
		panel.add(jf);
		panel.add(jf1);
		panel.add(jb);
        frame.add(panel);

        frame.setSize(400, 400);
        frame.setVisible(true);
}
}
---------- END SOURCE ----------

Comments
EVALUATION The last fix failed on programmatic resize of the frame. The new fix does process the WM_SYSCOMMAND message (in AwtWindow::WindowProc), sets the m_resizing flag and manually calls the DefWindowProc() to enter Size-Move message loop. After DefWindowProc() returns the m_resizing flag gets reset to FALSE. With this fix it seems to work in any situation (be it a manual or programmatic resize of the frame). Automatic test awt/Frame/LayoutOnMaximizeTest/ works well with this patch.
08-06-2006

EVALUATION The m_resizing flag is used to indicate that the window is currently being resized to prevent calling WindowResized() method on each WM_SIZE message. The m_resizing flag is set to TRUE when the user selects Size system menu command. If the window is not actually resized by the user after selecting system menu command Size, the WM_EXITSIZEMOVE message is not sent and as such the m_resizing flag doesn't get reset to FALSE. That's why selecting Maximize system menu command results in not resizing the contents of the frame (see Description for the test source code). Resetting the m_resizing to FALSE when the WM_SYSCOMMAND (SC_MAXIMIZE or SC_MINIMIZE) is processed fixes this bug.
06-06-2006

SUGGESTED FIX $ sccs diffs -C awt_Window.cpp ------- awt_Window.cpp ------- *** /tmp/sccs.FRCIpJ 2006-08-22 12:54:28.000000000 +0400 --- awt_Window.cpp 2006-08-22 12:39:20.000000000 +0400 *************** *** 1133,1150 **** MsgRouting AwtWindow::WmSysCommand(UINT uCmdType, int xPos, int yPos) { ! if (uCmdType == SC_SIZE) { ! m_resizing = TRUE; ! } return mrDoDefault; } MsgRouting AwtWindow::WmExitSizeMove() { ! if (m_resizing) { ! WindowResized(); ! m_resizing = FALSE; ! } return mrDoDefault; } --- 1133,1147 ---- MsgRouting AwtWindow::WmSysCommand(UINT uCmdType, int xPos, int yPos) { ! //Fixed 6355340: Contents of frame are not layed out properly on maximize ! return mrDoDefault; } MsgRouting AwtWindow::WmExitSizeMove() { ! //Fixed 6355340: Contents of frame are not layed out properly on maximize ! return mrDoDefault; } *************** *** 1301,1306 **** --- 1298,1315 ---- case WM_GETICON: mr = WmGetIcon(wParam, retValue); break; + case WM_SYSCOMMAND: + //Fixed 6355340: Contents of frame are not layed out properly on maximize + if (wParam == SC_SIZE) { + m_resizing = TRUE; + mr = WmSysCommand(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); + if (mr != mrConsume) { + AwtWindow::DefWindowProc(message, wParam, lParam); + } + m_resizing = FALSE; + mr = mrConsume; + } + break; } if (mr != mrConsume) {
06-06-2006

EVALUATION Reproducible on Win2000 too with JDK from 1.4.2.
25-11-2005