[1032] in java-interest

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

Re: stand-alone apps

daemon@ATHENA.MIT.EDU (Paul Beerkens)
Thu Aug 17 07:31:51 1995

From: Paul Beerkens <beerkens@prl.philips.co.uk>
Date: Thu, 17 Aug 1995 08:55:29 +0100
To: hodgesc@rockie.nsc.com
Cc: java-interest@java.sun.com


Hello Chris,

I know it is al very confusing, mainly because there is no documentation availible especcialy on stand-alone applications.

The program I send you contains two parts. The first part (GraphicsTest) contains a stand-alone Runable object (called GraphicsTest), the second part contains an object that runs as a thread (multitasking) but does nothing (because I didn't implement anything to do).

A basic java stand alone application has one object that contains a main function (has to be static). This object starts up the application. That is all it does. 

But lets concentrate first on the graphics part.

class GraphicsTest {
    static awt.Graphics MyGraphics;
public static void main (String argv [])
	{
	    awt.WServer MyWServer=new awt.WServer ();
	    MyWServer.start ();
// Create our own windows server

	    Window MyWindow;
// create a variable that can contain an window 
	    Frame MyFrame;
// create a variable that can contain a frame

	    MyFrame=new Frame (MyWServer,true,false,null,300,300,Color.gray);
	    MyFrame.setTitle ("Graphics Test Frame");
// create a frame in MyWServer with backgroundcolor gray	    
            MyWindow=new Window ( MyFrame,"Center",Color.white,200,200);
// create  a window in MyFrame with backgroundcolor white
// a window can contain graphical objects
// if you use "Center" than the size of the window will be acording to the size
// of the frame. If you resize the frame the size of the window will change 
// aswell. Try out "Left", this gives a different effect. As fas as I know this
// is not documented. Maybe there are other options
	    MyGraphics = new Graphics (MyWindow);
// Create a new Graphics object in MyWindow. This can contain boxes, text etc..
	    MyFrame.map ();
// Update MyFrame (several objects like MyGraphics have been added)
	    for (int c=1;c++<1000;);
// wait till everything is setup proparly
// normaly you don't have to do this because you do all the drawing in other
// threads (obbject running) and it will take long enhough to set them up
            MyGraphics.setForeground (Color.black);
//set draw color
	    MyGraphics.fillRect (40,40,10,10);
// draw black box
	    MyGraphics.drawString ("test",10,10);
//draw string
}; 

};

Just play around with this program to get a better feel about what it does.

Paul


> 
> Paul,
> 
> Sorry to bother you. I was trying to run the code you sent out
> to open a window and draw in it....I dont think Im getting the expected 
> results .
> 
> After compiling I run 'java GraphicsTest' and get a window
> and then the word "Test" show up on the command line.
> 
> When I run 'java GraphicsOutput' I get 
> 'In class GraphicsOutput: void main(String argv[]) is not defined'
> 
> As you can tell, I really have no idea what Im doing :) But, I would
> like to figure this stuff out so Im hoping you can tell me what
> what your code is supposed to do.
> 
> Much thanks.
> 
> Regards,
> Chris
> 
-
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