-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmyWindow.java
More file actions
executable file
·117 lines (104 loc) · 3.49 KB
/
myWindow.java
File metadata and controls
executable file
·117 lines (104 loc) · 3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
* myWindow.java
*
* Created on December 16, 2003, 11:09 AM
* Description: A window frame with WindowListener
*
* Note: compile in Java 1.1
*
*/
/**
* @author Chen-Fu Liao
* Sr. Systems Engineer
* ITS Institute, ITS Laboratory
* Center For Transportation Studies
* University of Minnesota
* 200 Transportation and Safety Building
* 511 Washington Ave. SE
* Minneapolis, MN 55455
*/
//package network2D ;
import java.awt.* ;
import java.awt.event.* ; // doesn't automatically load with java.awt.*
public class myWindow extends Frame implements WindowListener {
public boolean isClosed=false;
/** Creates a new instance of myWindow */
public myWindow() {
this.addWindowListener(this) ;
}
public myWindow(String title) {
this.addWindowListener(this) ;
this.setTitle(title) ;
}
/** Invoked when the Window is set to be the active Window. Only a Frame or
* a Dialog can be the active Window. The native windowing system may
* denote the active Window or its children with special decorations, such
* as a highlighted title bar. The active Window is always either the
* focused Window, or the first Frame or Dialog that is an owner of the
* focused Window.
*
*/
public void windowActivated(WindowEvent e) {
}
/** Invoked when a window has been closed as the result
* of calling dispose on the window.
*
*/
public void windowClosed(WindowEvent e) {
isClosed=true;
}
/** Invoked when the user attempts to close the window
* from the window's system menu. If the program does not
* explicitly hide or dispose the window while processing
* this event, the window close operation will be cancelled.
*
*/
public void windowClosing(WindowEvent e) {
//System.out.println("closing") ;
this.dispose() ;
}
/** Invoked when a Window is no longer the active Window. Only a Frame or a
* Dialog can be the active Window. The native windowing system may denote
* the active Window or its children with special decorations, such as a
* highlighted title bar. The active Window is always either the focused
* Window, or the first Frame or Dialog that is an owner of the focused
* Window.
*
*/
public void windowDeactivated(WindowEvent e) {
}
/** Invoked when a window is changed from a minimized
* to a normal state.
*
*/
public void windowDeiconified(WindowEvent e) {
}
/** Invoked when a window is changed from a normal to a
* minimized state. For many platforms, a minimized window
* is displayed as the icon specified in the window's
* iconImage property.
* @see java.awt.Frame#setIconImage
*
*/
public void windowIconified(WindowEvent e) {
}
/** Invoked the first time a window is made visible.
*
*/
public void windowOpened(WindowEvent e) {
isClosed=false;
//try {
//Thread.sleep(1000); // wait for a little while
//} catch (InterruptedException ie){}
this.toFront();
}
public void setCenter(){
Dimension screen = getToolkit().getDefaultToolkit().getScreenSize();
double top = 0.5*(screen.getWidth()-this.getWidth());
double left = 0.5*(screen.getHeight()-this.getHeight());
int x = new Double(top).intValue();
int y = new Double(left).intValue();
this.setLocation(x, y);
this.toFront();
}
}