altos/test: Adjust CRC error rate after FEC fix
[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; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18
19 package org.altusmetrum.altosuilib_14;
20
21 import java.awt.*;
22 import java.awt.event.*;
23 import javax.swing.*;
24
25 class AltosUIDialogListener extends WindowAdapter {
26         public void windowClosing (WindowEvent e) {
27                 AltosUIPreferences.unregister_ui_listener((AltosUIDialog) e.getWindow());
28         }
29 }
30
31 public class AltosUIDialog extends JDialog implements AltosUIListener {
32
33         private Container scrollPane;
34
35         public Container getScrollablePane() {
36                 if (scrollPane == null) {
37                         Container content = super.getContentPane();
38                         /* Create a container to hold the dialog contents */
39                         scrollPane = new Container();
40
41                         /* Make an opaque box to use the right color */
42                         Box box = new Box(BoxLayout.X_AXIS);
43                         box.add(scrollPane);
44                         box.setOpaque(true);
45
46                         /* Create a scrollpane to hold the box */
47                         JScrollPane scroll = new JScrollPane();
48                         JViewport view = scroll.getViewport();
49                         view.add(box);
50
51                         /* Add the scroll pane to the top level */
52                         content.add(scroll);
53                 }
54                 return (Container) scrollPane;
55         }
56
57         public void ui_changed(String look_and_feel) {
58                 SwingUtilities.updateComponentTreeUI(this);
59                 this.pack();
60         }
61
62         public AltosUIDialog() {
63                 AltosUIPreferences.register_ui_listener(this);
64                 addWindowListener(new AltosUIDialogListener());
65         }
66
67         public AltosUIDialog(Frame frame, String label, boolean modal) {
68                 super(frame, label, modal);
69                 AltosUIPreferences.register_ui_listener(this);
70                 addWindowListener(new AltosUIDialogListener());
71         }
72
73         public AltosUIDialog(Dialog dialog, String label, boolean modal) {
74                 super(dialog, label, modal);
75                 AltosUIPreferences.register_ui_listener(this);
76                 addWindowListener(new AltosUIDialogListener());
77         }
78
79         public AltosUIDialog(Frame frame, boolean modal) {
80                 super(frame, modal);
81                 AltosUIPreferences.register_ui_listener(this);
82                 addWindowListener(new AltosUIDialogListener());
83         }
84 }