Skip to content

Package: ComponentFrame

ComponentFrame

nameinstructionbranchcomplexitylinemethod
ComponentFrame(Component)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
ComponentFrame(Component, String)
M: 19 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Distribution License v. 1.0, which is available at
6: * http://www.eclipse.org/org/documents/edl-v10.php.
7: *
8: * SPDX-License-Identifier: BSD-3-Clause
9: */
10:
11: import java.awt.*;
12: import java.awt.event.*;
13: import javax.swing.JFrame;
14: import javax.swing.WindowConstants;
15:
16:
17: /**
18: * this Frame provides a utility class for displaying a single
19: * Component in a Frame.
20: *
21: * @author        Christopher Cotton
22: */
23:
24: public class ComponentFrame extends JFrame {
25:
26: /**
27: * creates the frame
28: * @param what        the component to display
29: */
30: public ComponentFrame(Component what) {
31:         this(what, "Component Frame");
32: }
33:
34: /**
35: * creates the frame with the given name
36: * @param what        the component to display
37: * @param name        the name of the Frame
38: */
39: public ComponentFrame(Component what, String name) {
40:         super(name);
41:
42:         // make sure that we close and dispose ourselves when needed
43:         setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
44:
45:         // default size of the frame
46:         setSize(700,600);
47:
48:         // we want to display just the component in the entire frame
49:•        if (what != null) {
50:          getContentPane().add("Center", what);
51:         }
52: }
53: }