[hotjoe.com] HotJoe Java Help Forums
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Visit java.com
Please send email if you are having login problems - see the posts below for more info.
Hotmail and Yahoo! users - please see the Hotmail post or the Yahoo! post for information on lost emails.
image problem in netbeans 6.1  XML
Forum Index » Java Programming
Author Message
freemefast

Newbie

Joined: 02/09/2010 14:34:35
Messages: 1
Offline

Hi all hope you can help,

Im using a jframe form and my program is a mars lander that moves left, right up and down with the keyboard arrows.

I am using a jLabel for the lander image but want to know how I can have it so that the image icon is swapped when i press an arrow. i.e. I want an image of my spaceship to display thrusters to the left and right when i press the arrow keys respectively.

Here is my code for the movement, it works just fine;


private void jPanel1KeyPressed(java.awt.event.KeyEvent evt) {
System.out.println(evt.getKeyCode());
switch (evt.getKeyCode()){
case ARROW_RIGHT:
x++;
break;
case ARROW_LEFT:
x--;
break;
case ARROW_UP:
y--;
break;
case ARROW_DOWN:
y++;
break;

}

I thought maybe using the image url after the (x--) statement would work but cant find help on the syntax. Any ideas?

Thanks in advance.
 
Forum Index » Java Programming
Go to:   
Powered by JForum 2.1.8 © JForum Team
This site built by Scott Dunbar of Xigole Systems. © 2005-2010 - Scott Dunbar
Java and the Java Get Powered logo are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.
hotjoe.com and xigole.com have no affiliation with Sun Microsystems, Inc.