Rekuta 0 Newbie Poster

Hi everybody ! I am trying to use a different image using a keyboard input such as this:

private ImageIcon GameIcon = new ImageIcon("f:/School Programmation/Dungeons of Darkness.gif");
private ImageIcon GameIcon2 = new ImageIcon("f:/School Programmation/untitled.gif");

public RPG18()
{
    setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
    add(keyboardPanel);

    keyboardPanel.setFocusable(true);


   add(new JLabel(GameIcon));
   repaint();
} 

and here's the keyboardPanel

 static class KeyboardPanel extends JPanel
  {
    private int x = 100;
    private int y = 100;
    private char keyChar = 'A';

    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 would like to use the GameIcon2 picture by typing o on the keyboard but the code doesn't want to compile. I've tried the class method and the change of name , but to no avail. Please help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.