01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Vadim L. Bogdanov
19: * @version $Revision$
20: */package javax.swing;
21:
22: import java.beans.PropertyVetoException;
23:
24: public class JRootPaneRTest extends SwingTestCase {
25: private JFrame frame;
26:
27: public JRootPaneRTest(final String name) {
28: super (name);
29: }
30:
31: @Override
32: protected void tearDown() throws Exception {
33: super .tearDown();
34: if (frame != null) {
35: frame.dispose();
36: frame = null;
37: }
38: }
39:
40: public void testDefaultButton() throws PropertyVetoException {
41: JInternalFrame iframe = new JInternalFrame("", true, true,
42: true, true);
43: JDesktopPane desktop = new JDesktopPane();
44: desktop.add(iframe);
45: JButton button = new JButton();
46: iframe.getContentPane().add(button);
47: iframe.getRootPane().setDefaultButton(button);
48: frame = new JFrame();
49: frame.setContentPane(desktop);
50: frame.setVisible(true);
51: iframe.setIcon(true);
52: assertNull(iframe.getRootPane().getDefaultButton());
53: iframe.setIcon(false);
54: assertSame(button, iframe.getRootPane().getDefaultButton());
55: iframe.setIcon(true);
56: iframe.getContentPane().remove(button);
57: iframe.setIcon(false);
58: assertNull(iframe.getRootPane().getDefaultButton());
59: }
60: }
|