Archived

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

himifire

[java] painting a noncomponent object

Recommended Posts

himifire    122
I created a class and a method called update to try and paint it. The update method is running(determined by println) but nothing is painting on the parent applet. parent is set in the constr as "this" in the applet. The images have loaded totally ive checked n double check that. thx in advance! heres the code: public void update() { if(parent == null) {return;} Graphics gg = parent.getGraphics(); Graphics2D 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(); for(int i = 0; i < cards.length; i++) { //at.setToTranslation((double)xx ,(double)yy); //drawImage(cardImages[i], at, parent); System.out.println("DRAWN"); xx += cardW + space; } } 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
himifire    122
oppz i guess i shuldnta named it update(). the class doesn''t extend Component or anything that does so there is nothing assosciated with update() besides my own code.

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
CaptainJester    523
Are you calling your update method from anywhere? The JVM will not call because it is not part of the painting hierarchy, so you have to call it yourself.



First make it work, then make it fast. --Brian Kernighan

The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities. We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)

Do not interrupt your enemy when he is making a mistake. - Napolean Bonaparte

Share this post


Link to post
Share on other sites