NCSAHabanero

[ Previous ] [ Index ] [ Next ]

-------------------------------------------------------------------
How specify the size, title, and other attributes of a hablet's window
-------------------------------------------------------------------

Specifying the Default Window Parameters

Background Information

Regular applets usually run in HTML pages, and the APPLET tag in HTML specifies how big the space for the applet should be.

In Habanero, there is no HTML page. Instead, the hablet runs in its own window. Thus it needs to have a method that tells it window size and other details.

How does this work?

The name of the method that does this is startInFrame(MirrorFrame).

Things included in the body of startInFrame(MirrorFrame):

MirrorFrame is a subclass of Frame[Outside link]
 
Running Example from the example of habanerizing TextDemo.java.
Add or modify this method in the class HabTextDemo
  public void startInFrame(MirrorFrame f)
  {
    f.setTitle("Habanerized TextDemo");
 
    f.add("Center", this);      // Center hablet in window
    f.setSize(500,200);         // Window's size
    f.setVisible(true);         // Window initially visible
 
    f.show();                   // Show the window
 
    init();                     // Initialize hablet code
    start();                    // Start hablet running

    // Code for event handling goes here.
  }
 
 
ALERT 

If you need to post an event from within StartInFrame(), you must post it from a new thread, or it will deadlock. 

What next?



Habanero® is a registered trademark owned by The Board of Trustees of the University of Illinois. Copyright 1996-1998. All rights reserved.   Java(TM) is a proprietary trademark owned by Sun Microsystems, Inc. NCSA
The National Center for Supercomputing Applications

University of Illinois at Urbana-Champaign

Contacts page