Frames | No Frames |
1: /* ======================================================================== 2: * JCommon : a free general purpose class library for the Java(tm) platform 3: * ======================================================================== 4: * 5: * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors. 6: * 7: * Project Info: http://www.jfree.org/jcommon/index.html 8: * 9: * This library is free software; you can redistribute it and/or modify it 10: * under the terms of the GNU Lesser General Public License as published by 11: * the Free Software Foundation; either version 2.1 of the License, or 12: * (at your option) any later version. 13: * 14: * This library is distributed in the hope that it will be useful, but 15: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 16: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 17: * License for more details. 18: * 19: * You should have received a copy of the GNU Lesser General Public 20: * License along with this library; if not, write to the Free Software 21: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 22: * USA. 23: * 24: * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 25: * in the United States and other countries.] 26: * 27: * ----------------- 28: * TabbedApplet.java 29: * ----------------- 30: * (C)opyright 2004, by Thomas Morgner and Contributors. 31: * 32: * Original Author: Thomas Morgner; 33: * Contributor(s): David Gilbert (for Object Refinery Limited); 34: * 35: * $Id: TabbedApplet.java,v 1.5 2005/10/18 13:23:37 mungady Exp $ 36: * 37: * Changes 38: * ------------------------- 39: * 16-Feb-2004 : Initial version 40: * 07-Jun-2004 : Added standard header (DG); 41: */ 42: 43: package org.jfree.ui.tabbedui; 44: 45: import java.awt.BorderLayout; 46: import java.beans.PropertyChangeEvent; 47: import java.beans.PropertyChangeListener; 48: 49: import javax.swing.JApplet; 50: import javax.swing.JPanel; 51: 52: /** 53: * An applet implementation that uses a tabbed GUI as backend. 54: * 55: * @author Thomas Morgner 56: */ 57: public class TabbedApplet extends JApplet { 58: 59: /** 60: * A property change listener that waits for the menubar to change. 61: */ 62: private class MenuBarChangeListener implements PropertyChangeListener { 63: /** 64: * Creates a new change listener. 65: */ 66: public MenuBarChangeListener() { 67: } 68: 69: /** 70: * This method gets called when a bound property is changed. 71: * 72: * @param evt A PropertyChangeEvent object describing the event source 73: * and the property that has changed. 74: */ 75: public void propertyChange(final PropertyChangeEvent evt) { 76: if (evt.getPropertyName().equals(AbstractTabbedUI.JMENUBAR_PROPERTY)) { 77: setJMenuBar(getTabbedUI().getJMenuBar()); 78: } 79: } 80: } 81: 82: /** The UI for the applet. */ 83: private AbstractTabbedUI tabbedUI; 84: 85: /** 86: * Default constructor. 87: */ 88: public TabbedApplet() { 89: } 90: 91: 92: /** 93: * Returns the UI implementation for the applet. 94: * 95: * @return Returns the tabbedUI. 96: */ 97: protected final AbstractTabbedUI getTabbedUI() 98: { 99: return tabbedUI; 100: } 101: /** 102: * Initialises the applet. 103: * 104: * @param tabbedUI the UI that controls the applet. 105: */ 106: public void init(final AbstractTabbedUI tabbedUI) { 107: 108: this.tabbedUI = tabbedUI; 109: this.tabbedUI.addPropertyChangeListener 110: (AbstractTabbedUI.JMENUBAR_PROPERTY, new MenuBarChangeListener()); 111: 112: final JPanel panel = new JPanel(); 113: panel.setLayout(new BorderLayout()); 114: panel.add(tabbedUI, BorderLayout.CENTER); 115: setContentPane(panel); 116: setJMenuBar(tabbedUI.getJMenuBar()); 117: } 118: 119: }