United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4320050 : Minimum size for java.awt.Frame is not being enforced.

Details
Type:
Enhancement
Submit Date:
2000-03-09
Status:
Resolved
Updated Date:
2005-09-07
Project Name:
JDK
Resolved Date:
2005-09-07
Component:
client-libs
OS:
windows_nt,generic,linux_redhat_8.0,windows_xp
Sub-Component:
java.awt
CPU:
x86,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.3.0,5.0,6
Fixed Versions:

Related Reports
Duplicate:
Duplicate:
Duplicate:
Duplicate:
Relates:
Relates:
Relates:

Sub Tasks

Description
Name: krT82822			Date: 03/08/2000


8 Mar 2000, eval1127@eng -- easily worked around.  Could not find any still-open
bugs re. this, so am filing new one.

java version "1.2.2"
Classic VM (build JDK-1.2.2-W, native threads, symcjit)

Since there is no method to set a minimum size on a java.awt.Frame, the most
obvious way to control this behavior is to extend the Frame object and override
the getMinimumSize() method. However, when this is done, the minimum size that
I set is not being enforced. Any other suggestions?

Sample code as follows:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

import java.awt.*;

public class ResizeTest extends Frame
{
   private final Dimension m_dim = new Dimension(200, 150);

   public static void main(String args[])
   {
      new ResizeTest("Resize Test");
   }

   public ResizeTest(String title)
   {
      super(title);
      setLayout(new BorderLayout());
      setSize(m_dim);
      show();
   }

   public Dimension getPreferredSize() { return m_dim; }
   public Dimension getMinimumSize()   { return m_dim; }
}
(Review ID: 102158) 
======================================================================

                                    

Comments
EVALUATION

Need some new methods for minimum and maximum size of a frame.  Commit to Tiger.

richard.ray@eng 2000-03-17

Necessary javadoc changes:

(Preliminary Specification)
java.awt.Window:
 
    /**
     * Sets the minimum size of this window to a constant
     * value.  Subsequent calls to <code>getMinimumSize</code>
     * will always return this value. If current window's
     * size is less than specified by <code>minimumSize</code>
     * param it's automatically enlarged. If <code>setSize</code>
     * or <code>setBounds</code> call is made with width and height
     * less than specified by <code>setMinimumSize</code> window
     * will by automatically enlarged to minimumSize value.
     * Setting the minimum size to <code>null</code> restores
     * the default behavior.
     * <p>
     * Resizing operation may be restricted if user tries
     * to resize window below the <code>minimumSize</code> value.
     * This behaviour is platform-dependent.
     *
     * @param minimumSize the new minimum size of this window
     * @see Component#setMinimumSize
     * @see #getMinimumSize
     * @see #isMinimumSizeSet
     * @see #setSize(Dimension)
     */
    public void setMinimumSize(Dimension minimumSize)
 
    /**
     * {@inheritDoc}
     * <p>
     * Values of <code>d.width</code> or <code>d.height</code>
     * will be automatically enlarged if they are less than
     * window's minimum size specified by previous call to
     * <code>setMinimumSize</code>.
     *
     * @see #getSize
     * @see #setBounds
     * @see #setMinimumSize
     */
    public void setSize(Dimension d)
 
    /**
     * {@inheritDoc}
     * <p>
     * Values of <code>width</code> or <code>height</code>
     * will be automatically enlarged if they are less than
     * window's minimum size specified by previous call to
     * <code>setMinimumSize</code>.
     *
     * @see #getSize
     * @see #setBounds
     * @see #setMinimumSize
     */
    public void setSize(int width, int height)
 
    /**
     * {@inheritDoc}
     * <p>
     * Values of <code>width</code> or <code>height</code>
     * will be automatically enlarged if they are less than
     * window's minimum size specified by previous call to
     * <code>setMinimumSize</code>.
     *
     * @see #getBounds
     * @see #setLocation(int, int)
     * @see #setLocation(Point)
     * @see #setSize(int, int)
     * @see #setSize(Dimension)
     * @see #setMinimumSize
     * @see #setLocationByPlatform
     * @see #isLocationByPlatform
     * @since 1.5
     */
    public void setBounds(int x, int y, int width, int height)
 
    /**
     * {@inheritDoc}
     * <p>
     * Values of <code>r.width</code> or <code>r.height</code>
     * will be automatically enlarged if they are less than
     * window's minimum size specified by previous call to
     * <code>setMinimumSize</code>.
     *
     * @see #getBounds
     * @see #setLocation(int, int)
     * @see #setLocation(Point)
     * @see #setSize(int, int)
     * @see #setSize(Dimension)
     * @see #setMinimumSize
     * @see #setLocationByPlatform
     * @see #isLocationByPlatform
     * @since 1.5
     */
    public void setBounds(Rectangle r)
 
    /**
     * @deprecated As of JDK version 1.1,
     * replaced by <code>setBounds(int, int, int, int)</code>.
     */
    @Deprecated
    public void reshape(int x, int y, int width, int height)
###@###.### 2005-06-10 13:18:36 GMT
                                     
2005-06-10
SUGGESTED FIX

On Win32 window's minimum size can be enforced using WM_GETMINMAXINFO message,
On XWin uning normal window's hints (setNormalHints function).

1. Need to add new method to WindowPeer interface:
void updateMinimumSize();
NB! This method has no agruments.
When this method is called peer should request minimum size from tagret
(target.getMinimumSize()) and return this value on subsequent WM_GETMINMAXINFO calls or modify window's hints.

2. Need to modify reshaping in window to supress setting size of window less than minimumSize. This would remove flicker on WM's that allow setting window size of window less than minimumSize.

3. Need to override Window.setMinimumSize(...) that should:
- modify minimumSize (i.e. invoke superclass)
- enlarge window if it's less than minimumSize
- invoke peer's updateMinimumSize
###@###.### 2005-06-09 15:51:59 GMT
                                     
2005-06-09
WORK AROUND



Name: krT82822			Date: 03/08/2000


8 Mar 2000, eval1127@eng -- Frame.setResizable(false),
or override setSize() to check if requested (new) size is less than desired minimum
======================================================================
                                     
2004-09-17
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
mustang


                                     
2004-09-17



Hardware and Software, Engineered to Work Together