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 24import javax.swing.*; 25import java.awt.*; 26import java.awt.event.WindowAdapter; 27import java.awt.event.WindowEvent; 28 29/* 30 * @author Aruna Samji 31 */ 32 33public class GUIZoomFrame extends Frame { 34 35 JFrame jframe1, jframe2; 36 JButton jbutton; 37 JTextArea jtextarea; 38 volatile boolean maxHor, maxVer, maxBoth, normal, iconify; 39 40 public GUIZoomFrame() { 41 //GUI for ZoomJFrameChangeState 42 jframe1 = new JFrame("ZoomJFrameChangeState"); 43 jframe1.getContentPane().setBackground(Color.red); 44 jframe1.getContentPane().setLayout(null); 45 jframe1.setSize(500,270); 46 47 //GUI for ZoomJFrameRepaint 48 jframe2 = new JFrame("ZoomJFrameRepaint"); 49 jframe2.getContentPane().setBackground(Color.red); 50 jframe2.setSize(500, 270); 51 jframe2.getContentPane().setLayout(null); 52 jbutton = new JButton("TestButton"); 53 jtextarea = new JTextArea("TextArea"); 54 jbutton.setBounds(20, 100, 80, 60); 55 jtextarea.setBounds(120, 100, 80, 60); 56 57 //Listeners for ZoomJFrameChangeState 58 jframe1.addWindowStateListener(new WindowAdapter() { 59 public void windowStateChanged(WindowEvent e) { 60 if (e.getNewState() == Frame.MAXIMIZED_BOTH) 61 maxBoth = true; 62 63 if (e.getNewState() == Frame.NORMAL) 64 normal = true; 65 66 if (e.getNewState() == Frame.ICONIFIED) 67 iconify = true; 68 69 if (e.getNewState() == Frame.MAXIMIZED_HORIZ) 70 maxHor = true; 71 72 if (e.getNewState() == Frame.MAXIMIZED_VERT) 73 maxVer = true; 74 } 75 }); 76 77 //Listeners for ZoomJFrameRepaint 78 jframe2.addWindowStateListener( new WindowAdapter() { 79 public void windowStateChanged(WindowEvent e) { 80 if (e.getNewState() == Frame.MAXIMIZED_BOTH) 81 maxBoth = true; 82 83 if (e.getNewState() == Frame.NORMAL) 84 normal = true; 85 } 86 }); 87 } 88} 89