home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-06-13 | 1.8 KB | 85 lines |
- // FrameComponent - demonstrates how to create a Frame with
- // a simple menu and how to read menu selections
- import java.applet.*;
- import java.awt.*;
- import TestFrame;
-
- public class FrameComponent extends Applet
- {
-
- // m_frame - this is the frame we create
- private Frame m_frame;
-
- // m_object - the action object passed from the
- // Frame menu
- private Object m_object;
-
- public FrameComponent()
- {
- // TODO: Add Constructor code here
- }
-
- public String getAppletInfo()
- {
- return "Name: FrameComponent\r\n" +
- "Author: Stephan R. Davis\r\n" +
- "Created for Learn Java Now";
- }
-
-
- public void init()
- {
- resize(320, 240);
-
- // TODO: Place Addition Initialization code here
- // create a frame of type TestFrame
- m_frame = new TestFrame(this);
-
- // size the frame
- Dimension d = size();
- m_frame.resize(d);
-
- // now make it visible (frames are created hidden)
- m_frame.show();
- }
-
- public void destroy()
- {
- // TODO: Place applet cleanup code here
- }
-
- // paint - if there is an action object, output it
- // to the applet window
- public void paint(Graphics g)
- {
- if (m_object != null)
- {
- g.drawString(m_object.toString(), 10, 20);
- }
- }
-
- public void start()
- {
- // TODO: Place additional applet Start code here
- }
-
- public void stop()
- {
- }
-
-
-
-
- // action - record the action object for
- // display (this method is not normally invoked -
- // it's only called here because the TestFrame
- // class passes the event along
- public boolean action(Event event, Object obj)
- {
- m_object = obj;
- repaint();
- return true;
- }
-
- }
-