Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Rectangle without Paint method!  RSS feed

 
Angela Jessi
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can I I do draw Rectangle with initialization of Graphics object and without using Paint method?
I tried following, but doesn't work...
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;

public class TabelDemo1 extends Applet
{
Graphics g;
public void init()
{
g = getGraphics();
g.draw3DRect(10,25,200,90,true);
g.draw3DRect(5,20,210,100,true);
}
}
Please let me know if I can draw without using Paint method.
Thanks in advance,
Angela
 
mick barry
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can paint outside of the paint method.
However looking at your example, I don't think you can paint in an applet init method as the graphic context has not yet neen initialized. You need to wait until the applet is started.
 
Angela Jessi
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks mick,
I tried initialized Graphics after Applet started. But it doesn't work! :rollereyes:
Please send me any example if you have,
Thanks,
Angela
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!