[java] graphics.disopse()???
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 = cards.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 == null || cardImages.getWidth(parent) <= 0)
{
return;
}
at.setToTranslation((double)xx ,(double)yy);
g.drawImage(cardImages, at, parent);
xx += cardW + space;
}
// heres the problem
g.dispose();
}
</i>
DADDY LONG LEGZ HERE! novice java programmer :-)feel free to email me or my SN for AIM is JHHIM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement