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); } }