2 // Getdown - application installer, patcher and launcher
3 // Copyright (C) 2004-2018 Getdown authors
4 // https://github.com/threerings/getdown/blob/master/LICENSE
6 package com.threerings.getdown.launcher;
8 import java.awt.Dimension;
9 import java.awt.event.ActionEvent;
10 import java.awt.event.ActionListener;
12 import java.util.MissingResourceException;
13 import java.util.ResourceBundle;
15 import javax.swing.BorderFactory;
16 import javax.swing.JButton;
17 import javax.swing.JFrame;
18 import javax.swing.JLabel;
19 import javax.swing.JPanel;
21 import com.samskivert.swing.GroupLayout;
22 import com.samskivert.swing.Spacer;
23 import com.samskivert.swing.VGroupLayout;
25 import com.threerings.getdown.util.MessageUtil;
26 import static com.threerings.getdown.Log.log;
29 * Displays a confirmation that the user wants to abort installation.
31 public final class AbortPanel extends JFrame
32 implements ActionListener
34 public AbortPanel (Getdown getdown, ResourceBundle msgs)
39 setLayout(new VGroupLayout());
41 setTitle(get("m.abort_title"));
43 JLabel message = new JLabel(get("m.abort_confirm"));
44 message.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
46 add(new Spacer(5, 5));
48 JPanel row = GroupLayout.makeButtonBox(GroupLayout.CENTER);
50 row.add(button = new JButton(get("m.abort_ok")));
51 button.setActionCommand("ok");
52 button.addActionListener(this);
53 row.add(button = new JButton(get("m.abort_cancel")));
54 button.setActionCommand("cancel");
55 button.addActionListener(this);
56 getRootPane().setDefaultButton(button);
60 // documentation inherited
62 public Dimension getPreferredSize ()
64 // this is annoyingly hardcoded, but we can't just force the width
65 // or the JLabel will claim a bogus height thinking it can lay its
66 // text out all on one line which will booch the whole UI's
68 return new Dimension(300, 200);
71 // documentation inherited from interface
72 public void actionPerformed (ActionEvent e)
74 String cmd = e.getActionCommand();
75 if (cmd.equals("ok")) {
82 /** Used to look up localized messages. */
83 protected String get (String key)
85 // if this string is tainted, we don't translate it, instead we
86 // simply remove the taint character and return it to the caller
87 if (MessageUtil.isTainted(key)) {
88 return MessageUtil.untaint(key);
91 return _msgs.getString(key);
92 } catch (MissingResourceException mre) {
93 log.warning("Missing translation message '" + key + "'.");
98 protected Getdown _getdown;
99 protected ResourceBundle _msgs;