So I am making this java applet and I just want to first make sure the key input works correctly before making it more complex. I have no idea why, but when you remove the "System.out.print(needUpdating);" it does not correctly moves the rectangle according to the key input. Could anyone tell me why and how to fix it? This is a total mystery to me.
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JApplet;
public class firstApplet …Run Code Online (Sandbox Code Playgroud)