Results 1 to 1 of 1
- 05-13-2010, 05:00 PM #1
Member
- Join Date
- May 2010
- Posts
- 6
- Rep Power
- 0
How to use another image using a keyboard input
I am trying to use this image:
private ImageIcon OptionsIcon = new ImageIcon("f:");
but I already have this image working:
private ImageIcon GameIcon = new ImageIcon("f:/School Programmation/Dungeons of Darkness.gif");
public RPG14()
{
setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
add(keyboardPanel);
keyboardPanel.setFocusable(true);
add(new JLabel(GameIcon));
repaint();
}
its keyboard Panel:
public KeyboardPanel()
{
addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
switch (e.getKeyCode())
{
case KeyEvent.VK_M: MainMenu = 1; break;
case KeyEvent.VK_Q: QuitGame = 1; break;
case KeyEvent.VK_C: Credits = 1; break;
case KeyEvent.VK_N: NewGame = 1; break;
case KeyEvent.VK_O: Options = 1; break;
default: keyChar = e.getKeyChar();
}
repaint();
}
I want to use the key event C and the key event O to display another image than the one provided by the GameIcon But i did not succeed into doing it. please help.
Similar Threads
-
getting each character from keyboard
By Sreejesh25 in forum Advanced JavaReplies: 6Last Post: 03-05-2010, 07:12 PM -
get keyboard input while running in the background?
By gen1mx6 in forum Advanced JavaReplies: 16Last Post: 07-16-2009, 03:51 PM -
KeyBoard Problem
By arimakidd in forum Java AppletsReplies: 3Last Post: 09-19-2008, 04:05 PM -
Basic keyboard input and edit
By BHCluster in forum New To JavaReplies: 18Last Post: 08-08-2008, 11:52 PM -
Polled keyboard input through swing
By Prometheus in forum Advanced JavaReplies: 2Last Post: 02-04-2008, 04:05 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks