Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

himifire

[java] graphics.disopse()???

This topic is 5237 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve written a draw(g) method in a non-component hand class that is called by the parent frame''s paint(g) method. Heres my problem if i call the g.dispose() at the end of the method the program wont draw the next hand(the frame calls two draw mthods one after another for two seperate objects) and if i don''t call the g.dispose() the program uses all the memerory on the system and gets an error....whats wrong with the method? the call to g.dispose is used right as far as i can tell. Heres the code. public void draw(Graphics gg) { if(handSize() == 0) return; // INIT FIELDS g =(Graphics2D) gg; int xx = x; int yy = y; card[] cards = new card[handSize()]; Image[] cardImages = new Image[handSize()]; int cardW = 0; int cardH = 0; for(int i = 0; i < handSize(); i++) { cards = getCard(i); cardImages[i] = cards[i].getImage(); } cardW = cardImages[0].getWidth(parent); cardH = cardImages[0].getHeight(parent); AffineTransform at = new AffineTransform(); // DRAW CARDS for(int i = 0; i < cards.length; i++) { if(cardImages[i] == null || cardImages[i].getWidth(parent) <= 0) { return; } at.setToTranslation((double)xx ,(double)yy); g.drawImage(cardImages[i], at, parent); xx += cardW + space; } // heres the problem g.dispose(); } DADDY LONG LEGZ HERE! novice java programmer :-)feel free to email me or my SN for AIM is JHHIM

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!