So everything in my program works, except for the mouse and the keyboard listeners. I've got a couple actionListeners working on Jbuttons that do exactly what I'm trying to do here, but the assignment says it has to work with all three. So I would like to know why it compiles, but doesn't work. Am I doing something wrong?
panel.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_UP){
shape.addSides();
}
if(e.getKeyCode() == KeyEvent.VK_DOWN){
shape.subSides();
}
}
@Override
public void keyReleased(KeyEvent e) {
}
}
);
panel.addMouseListener(new MouseListener(){
@Override
public void mouseEntered(MouseEvent e){
if(e.getButton() == MouseEvent.BUTTON1){
shape.addSides();
}
if(e.getButton() == MouseEvent.BUTTON3){
shape.subSides();
}
}
@Override
public void mouseClicked(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
}
);