home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 6.5 KB | 253 lines |
- /*---------------------------------------------------------------------------
-
- Written by the Personal Journal developers of Dow Jones & Company, Inc.
-
- Dow Jones makes no representations or warranties about
- the suitability of this software, either express or
- implied, including but not limited to the implied warranties
- of merchantability, fitness for a particular purpose,
- or non-infringement. Dow Jones will not be liable for
- any damages suffered by a user as a result of using,
- modifying or distributing this software or its derivatives.
-
-
- @(#)PjFrame.java 0.00 15-Jan-95
-
- A MainFrame customized for Personal Journal.
-
- Authors:
-
- rphall Rick Hall
- lning Lindee Ning
- jlee James Lee
-
- Version Ident:
-
- $Header$
-
- History:
-
- 15-Jan-95 rphall Initial Creation
- 08-Mar-96 lning Added action() in order to pass the command
- from selecting the menuitem.
- Also use PjNbSpec to difine the menuitems in
- "Contents" menu in order to bind them to corresponding pages.
- 21-Mar-96 jlee Changed the frame title from "Personal Journal" to "Web Street Journal"
- 26-Mar-96 Ted S. Changed it back, the Lawyers said "Personal Journal" is OK.
- 28-Mar-96 jlee Added setAboutBoxImage
- 29-Mar-96 jlee Got rid of setAboutBoxImage and changed the way adBox is created.
- ---------------------------------------------------------------------------*/
-
- package pj.awt;
-
- import pj.awt.AboutDialog;
- import pj.awt.MainFrame;
- import pj.awt.PjNbSpec;
-
- import java.awt.Event;
- import java.awt.Image;
- import java.awt.Menu;
- import java.awt.MenuBar;
- import java.awt.MenuItem;
- import java.lang.String;
-
- class PjMenuItem extends MenuItem
- {
-
- // --- Instance variables
-
- String m_itemData;
- String label;
-
- // --- Public constructor
-
- public PjMenuItem(String label, String itemData)
- {
- super(label);
- m_itemData = itemData;
- }
-
- // --- Public operations
-
- public String getItemData()
- {
- return m_itemData;
- } // getItemData()
-
- } // PjMenuItem
-
-
- class PjMenuBar extends MenuBar
- {
-
- // --- Class variables
-
- /** File menu */
- public static final String strFile = "File";
-
- /** Edit menu */
- //public static final String strEdit = "Edit";
-
- /** Contents menu */
- public static final String strCtnt = "Contents";
-
- /** File Connect */
- //public static final String strFileConnect = "Connect";
-
- /** File SaveAs */
- //public static final String strFileSaveAs = "Save As...";
-
- /** File Print */
- //public static final String strFilePrint = "Print...";
-
- /** File Printer Setup */
- //public static final String strFilePrinter = "Printer Setup...";
-
- /** File Exit */
- public static final String strFileExit = "Exit";
-
- /** Edit Copy */
- //public static final String strEditCopy = "Copy";
-
- /** Edit SelectAll */
- //public static final String strEditSelect = "Select All";
-
- /** Help */
- public static final String strHelp = "Help";
-
- /** Help About Personal Journal... */
- public static final String strHelpAbout = "About Personal Journal...";
-
-
- private static final String astrMenuFile = strFileExit;
-
- /*
- private static final String[] astrMenuEdit =
- {
- strEditCopy,strEditSelect
- };
- */
-
- // --- Public constructors
-
- public PjMenuBar()
- {
- Menu m;
- Menu rootmenu;
-
- m = new Menu(strFile,/*tearOff*/true);
- m.add( new MenuItem(astrMenuFile) );
-
- add(m);
-
- m = new Menu(strCtnt,/*tearOff*/true);
-
- PjNbSpec nbs = new PjNbSpec();
- for (int i=0; i<nbs.mainmenustring.length; i++)
- {
- if(nbs.substrings[i] != null)
- {
- rootmenu = new Menu(nbs.mainmenustring[i],/*tearOff*/true);
- for (int j=0; j<nbs.substrings[i].length; j++)
- rootmenu.add( new PjMenuItem((nbs.substrings[i])[j],(nbs.subnames[i])[j]) );
-
- m.add( rootmenu );
- }
- else
- m.add( new PjMenuItem(nbs.mainmenustring[i],nbs.mainmenuname[i]) );
- } // for
-
- add(m);
-
- m = new Menu(strHelp,/*tearOff*/true);
- m.add( new MenuItem( strHelpAbout ) );
-
- add(m);
- setHelpMenu( m );
-
- } // PjMenuBar constructor
-
- } // PjMenuBar
-
-
-
- /**
- * A MainFrame customized for Personal Journal.
- *
- * @see pj.awt.MainFrame
- * @version 0.00 15-Jan-95
- * @author rphall
- */
- public class PjFrame extends MainFrame
- {
-
- // --- Class variables
-
- /** Frame title */
- public static final String strPjFrameTitle = "Personal Journal";
-
-
- // --- Instance variables
- private PjImages piPjImages = null;
- private AboutDialog adBox = null;
-
-
- // --- Public constructors
-
- /**
- * Construct a PjFrame.
- */
- public PjFrame()
- { this((PjImages)null); }
-
- /**
- * Construct a PjFrame.
- */
- public PjFrame( PjImages piImages )
- {
- super(strPjFrameTitle);
-
- piPjImages = piImages;
- setMenuBar(new PjMenuBar());
- System.out.println("Debug-PjFrame:constructed");
- }
-
-
-
- // --- Public operations
-
- /**
- * Catch the action from menubar and pass it down
- */
- public boolean action(Event evt, Object arg)
- {
- if ( evt.target instanceof MenuItem )
- {
- if ( PjMenuBar.strFileExit.equals(((MenuItem)(evt.target)).getLabel()) )
- {
- dispose();
- return true;
- }
- else
- if ( PjMenuBar.strHelpAbout.equals( ((MenuItem)(evt.target)).getLabel()) )
- {
- if ( (adBox == null) || (adBox != null && !adBox.isVisible()) )
- {
- adBox = new AboutDialog( this, "About Personal Journal", true );//modal dialog box
- adBox.Initialize( piPjImages );
- return true;
- }
- }
- }
- else
- return false;
-
- int count = countComponents();
-
- for(int i = 0; i < count; i++)
- getComponent(i).handleEvent(evt);
-
- return true;
- }
- }; // PjFrame
-