Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] painting a noncomponent object

Started by himifire Jan 15, 2004 at 10:32 AM 3 replies 300+ views
Original Post
himifire
himifire
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
___________ DADDY LONG LEGZ HERE! novice java programmer :-)feel free to email me or my SN for AIM is JHHIM
himifire
himifire
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
___________ DADDY LONG LEGZ HERE! novice java programmer :-)feel free to email me or my SN for AIM is JHHIM
CaptainJester
CaptainJester
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
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.