1 /*
   2  * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.awt.*;
  25 import java.awt.event.WindowAdapter;
  26 import java.awt.event.WindowEvent;
  27 
  28 /*
  29  * @author Aruna Samji
  30  */
  31 
  32 public class GUIZoomFrame extends Frame {
  33 
  34     Frame frame1, frame2;
  35     Button button;
  36     TextArea textarea;
  37     volatile boolean maxHor, maxVer, maxBoth, normal, iconify;
  38 
  39     public GUIZoomFrame() {
  40         //GUI for ZoomFrameChangeState
  41         frame1 = new Frame("ZoomFrameChangeState");
  42         frame1.setBackground(Color.red);
  43         frame1.setSize(500,270);
  44 
  45         //GUI for ZoomFrameRepaint
  46         frame2 = new Frame("ZoomFrameRepaint");
  47         frame2.setBackground(Color.red);
  48         frame2.setSize(500,270);
  49         frame2.setLayout(null);
  50         button = new Button("TestButton");
  51         textarea = new TextArea("TextArea");
  52         button.setBounds(20, 100, 80, 60);
  53         textarea.setBounds(120, 100, 80, 60);
  54 
  55         //Listeners for ZoomFrameChangeState
  56         frame1.addWindowStateListener( new WindowAdapter() {
  57             public void windowStateChanged(WindowEvent e) {
  58                 if (e.getNewState() == Frame.MAXIMIZED_BOTH)
  59                     maxBoth=true;
  60 
  61                 if (e.getNewState() == Frame.NORMAL)
  62                     normal=true;
  63 
  64                 if (e.getNewState() == Frame.ICONIFIED)
  65                     iconify=true;
  66 
  67                 if (e.getNewState() == Frame.MAXIMIZED_HORIZ)
  68                     maxHor=true;
  69 
  70                 if (e.getNewState() == Frame.MAXIMIZED_VERT)
  71                     maxVer=true;
  72             }
  73 
  74         });
  75 
  76         //Listeners for ZoomFrameRepaint
  77         frame2.addWindowStateListener( new WindowAdapter() {
  78             public void windowStateChanged(WindowEvent e) {
  79                 if (e.getNewState() == Frame.MAXIMIZED_BOTH)
  80                     maxBoth = true;
  81 
  82                 if (e.getNewState() == Frame.NORMAL)
  83                     normal = true;
  84             }
  85         });
  86     }
  87 }