1 /* 2 * Copyright (c) 2009, 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 /* 25 * @test 26 * @key headful 27 * @bug 6802868 28 * @summary JInternalFrame is not maximized when maximized parent frame 29 * @author Alexander Potochkin 30 * @library .. 31 */ 32 33 import java.awt.Dimension; 34 import java.awt.Point; 35 import java.beans.PropertyVetoException; 36 import javax.swing.JDesktopPane; 37 import javax.swing.JFrame; 38 import javax.swing.JInternalFrame; 39 40 public class Test6802868 { 41 42 public static void main(String[] args) throws Throwable { 43 SwingTest.start(Test6802868.class); 44 } 45 46 private final JFrame frame; 47 private final JInternalFrame internal; 48 private Dimension size; 49 private Point location; 50 51 public Test6802868(JFrame frame) { 52 JDesktopPane desktop = new JDesktopPane(); 53 54 this.frame = frame; 55 this.frame.add(desktop); 56 57 this.internal = new JInternalFrame(getClass().getName(), true, true, true, true); 58 this.internal.setVisible(true); 59 60 desktop.add(this.internal); 61 } 62 63 public void firstAction() throws PropertyVetoException { 64 this.internal.setMaximum(true); 65 } 66 67 public void firstTest() { 68 this.size = this.internal.getSize(); 69 resizeFrame(); 70 } 71 72 public void firstValidation() { 73 if (this.internal.getSize().equals(this.size)) { 74 throw new Error("InternalFrame hasn't changed its size"); 75 } 76 } 77 78 public void secondAction() throws PropertyVetoException { 79 this.internal.setIcon(true); 80 } 81 82 public void secondTest() { 83 this.location = this.internal.getDesktopIcon().getLocation(); 84 resizeFrame(); 85 } 86 87 public void secondValidation() { 88 if (this.internal.getDesktopIcon().getLocation().equals(this.location)) { 89 throw new Error("JDesktopIcon hasn't moved"); 90 } 91 } 92 93 private void resizeFrame() { 94 Dimension size = this.frame.getSize(); 95 size.width += 10; 96 size.height += 10; 97 this.frame.setSize(size); 98 } 99 }