Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-1231233

Frame.setResizable(false) does not prevent resizing.


    • Subcomponent:
    • Resolved In Build:
    • CPU:
      x86, sparc
    • OS:
      solaris_2.5, solaris_2.5.1, solaris_2.6, windows_95, windows_nt
    • Verification:



        java.awt.Frame.setResizable(false) does not prevent the user from resizing the frame

        Steps to reproduce:
        Compile and run the attached code
        Press <UnSet Resizable>
        <Click + Drag> any corner of the window

        import java.awt.*;

        public class FrameTest extends AppFrame
            final String RESIZABLE = "Set Resizable";
            final String NOTRESIZABLE = "UnSet Resizable";
            Label label;

            public static void main(String args[])
               FrameTest f = new FrameTest();

            public FrameTest()
               super("Frame Test");
               Panel panel = new Panel();

               add("North", panel);
               panel.add( new Button(RESIZABLE) );
               panel.add( new Button(NOTRESIZABLE) );
               panel.add( label = new Label( new Boolean( isResizable() ).toString() ) );
               resize(200, 200);

            public boolean action(Event evt, Object obj)
               if (evt.target instanceof Button)
                  String lbl = (String) obj;
                  if ( lbl.equals(RESIZABLE) )
                  else if ( lbl.equals(NOTRESIZABLE) )
                     return false;

                  label.setText( new Boolean( isResizable() ).toString() );
                  return true;

               return super.action(evt, obj);

        /* Generic Full Application Frame
         * @(#)AppFrame.java 1.4 15 Nov 1995 15:48:24
         * @author Kevin A. Smith
         * The class AppFrame provides an AWT Frame window for running
         * applications.

        import java.awt.Frame;
        import java.awt.Event;
        import java.awt.MenuItem;

        // Application Frame window
        class AppFrame extends Frame
            // constructor needed to pass window title to class Frame
            public AppFrame(String name)
               // call java.awt.Frame(String) constructor

            // needed to allow window close
            public boolean handleEvent(Event e)
               // Window Destroy event
               if (e.id == Event.WINDOW_DESTROY)
                  return appExit(0);
               // it's good form to let the super class look at any
               // unhandled events
               return super.handleEvent(e);

            } // end handleEvent()

            // Generic Action event handler
            public boolean action(Event evt, Object obj)
               if(evt.target instanceof MenuItem)
                  return menuEvent(evt, obj);
                  // it is good form to let the super class look at any
                  // unhandled events.
                  return super.action(evt, obj);

            } // end action()

            // Generic Menu event handler
            public boolean menuEvent(Event evt, Object obj)
               String menuLabel = obj.toString();

               if( menuLabel.equals("Exit") )
                  // This menu item is the same as Close
                  return appExit(0);

                  // menu event handler did nothing with this event.
                  // In a fully written application, you should never
                  // get to this line.
                  return false;

            } // end menuEvent()

            // application exit code
            protected boolean appExit(int exitCode)
               return true;

        } // end class AppFrame

        roger.lewis@Eng 1997-07-16

        Release: 1.1.3
        Hardware: i586
        OSversion: win_95

        Synopsis: setResizable(false) still lets you maximize a frame

        1. Put setResizable(false) in the initialization of a frame.
        2. Run the program
        3. Double-click the header or press the maximize button.
        4. The window is maximized with the contents in the upper left corner.

        company - OPUS DA , email - ###@###.###


            Currently Frames do not have methods to enable and disable minimize and maximize buttons.
        Only way out is to disable events to these buttons. Better method would be to have functions
        which allow the prograammer to enable or disable these buttons.



            Issue Links



                • Assignee:
                  pyoung Paul Young
                  kasmithsunw Kevin Smith (Inactive)
                • Votes:
                  0 Vote for this issue
                  1 Start watching this issue


                  • Created: