Review request for 7154030: java.awt.Component.hide() does not repaint parent container (original) (raw)
Jonathan Lu luchsh at linux.vnet.ibm.com
Thu Mar 15 01:24:53 PDT 2012
- Previous message: Instability of texts in Graphics2D imaging
- Next message: Review request for 7154030: java.awt.Component.hide() does not repaint parent container
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi awt-dev,
java.awt.Component.hide() was declared as deprecation and replaced by setVisible(boolean), but in my tests, it does not works in the same way as setVisible(false). The reason of this failure is that java.awt.Component.hide() does not repaint the special area it used to taken of parent container. Although this is deprecated method, it may still valuable for customers due to compatibility reason. Bug 7154030 created for this issue.
Here's a simple test case to demonstrate this problem.
/*
- Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- This code is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License version 2 only, as
- published by the Free Software Foundation.
- This code is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- version 2 for more details (a copy is included in the LICENSE file that
- accompanied this code).
- You should have received a copy of the GNU General Public License version
- 2 along with this work; if not, write to the Free Software Foundation,
- Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- or visit www.oracle.com if you need additional information or have any
- questions. */
/*
- Portions Copyright (c) 2012 IBM Corporation */
import javax.swing.*;
/* @test 1.1 2012/03/15 @bug 7154030 @run main/manual ComponentHideShowTest.html */
@SuppressWarnings("serial") public class ComponetHideShowTest extends JFrame { JInternalFrame internalFrame; JButton btn; JDesktopPane desktop;
ComponetHideShowTest(String name) {
super(name);
desktop = new JDesktopPane();
setContentPane(desktop);
setSize(600, 400);
setVisible(true);
internalFrame = new JInternalFrame("Test Internal Frame");
internalFrame.setSize(100, 100);
internalFrame.setLocation(10, 10);
internalFrame.setVisible(true);
desktop.add(internalFrame);
btn = new JButton("OK");
btn.setSize(100, 50);
btn.setLocation( 300, 300);
btn.setVisible(true);
desktop.add(btn);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
@SuppressWarnings("deprecation")
public void runTest() throws Exception {
Object[] options = { "Yes, I saw it", "No, I did not see it!" };
int ret = JOptionPane.showOptionDialog(this,
"Do you see the internal window?", "InternalFrmaeHideTest",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
null, options, options[1]);
if (ret == 1 || ret == JOptionPane.CLOSED_OPTION) {
throw new Exception("Failed to display internal window");
}
internalFrame.hide();
btn.hide();
ret = JOptionPane.showOptionDialog(this,
"Do you see the internal window?", "InternalFrmaeHideTest",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
null, options, options[1]);
if (ret == 0 || ret == JOptionPane.CLOSED_OPTION) {
throw new Exception("Failed to hide internal window");
}
internalFrame.show();
btn.show();
ret = JOptionPane.showOptionDialog(this,
"Do you see the internal window?", "InternalFrmaeHideTest",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
null, options, options[1]);
if (ret == 1 || ret == JOptionPane.CLOSED_OPTION) {
throw new Exception("Failed to hide internal window");
}
}
public static void main(String[] args) throws Exception {
ComponetHideShowTest test = null;
test = new ComponetHideShowTest("InternalFrameHideTest");
test.runTest();
}
}
And here's the patch http://cr.openjdk.java.net/~littlee/7154030/
Can anybody please help to take a look?
Cheers!
- Jonathan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.openjdk.java.net/pipermail/awt-dev/attachments/20120315/80c64489/attachment.html
- Previous message: Instability of texts in Graphics2D imaging
- Next message: Review request for 7154030: java.awt.Component.hide() does not repaint parent container
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]