1 42 43 package org.jfree.ui.tabbedui; 44 45 import java.awt.BorderLayout ; 46 import java.awt.event.ActionEvent ; 47 import java.awt.event.WindowAdapter ; 48 import java.awt.event.WindowEvent ; 49 import java.beans.PropertyChangeEvent ; 50 import java.beans.PropertyChangeListener ; 51 52 import javax.swing.JFrame ; 53 import javax.swing.JPanel ; 54 55 60 public class TabbedFrame extends JFrame { 61 62 63 private AbstractTabbedUI tabbedUI; 64 65 68 private class MenuBarChangeListener implements PropertyChangeListener { 69 70 73 public MenuBarChangeListener() { 74 } 75 76 82 public void propertyChange(final PropertyChangeEvent evt) { 83 if (evt.getPropertyName().equals(AbstractTabbedUI.JMENUBAR_PROPERTY)) { 84 setJMenuBar(getTabbedUI().getJMenuBar()); 85 } 86 } 87 } 88 89 92 public TabbedFrame() { 93 } 94 95 100 public TabbedFrame(final String title) { 101 super(title); 102 } 103 104 109 protected final AbstractTabbedUI getTabbedUI() 110 { 111 return tabbedUI; 112 } 113 114 119 public void init(final AbstractTabbedUI tabbedUI) { 120 121 this.tabbedUI = tabbedUI; 122 this.tabbedUI.addPropertyChangeListener( 123 AbstractTabbedUI.JMENUBAR_PROPERTY, new MenuBarChangeListener() 124 ); 125 126 addWindowListener(new WindowAdapter () { 127 public void windowClosing(final WindowEvent e) { 128 getTabbedUI().getCloseAction().actionPerformed 129 (new ActionEvent (this, ActionEvent.ACTION_PERFORMED, null, 0)); 130 } 131 }); 132 133 final JPanel panel = new JPanel (); 134 panel.setLayout(new BorderLayout ()); 135 panel.add(tabbedUI, BorderLayout.CENTER); 136 setContentPane(panel); 137 setJMenuBar(tabbedUI.getJMenuBar()); 138 } 139 140 } 141 | Popular Tags |