OSDN Git Service

fixed: GUIを一新した
[importpicture/importpicture.git] / src / main / java / osm / jp / gpx / matchtime / gui / QuitDialog.java
1 package osm.jp.gpx.matchtime.gui;
2
3 import java.awt.Font;
4 import java.awt.Rectangle;
5 import java.awt.Toolkit;
6 import java.awt.Window;
7 import java.awt.event.WindowEvent;
8 import java.awt.event.WindowListener;
9 import java.util.ResourceBundle;
10
11 import javax.swing.JButton;
12 import javax.swing.JDialog;
13 import javax.swing.JFrame;
14 import javax.swing.JLabel;
15
16 @SuppressWarnings("serial")
17 public class QuitDialog extends JDialog implements WindowListener
18 {
19     JButton yesButton;
20     JButton noButton;
21     JLabel label1;
22
23     @SuppressWarnings("OverridableMethodCallInConstructor")
24     public QuitDialog(JFrame parent, boolean modal) {
25         super(parent, modal);
26         
27         ResourceBundle i18n = ResourceBundle.getBundle("i18n");
28
29         addWindowListener((WindowListener) this);
30         setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
31
32         setLayout(null);
33         setSize(getInsets().left + getInsets().right + 337, getInsets().top + getInsets().bottom + 135);
34         
35         yesButton = new JButton(String.format("  %s  ", i18n.getString("dialog.quit")));
36         yesButton.addActionListener(new java.awt.event.ActionListener() {
37             @Override
38             public void actionPerformed(java.awt.event.ActionEvent evt) {
39                 Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new WindowEvent((Window)getParent(), 201));
40                 System.exit(0);
41             }
42         });
43         yesButton.setBounds(getInsets().left + 72, getInsets().top + 80, 79, 22);
44         yesButton.setFont(new Font("Dialog", 1, 12));
45         add(yesButton);
46
47         noButton = new JButton(i18n.getString("dialog.cancel"));
48         noButton.addActionListener(new java.awt.event.ActionListener() {
49             @Override
50             public void actionPerformed(java.awt.event.ActionEvent evt) {
51                 Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new WindowEvent(QuitDialog.this, WindowEvent.WINDOW_CLOSING));
52                 setVisible(false);
53             }
54         });
55         noButton.setBounds(getInsets().left + 185, getInsets().top + 80, 99, 22);
56         noButton.setFont(new Font("Dialog", 1, 12));
57         add(noButton);
58         
59         label1 = new JLabel(i18n.getString("dialog.msg1"), JLabel.CENTER);
60         label1.setBounds(78, 33, 180, 23);
61         add(label1);
62         setTitle(i18n.getString("dialog.msg1"));
63         setResizable(false);
64         setVisible(true);
65     }
66
67     @Override
68     public void setVisible(boolean b) {
69         if(b) {
70             Rectangle bounds = getParent().getBounds();
71             Rectangle abounds = getBounds();
72             setLocation(bounds.x + (bounds.width - abounds.width) / 2, bounds.y + (bounds.height - abounds.height) / 2);
73         }
74         super.setVisible(b);
75     }
76
77
78     @Override
79     public void windowActivated(WindowEvent e) {
80     }
81
82     @Override
83     public void windowClosed(WindowEvent e) {
84         setVisible(false);
85     }
86
87     @Override
88     public void windowClosing(WindowEvent e) {
89         setVisible(false);
90     }
91
92     @Override
93     public void windowDeactivated(WindowEvent e) {
94     }
95
96     @Override
97     public void windowDeiconified(WindowEvent e) {
98     }
99
100     @Override
101     public void windowIconified(WindowEvent e) {
102     }
103
104     @Override
105     public void windowOpened(WindowEvent e) {
106     }
107 }