1 42 43 package org.jfree.ui.tabbedui; 44 45 import java.awt.BorderLayout ; 46 import java.awt.Dialog ; 47 import java.awt.Frame ; 48 import java.awt.event.ActionEvent ; 49 import java.awt.event.WindowAdapter ; 50 import java.awt.event.WindowEvent ; 51 import java.beans.PropertyChangeEvent ; 52 import java.beans.PropertyChangeListener ; 53 54 import javax.swing.JDialog ; 55 import javax.swing.JPanel ; 56 57 62 public class TabbedDialog extends JDialog { 63 64 65 private AbstractTabbedUI tabbedUI; 66 67 70 private class MenuBarChangeListener implements PropertyChangeListener { 71 72 75 public MenuBarChangeListener() { 76 } 77 78 84 public void propertyChange(final PropertyChangeEvent evt) { 85 if (evt.getPropertyName().equals(AbstractTabbedUI.JMENUBAR_PROPERTY)) { 86 setJMenuBar(getTabbedUI().getJMenuBar()); 87 } 88 } 89 } 90 93 public TabbedDialog() { 94 } 95 96 101 public TabbedDialog(final Dialog owner) { 102 super(owner); 103 } 104 105 111 public TabbedDialog(final Dialog owner, final boolean modal) { 112 super(owner, modal); 113 } 114 115 121 public TabbedDialog(final Dialog owner, final String title) { 122 super(owner, title); 123 } 124 125 132 public TabbedDialog(final Dialog owner, final String title, final boolean modal) { 133 super(owner, title, modal); 134 } 135 136 141 public TabbedDialog(final Frame owner) { 142 super(owner); 143 } 144 145 151 public TabbedDialog(final Frame owner, final boolean modal) { 152 super(owner, modal); 153 } 154 155 161 public TabbedDialog(final Frame owner, final String title) { 162 super(owner, title); 163 } 164 165 172 public TabbedDialog(final Frame owner, final String title, final boolean modal) { 173 super(owner, title, modal); 174 } 175 176 177 182 protected final AbstractTabbedUI getTabbedUI() 183 { 184 return tabbedUI; 185 } 186 187 192 public void init(final AbstractTabbedUI tabbedUI) { 193 194 this.tabbedUI = tabbedUI; 195 this.tabbedUI.addPropertyChangeListener 196 (AbstractTabbedUI.JMENUBAR_PROPERTY, new MenuBarChangeListener()); 197 198 addWindowListener(new WindowAdapter () { 199 public void windowClosing(final WindowEvent e) { 200 getTabbedUI().getCloseAction().actionPerformed 201 (new ActionEvent (this, ActionEvent.ACTION_PERFORMED, null, 0)); 202 } 203 }); 204 205 final JPanel panel = new JPanel (); 206 panel.setLayout(new BorderLayout ()); 207 panel.add(tabbedUI, BorderLayout.CENTER); 208 setContentPane(panel); 209 setJMenuBar(tabbedUI.getJMenuBar()); 210 211 } 212 213 } 214 | Popular Tags |