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
|
package NET.worlds.network;
import NET.worlds.console.Console;
import NET.worlds.console.MultiLineLabel;
import NET.worlds.console.PolledDialog;
import NET.worlds.core.Std;
import java.awt.Button;
import java.awt.Event;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.text.MessageFormat;
public class NewVersionDialog extends PolledDialog {
private static final long serialVersionUID = -2091867202100838097L;
private Button yesButton = new Button(Console.message("Yes-Restart"));
private Button noButton = new Button(Console.message("No-Keep-Playing"));
private boolean confirmed;
Object[] arguments = new Object[]{new String(Std.getProductName())};
private String message = MessageFormat.format(Console.message("upgrade-is-now"), this.arguments);
private static String title = Console.message("Download-Complete");
private boolean done;
public NewVersionDialog() {
super(Console.getFrame(), null, title, false);
this.setAlignment(1);
this.readySetGo();
}
@Override
protected void build() {
GridBagLayout gbag = new GridBagLayout();
this.setLayout(gbag);
GridBagConstraints c = new GridBagConstraints();
c.anchor = 10;
c.fill = 0;
c.weightx = 1.0;
c.weighty = 1.0;
c.gridwidth = 0;
c.gridheight = 1;
this.add(gbag, new MultiLineLabel(this.message, 5, 5), c);
c.gridwidth = 2;
this.add(gbag, this.yesButton, c);
this.add(gbag, this.noButton, c);
}
@Override
public void show() {
super.show();
this.yesButton.requestFocus();
}
public synchronized boolean confirmRestart() {
while (this.isActive()) {
try {
this.wait();
} catch (InterruptedException var2) {
}
}
return this.getConfirmed();
}
@Override
protected synchronized boolean done(boolean confirmed) {
boolean retCode = super.done(confirmed);
this.notify();
return retCode;
}
@Override
public boolean action(Event event, Object what) {
if (event.target == this.yesButton) {
return this.done(true);
} else {
return event.target == this.noButton ? this.done(false) : false;
}
}
@Override
public boolean keyDown(Event event, int key) {
return key == 27 ? this.done(false) : super.keyDown(event, key);
}
}
|