Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Member Functions | Static Private Attributes
TrivialApplet Class Reference
Inheritance diagram for TrivialApplet:
Inheritance graph
[legend]
Collaboration diagram for TrivialApplet:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void init ()
boolean mouseEnter (Event evt, int x, int y)
boolean mouseExit (Event evt, int x, int y)
void print (String message)
int getAppletCount ()

Public Attributes

Button goButton
Button aboutButton
TextField urlField
PopupMenu contextMenu
Menu aboutMenu
ActionListener[] actionListeners

Private Member Functions

MenuItem newItem (String title, ActionListener listener)
Frame getFrame ()

Static Private Attributes

static int appletCount

Detailed Description

Definition at line 85 of file TrivialApplet.java.


Member Function Documentation

Definition at line 204 of file TrivialApplet.java.

                                {
       return appletCount;
    }
Frame TrivialApplet.getFrame ( ) [inline, private]

Definition at line 179 of file TrivialApplet.java.

                                {
              Component p = this;
              while (p != null && !(p instanceof Frame))
                     p = getParent();
              return (Frame)p;
       }
void TrivialApplet.init ( ) [inline]

Definition at line 94 of file TrivialApplet.java.

                          {
              ++appletCount;
       
              goButton = new Button("Go");
              aboutButton = new Button("About");
              
              String urlText = getParameter("URL");
              if (urlText == null)
                     urlText = "http://www.apple.com";
              
              urlField = new TextField(urlText);
              
              ActionListener goListener =
                     new ActionListener() {
                            public void actionPerformed(ActionEvent e) {
                                   try {
                                          URL location = new URL(urlField.getText());
                                          System.out.println("going to URL: " + location);
                                          JSObject window = JSObject.getWindow(TrivialApplet.this);
                                          if (window != null) {
                                                 //window.eval("alert('going to location " + location + "');");
                                                 window.eval("println('" + location + "')");
                                          }
                                          getAppletContext().showDocument(location, "_new");
                                   } catch (MalformedURLException mfue) {
                                   }
                            }
                     };
              
              ActionListener aboutListener =
                     new ActionListener() {
                            public void actionPerformed(ActionEvent e) {
                                   new AboutBox(aboutMenu, actionListeners);
                            }
                     };
              
              goButton.addActionListener(goListener);
              aboutButton.addActionListener(aboutListener);
                     
              add(goButton);
              add(aboutButton);
              add(urlField);
              
              // Try a pop-up menu, and a menu in the menubar.
              contextMenu = new PopupMenu();
              aboutMenu = new Menu("About");
              
              contextMenu.add(newItem("About", aboutListener));
              aboutMenu.add(newItem("About", aboutListener));
              
              contextMenu.add(newItem("Go", goListener));
              aboutMenu.add(newItem("Go", goListener));
              
              ActionListener errorListener = new ActionListener() {
                            public void actionPerformed(ActionEvent e) {
                                   new ExceptionThread();
                            }
                     };
              contextMenu.add(newItem("Error", errorListener));
              aboutMenu.add(newItem("Error", errorListener));
              
              ActionListener[] listeners = { aboutListener, goListener, errorListener };
              actionListeners = listeners;
              
              add(contextMenu);

              // add a mouse listener that causes the pop-up to appear appropriately.
              MouseListener mouseListener = new MouseAdapter() {
                     public void mousePressed(MouseEvent e) {
                            if (e.isPopupTrigger()) {
                                   e.consume();
                                   contextMenu.show(TrivialApplet.this, e.getX(), e.getY());
                            }
                     }
              };
              
              addMouseListener(mouseListener);
       }

Here is the call graph for this function:

boolean TrivialApplet.mouseEnter ( Event  evt,
int  x,
int  y 
) [inline]

Definition at line 188 of file TrivialApplet.java.

                                                       {
       showStatus("Welcome!");
              return true;
    }
boolean TrivialApplet.mouseExit ( Event  evt,
int  x,
int  y 
) [inline]

Definition at line 193 of file TrivialApplet.java.

                                                      {
       showStatus("See you later!");
              return true;
    }
MenuItem TrivialApplet.newItem ( String  title,
ActionListener  listener 
) [inline, private]

Definition at line 173 of file TrivialApplet.java.

                                                                       {
              MenuItem item = new MenuItem(title);
              item.addActionListener(listener);
              return item;
       }

Here is the caller graph for this function:

void TrivialApplet.print ( String  message) [inline]

Definition at line 198 of file TrivialApplet.java.

                                         {
              JSObject window = JSObject.getWindow(this);
              Object[] args = { message };
              window.call("println", args);
    }

Here is the call graph for this function:


Member Data Documentation

Definition at line 87 of file TrivialApplet.java.

Definition at line 90 of file TrivialApplet.java.

ActionListener [] TrivialApplet.actionListeners

Definition at line 91 of file TrivialApplet.java.

int TrivialApplet.appletCount [static, private]

Definition at line 92 of file TrivialApplet.java.

Definition at line 89 of file TrivialApplet.java.

Definition at line 86 of file TrivialApplet.java.

Definition at line 88 of file TrivialApplet.java.


The documentation for this class was generated from the following file: