dc737414532718a14c236925f0ce442be200ed2c
[fw/altos] / altosuilib / AltosUIDialog.java
1 /*
2  * Copyright © 2011 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17
18 package org.altusmetrum.altosuilib_2;
19
20 import java.awt.*;
21 import java.awt.event.*;
22 import javax.swing.*;
23
24 class AltosUIDialogListener extends WindowAdapter {
25         public void windowClosing (WindowEvent e) {
26                 AltosUIPreferences.unregister_ui_listener((AltosUIDialog) e.getWindow());
27         }
28 }
29
30 public class AltosUIDialog extends JDialog implements AltosUIListener {
31
32         public void ui_changed(String look_and_feel) {
33                 SwingUtilities.updateComponentTreeUI(this);
34                 this.pack();
35         }
36
37         public AltosUIDialog() {
38                 AltosUIPreferences.register_ui_listener(this);
39                 addWindowListener(new AltosUIDialogListener());
40         }
41
42         public AltosUIDialog(Frame frame, String label, boolean modal) {
43                 super(frame, label, modal);
44                 AltosUIPreferences.register_ui_listener(this);
45                 addWindowListener(new AltosUIDialogListener());
46         }
47
48         public AltosUIDialog(Dialog dialog, String label, boolean modal) {
49                 super(dialog, label, modal);
50                 AltosUIPreferences.register_ui_listener(this);
51                 addWindowListener(new AltosUIDialogListener());
52         }
53
54         public AltosUIDialog(Frame frame, boolean modal) {
55                 super(frame, modal);
56                 AltosUIPreferences.register_ui_listener(this);
57                 addWindowListener(new AltosUIDialogListener());
58         }
59 }