[549] in java-interest

home help back first fref pref prev next nref lref last post

Re: Starting Awt???

daemon@ATHENA.MIT.EDU (Sven Rizzotti)
Fri Jun 30 04:01:11 1995

From: Sven Rizzotti <rizzotti.sven@ch.swissbank.com>
Date: Fri, 30 Jun 95 09:48:24 +0200
To: Jeff.Kesselman@netcom.com
Cc: java-interest@java.sun.com

Had the same experience at the begining, try this:

In your subclass of Applet initialize the parent window with this in the  
start() method:

class ProjectApplet extends Applet {
	public Frame projectFrame;
		
	public void init() {
		resize(0,0);
 	}
	
	public void start() {
		Window win;
	
	        while (((win = item.parent) == null) &&
	            ((item.getStatus() == AppletDisplayItem.STARTED) ||
	            (item.getStatus() == AppletDisplayItem.INITIALIZING))) {
	        }
		projectFrame = new ProjectFrame(w.wServer, false, null, 380,  
200, Color.lightGray);
	}
}


Then I wrote a subclass of Frame like:

class ProjectFrame extends Frame {
	ProjectWindow win;

	ProjectFrame(WServer ws, boolean hasTitleBar, Frame parentFrame, int  
w, int h, Color bg) {
		super(ws, hasTitleBar, parentFrame, w, h, bg);
		super.setTitle("Projects");
		super.setMinSize(width+20, height+100);
		win = new ProjectWindow(this, "Center", bg, width, height+100);
		map();
	}
}


And finally you'll need your own version of a window:

class ProjectWindow extends Window implements ChoiceHandler {
	public List list;
	Label labelProject;
	
	ProjectWindow(Container w, String  name, Color  bg, int wd, int ht) {
		super(w, name, bg, wd, ht);
		Row row = new Row(this, null, true);
		
		labelProject = new Label("Projects", "labelProjects", this);
		list = new List(this, this, "ProjectList", 10, false, false);
		list.select(0);
	}

	public void selected(Component c, int pos) {
		if (c.name == "ProjectList") {
			// do whatever you want with it
		}
	}
	
	public void handleResize() {
		labelProject.move(10, 10);
		list.reshape(10, 30, width/2 - 20, height-30);
	}
}


These are the basic tricks, I only noted the important part of it, you also  
have to implement doubleClick() within window because of the choiceHandler  
keyword. Note that you can do your own stuff in handleResize() when the window  
is resized. handleResize() is an overwritten method of Window.

__Sven
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post