I can't figure out what's wrong - I was remaking the code from an older and messier version, but now I've hit a roadblock because what I say in the actionPerformed section just doesn't happen.
I suspect that it's because of the Timer, which a friend adviced me to link to an empty method (NullListener). But even when I move around using the keyListener, nothing happens! Why?
(Please remember that the things currently in the actionPerformed section are only there so I can see if it works at all, so the problem can't be within the method itself.)
import java.awt.event.*;
import javax.swing.*;
public class gameinit implements ActionListener
{
public static int number;
public static JFrame p;
public static Timer t;
public static JLabel Iz;
public static char rar = 'T';
public static void main(String args[])
{
p = new JFrame("Version 2.4");
p.setSize(600,393);
NullListener Blanky = new NullListener();
t = new Timer(50, Blanky);
t.start();
Maps.map0();
p.setVisible(true);
p.addKeyListener(new KeyListen());
}
public void actionPerformed(ActionEvent e)
{
Izzy.hittable();
Izzy.movement();
if(rar == 'T')
{
System.out.print("Sky High(Grand Nuave)");
}
}
static class KeyListen implements KeyListener
{
KeyListen(){}
public void keyPressed(KeyEvent e)
{
if(e.getKeyCode() == 39)
{
number = 1;
Controls.test(number);
}
if(e.getKeyCode() == 37)
{
number = 2;
Controls.test(number);
}
if(e.getKeyCode() == 32)
{
number = 3;
Controls.test(number);
}
}
public void keyReleased(KeyEvent e)
{
if(e.getKeyCode() == 39 || e.getKeyCode() == 37)
{
char direction = Controls.test(number), dir;
Izzy.stop(direction);
}
}
public void keyTyped(KeyEvent e)
{}
}
}