[2723] in java-interest

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

drawing a line in a graphics window

daemon@ATHENA.MIT.EDU (Sharma V R Madiraju)
Wed Oct 11 22:14:42 1995

From: Sharma V R Madiraju <sharma@lochard.com.au>
To: java-interest@java.sun.com
Date: Thu, 12 Oct 1995 10:42:35 +1000 (EST)


This may be a stupid question for java 'gurus' but this is a real 
problem for me.

I am trying to draw a line and grab events  in a graphics window 
(GWindow) which is derived from Window class. This window is 
initialised in Ex  class constructor and this (Ex) is derived from
a frame class.  I could see stdout messages (event handling) when 
I move the mouse in the window. I could see paint() is called but 
the line is not appearing in the window. 



The code is like this

======



import awt.*;
import java.lang.*;
import java.io.*;
import java.util.*;


public class Ex extends Frame {

static WServer  server = null;


    public static int windowWidth  = 300;
    public static int windowHeight = 300;
    GWindow 		gwindow;
	
  
  public Ex(WServer serv, String args[]) {
  
   super(serv,false,null,windowWidth,windowHeight,Color.lightGray); 
   setInsets(4,0,4,0);
   serv.sync();
   String  str =  new String("abc"); 
   gwindow = new GWindow (this,str,300,300); 
   map(); 


   }


   public static void main( String args[]) {

   server = new WServer();
   server.start(); 
   Ex mp = new Ex(server,args);
  }


}



class GWindow extends  Window{

   Event tEvent = new Event();
   Graphics gwgraphics;
 
   public GWindow (Frame fr, String str, int ht, int wt ) {

    super(fr, str, Color.white, 300,300);

    super.handleExpose(0,0,300,300);	
    enablePointerMotionEvents();
    setMargin(2);
    setLayout(null);
}


 public void mouseMoved(Event e)
{

     System.out.println("Moise Moved points" +  e.x +" " + e.y);
}

 public void mouseDrag(Event e) {
     System.out.println("Mouse Drag points" +  e.x +" " + e.y);

			 }
public void mouseUp(Event e) {
     System.out.println("Mouse Up" +  e.x +" " + e.y);
			}
public void mouseDown(Event e) {
     System.out.println("mouse Down" +  e.x +" " + e.y);
	}

public void mouseExit(Event e) {
     System.out.println("mouse exit");
			}
public void mouseEnter(Event e) {
     System.out.println("mouse enter");
			}
public void expose(int x, int y, int w, int h) {
    paint();
    }
public void paint(){
	System.out.println("drawing line");
	drawLine (10,10,200,100);

}

}

======


Can you please tell me what the problem is.

I am also looking for ftp sites for java application examples
similar to above (graphics, etc). 

Thanks very much
Sharma Madiraju
-- 
sharma@lochard.com.au		  Lochard Environment Systems		
http://www.cs.mu.oz.au/~madiraju  875 Glenhuntly Road			   
Tel (613) 524 3908		  Caulfield South, VIC 3162	
Fax (613) 532 8209	          Australia				 
-
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