My main problem; i can get the paint method to work. i've used it with my teacher in my programming class but there we use school computers with the stuff pre-made by our teach. I've recently downloaded JCreator Pro and ive managed a few basic things like a calculator and a madlibs for fun :D. i even made a guess the number game on my own!!
So now i feel like i need to use the paint method a bit, so maybe i can chamge the text or use text file pictures, etc. the problem is at school its always been premade, out teacher never taught us how to make the paint method, i feel like im stuck on square one :(.
My freind gave me a code that doesnt quite work;
System.setProperty("info.gridworld.gui.watermark", "hide");
//Double Buffer -- fast graphics
// Faster graphics with page swap
Image myScreen;
public void paint(Graphics pen)
{
myScreen =createImage(getSize().width,getSize().height);
Graphics screen = myScreen.getGraphics();
doubleBuffer(screen);
pen.drawImage(myScreen,0,0,null);
}
}
public void doubleBuffer(Graphics pen) // for fast graphics
{
//Draw all graphics (screen) here
}
note, i reverted the code to its origional form because i think you people might have a better time interpretting what my frind mean by all this. @.@ i am a newbie...
Paint Method
Started by
nujumkey
, Feb 22 2012 02:24 AM
1 reply to this topic
#1
Posted 22 February 2012 - 02:24 AM
#2
Posted 22 February 2012 - 10:48 AM
What your friend gave you is code for double buffered drawing.
You can find more info on it here: http://docs.oracle.c...doublebuf.html.
For a drawing tutorial go here: http://docs.oracle.c.../2d/index.html.
You should also ask yourself if you really need to draw things yourself.
If it's just for images, showing text, menu's, etc you're better off just using Swing: http://docs.oracle.c...orial/uiswing/.
You can find more info on it here: http://docs.oracle.c...doublebuf.html.
For a drawing tutorial go here: http://docs.oracle.c.../2d/index.html.
You should also ask yourself if you really need to draw things yourself.
If it's just for images, showing text, menu's, etc you're better off just using Swing: http://docs.oracle.c...orial/uiswing/.











