Image backi;
Graphics backg;
backi = createImage(width, height);
backg = backi.getGraphics();
Now do all your drawing on backg, just as you would on the normal graphics object. When you want to swap images, simply call:
g.drawImage(backi, 0, 0, this);
Note that "g" here is the normal graphics object you get from some method like update(Graphics g).
]]>actually thats an EXTREMELY irritating occurance that annoys the heck out of me with java applets. Whenever you tell the screen to refresh it flickers. If it refreshes everytime you move the mouse, its just.. a nightmare.
Double buffering will eliminate the flicker.
]]>actually thats an EXTREMELY irritating occurance that annoys the heck out of me with java applets. Whenever you tell the screen to refresh it flickers. If it refreshes everytime you move the mouse, its just.. a nightmare.
I'm not sure if it does that with jframes though..
]]>Move (k-1)/(n-2) to each of the n-2 pegs, leaving the first with only the bottom disk and the last peg empty. Note there may be additional ones left over because of integer division. This will cost f((k-1)/(n-2)), the same f as before. Now move the big disk over, and stack all the others on top, each costing f((k-1)/(n-2)). The total cost is:
2*(n-2)*f((k-1)/(n-2)) + 1
Is this the fastest way?
]]>My point remains for the different sized discs though ^^
]]>Can't we just ignore all but three?
Certainly. But what's the fastest way to do it?
Here's an easier question: TOH with 4 pegs, using my exact logic from before, come up with a faster way to do it than with 3 pegs.
]]>It changes the problem dramatically and makes analysis of the run time much more complicated.
it does? Can't we just ignore all but three? There's no rule about not being able to move a disk more than one post away.
]]>Adding more posts is completely redundant.
Not entirely. It changes the problem dramatically and makes analysis of the run time much more complicated.
]]>--------------------------------------------------------------------------------------------------------------
Genius Is Noticed! But Refused Acceptance! By Persons With Academic liabilities! .....................
hmmm... okay, I wouldn't mind seeing another now.
]]>