2 * Copyright © 2011 Keith Packard <keithp@keithp.com>
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.
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.
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.
19 package org.altusmetrum.altosuilib_14;
22 import java.awt.event.*;
25 class AltosUIDialogListener extends WindowAdapter {
26 public void windowClosing (WindowEvent e) {
27 AltosUIPreferences.unregister_ui_listener((AltosUIDialog) e.getWindow());
31 public class AltosUIDialog extends JDialog implements AltosUIListener {
33 private Container scrollPane;
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();
41 /* Make an opaque box to use the right color */
42 Box box = new Box(BoxLayout.X_AXIS);
46 /* Create a scrollpane to hold the box */
47 JScrollPane scroll = new JScrollPane();
48 JViewport view = scroll.getViewport();
51 /* Add the scroll pane to the top level */
54 return (Container) scrollPane;
57 public void ui_changed(String look_and_feel) {
58 SwingUtilities.updateComponentTreeUI(this);
62 public AltosUIDialog() {
63 AltosUIPreferences.register_ui_listener(this);
64 addWindowListener(new AltosUIDialogListener());
67 public AltosUIDialog(Frame frame, String label, boolean modal) {
68 super(frame, label, modal);
69 AltosUIPreferences.register_ui_listener(this);
70 addWindowListener(new AltosUIDialogListener());
73 public AltosUIDialog(Dialog dialog, String label, boolean modal) {
74 super(dialog, label, modal);
75 AltosUIPreferences.register_ui_listener(this);
76 addWindowListener(new AltosUIDialogListener());
79 public AltosUIDialog(Frame frame, boolean modal) {
81 AltosUIPreferences.register_ui_listener(this);
82 addWindowListener(new AltosUIDialogListener());