• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Rectangle without Paint method!

 
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
 
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
 
This guy is skipping without a rope. At least, that's what this tiny ad said:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic