home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 10.2 KB | 332 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:
-
- jlee James Lee
- Ted S. Ted Skolnick
-
- Version Ident:
-
- $Header:$
-
- History:
-
- 27-Mar-96 jlee Initial Creation
- 28-Mar-96 jlee Added initBoxText
- 28-Mar-96 Ted S. Added some more text.
- 29-Mar-96 jlee Changed old Initialize() to Initialize( PjImages )
- ---------------------------------------------------------------------------*/
-
- package pj.awt;
-
- import pj.awt.GifCanvas;
- import pj.awt.Panel3D;
- import pj.awt.PjFinals;
- import pj.awt.PjImages;
- import pj.awt.TextCanvas;
-
- import java.awt.Button;
- import java.awt.Canvas;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.Dialog;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.GridBagConstraints;
- import java.awt.GridBagLayout;
- import java.awt.Frame;
- import java.awt.Image;
- import java.awt.Insets;
- import java.awt.LayoutManager;
- import java.awt.Panel;
- import java.awt.Rectangle;
- import java.lang.String;
-
-
- class AboutDialog extends Dialog
- {
- // --- Public constructors
- public AboutDialog( Frame frmParent, String strTitle, boolean bModal )
- {
- super( frmParent, strTitle, bModal );
- }
-
-
- // --- Public functions
- public void Initialize( PjImages piImages )
- {
- GifCanvas gcAboutBox = null;
- Image iPjLogo = null;
- PjImages iPjImages = null;
-
- setResizable( false );
- setLayout( new AboutBoxLayout( 0, 3 ) );
-
- if ( piImages != null )
- iPjLogo = piImages.imagespecs()[piImages.idxPjLogo].getImage();
-
- if ( iPjLogo != null )
- gcAboutBox = new GifCanvas( iPjLogo );
- else
- {
- System.out.println("Error-AboutDialog-Initialize:About Box Image is null!");
- dispose();
- return;
- }
-
- add( gcAboutBox );
-
- Panel3D pnl3dText = new Panel3D();
- TextCanvas tcvText = new TextCanvas();
- pnl3dText.add( tcvText );
- add( pnl3dText );
-
- Button btnOk = new Button("OK");
- add( btnOk );
-
- pack();
- show();
- resize( PjFinals.dimAboutDialogSize );
-
- initBoxText( tcvText );
- }
-
- private void initBoxText( TextCanvas tcvText )
- {
- // 0: PLAIN font, 1: BOLD font 2: ITALIC font
- tcvText.addText( "", 0 );
- tcvText.addText( "Personal Journal (Java Implementation) Version 1.0(Build0329)", 1 );
- tcvText.addText( "", 0 );
- tcvText.addText( "Dow Jones & Company, Inc.", 1 );
- tcvText.addText( "", 0 );
- tcvText.addText( "Personal Journal gives you a quick read of selected", 1 );
- tcvText.addText( "Wall Street Journal editiorial, business and world-wide", 1 );
- tcvText.addText( "news plus the news that's most important to you.", 1 );
- tcvText.addText( "", 0 );
- tcvText.addText( "Develped by:", 1 );
- tcvText.addText( " Laura Bertrand, Mark Bukovec, Richard Hall, James Lee", 1 );
- tcvText.addText( " Lindee Ning, Alka Rao, Nimesh Shah, Ted Skolnick", 1 );
- tcvText.addText( "", 0 );
- tcvText.addText( "Thanks to:", 1 );
- tcvText.addText( " Amy Katz, Keith Tuskey for their help.", 1 );
- }
-
-
- /**
- * Handle an event. A AboutDialog will handle Event.WINDOW_DESTROY,
- * and delegate other events to its superclass, Frame.
- * @param evt An event targeted at the frame.
- * @return True if the frame handled the event, false otherwise.
- */
- public boolean handleEvent( Event evt )
- {
- switch ( evt.id )
- {
- case Event.WINDOW_DESTROY:
- dispose();
- return true;
- case Event.ACTION_EVENT:
- if ( evt.target instanceof Button )
- {
- dispose();
- return true;
- }
- break;
- default:
- break;
- }//switch
-
- return false;
- } // handleEvent
- }// AboutDialog
-
- /*---------------------------------------------------------------------------
-
- 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.
-
-
- @(#)AboutBoxLayout.java 0.00 8-Feb-96
-
- A AboutBoxLayout that manages the eaual size buttons layout.
-
- Authors:
-
- jlee James Lee
-
- Version Ident:
-
- $Header:$
-
- History:
-
- 27-Mar-96 jlee Initial creation.
- ---------------------------------------------------------------------------*/
-
- /**
- * AboutBoxLayout is used to layout equal size buttons in a panel.
- * @version 0.00, 8/2/96
- * @author James Lee
- */
- class AboutBoxLayout implements LayoutManager
- {
-
- // Instance variables
-
- private int hgap;
- private int vgap;
-
- private Rectangle recLast = new Rectangle(0, 0, 0, 0);
-
-
- // --- Public constructors
- /**
- * Constructs a new Flow Layout with a centered alignment.
- * Default value for hgap and vgap is 0.
- */
- public AboutBoxLayout()
- {
- this(0, 0);
- }
-
- /**
- * Constructs a new Flow Layout with the specified alignment and gap
- * values.
- * @param hgap the horizontal gap variable
- * @param vgap the vertical gap variable
- */
- public AboutBoxLayout(int hgap, int vgap)
- {
- this.hgap = hgap;
- this.vgap = vgap;
- }
-
- // --- Public operations
- /**
- * Adds the specified component to the layout. Not used by this class.
- * @param name the name of the component
- * @param comp the the component to be added
- */
- public void addLayoutComponent(String name, Component comp)
- {
- }
-
- /**
- * Removes the specified component from the layout. Not used by
- * this class.
- * @param comp the component to remove
- */
- public void removeLayoutComponent(Component comp)
- {
- }
-
- /**
- * Returns the preferred dimensions for this layout given the components
- * in the specified target container.
- * @param target the component which needs to be laid out
- * @see Container
- * @see #minimumLayoutSize
- */
- public Dimension preferredLayoutSize(Container target)
- {
- return PjFinals.dimAboutDialogSize;
- }
-
- /**
- * Returns the minimum dimensions needed to layout the components
- * contained in the specified target container.
- * @param target the component which needs to be laid out
- * @see #preferredLayoutSize
- */
- public Dimension minimumLayoutSize(Container target)
- {
- return PjFinals.dimAboutDialogSize;
- }
-
-
- /**
- * Lays out the container. This method will actually reshape the
- * components in the target in order to satisfy the constraints of
- * the PjAdViewLayout object.
- * @param target the specified component being laid out.
- * @see Container
- */
- public void layoutContainer(Container target)
- {
- Insets insets = target.insets();
- Rectangle rec = target.bounds();
-
- if ( target.isValid() &&
- rec.x == recLast.x && rec.y == recLast.y &&
- rec.width == recLast.width && rec.height == recLast.height )
-
- return;
- else
- recLast = rec;
-
- int maxwidth = rec.width - (insets.left + insets.right);
- int maxheight = rec.height - (insets.top + insets.bottom + vgap*2);
- int nmembers = target.countComponents();
-
- int x;
-
- for (int i = 0 ; i < nmembers ; i++)
- {
- Component m = target.getComponent(i);
-
- if ( m.isVisible() )
- switch ( i )
- {
- case 0://image
- x = (maxwidth - PjFinals.dimAboutBoxImage.width) / 2 + insets.left;
- m.move( x , insets.top );
- break;
- case 1://panel
- m.reshape( insets.left, insets.top + vgap + PjFinals.dimAboutBoxImage.height,
- maxwidth, maxheight - PjFinals.dimOKButton.height - PjFinals.dimAboutBoxImage.height );
- break;
- case 2://button
- x = (maxwidth - PjFinals.dimOKButton.width) / 2 + insets.left;
- m.reshape( x, insets.top + maxheight - PjFinals.dimOKButton.height + vgap,
- PjFinals.dimOKButton.width, PjFinals.dimOKButton.height );
- break;
- default:
- break;
- }
- }
- }
-
- /**
- * Returns the String representation of this AboutBoxLayout's values.
- */
- public String toString()
- {
- return getClass().getName() + "[hgap=" + hgap + ",vgap=" + vgap + "]";
- }
- }
-