Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/JFrameWrapper.java
41161 views
1
/*
2
* Copyright (c) 2001, 2008, 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
package sun.jvm.hotspot.ui;
26
27
import java.awt.*;
28
import java.awt.event.*;
29
import javax.swing.*;
30
31
public class JFrameWrapper implements FrameWrapper {
32
private JFrame frame;
33
private boolean hasWindowListener;
34
private ActionListener closingActionListener;
35
private ActionListener activatedActionListener;
36
37
public JFrameWrapper(JFrame frame) {
38
this.frame = frame;
39
}
40
41
public Component getComponent() { return frame; }
42
public Container getContentPane() { return frame.getContentPane(); }
43
public void setVisible(boolean visible) { frame.setVisible(visible); }
44
public void setSize(int x, int y) { frame.setSize(x, y); }
45
public void pack() { frame.pack(); }
46
public void show() { frame.setVisible(true); }
47
public void dispose() { frame.dispose(); }
48
public void setBackground(Color color) { frame.setBackground(color); }
49
public void setResizable(boolean resizable) { frame.setResizable(resizable); }
50
51
public void setClosable(boolean closable) {
52
if (closable) {
53
frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
54
} else {
55
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
56
}
57
}
58
59
public void setClosingActionListener(ActionListener l) {
60
closingActionListener = l;
61
maybeInstallWindowListener();
62
}
63
64
public void setActivatedActionListener(ActionListener l) {
65
activatedActionListener = l;
66
maybeInstallWindowListener();
67
}
68
69
public void toFront() {
70
frame.toFront();
71
frame.requestFocus();
72
}
73
74
//----------------------------------------------------------------------
75
// Internals only below this point
76
//
77
78
private void maybeInstallWindowListener() {
79
if (!hasWindowListener) {
80
frame.addWindowListener(new WindowAdapter() {
81
public void windowClosing(WindowEvent e) {
82
if (closingActionListener != null) {
83
closingActionListener.actionPerformed(null);
84
}
85
}
86
87
public void windowActivated(WindowEvent e) {
88
if (activatedActionListener != null) {
89
activatedActionListener.actionPerformed(null);
90
}
91
}
92
});
93
hasWindowListener = true;
94
}
95
}
96
}
97
98