[4599] in java-interest

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

Disappearing Text

daemon@ATHENA.MIT.EDU (Michael Afergan)
Mon Jan 8 19:03:50 1996

From: mikea@ai.mit.edu (Michael Afergan)
To: java-interest@java.sun.com
Date: Mon, 08 Jan 96 17:21:32 GMT

I am slightly confused as to when the background is cleared with 
repaint().  I am trying to create a simple message scroller using the 
following code:

		g.drawString(""+mes.charAt(c++),200,200);
	     	g.copyArea(20,180,200,40,-20,0);

	Obviously there's more to it, but I would think that the above code 
would place the next letter of mes (a String) at 200,200, and move the 
rectangle defined by (20,180) and (220,220) - which contains the new character  
- back 20 units. 
	 I could then place the next character at the end, slide it back, add 
another, etc.
	Obiously there must be more to the code, but I have encountered a 
basic error that prevents any such procedure:  When I return to paint(), the 
text is no longer there.

	To test this phenomenon, I used the following code:

	public void paint(Graphics g) {
		 if (c >= 10)
			c = 0;
		 g.drawString(""+mes.charAt(c),200+5*c,200+5*c);
		}

	 public boolean mouseDown( java.awt.Event evt, int x, int y )    {
		repaint();
		}

	At first I thought this code would cause my message to be printed 
diagonally down the applet - one letter each time I clicked it.  While each 
new character was displayed, previous characters were no longer there.

	Am I missing something?  Can anyone show me an example of a simple 
text scroller?

	Thanks,
	-- Mike
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

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