java – The box will not move

I'm trying to make a code that moves this box gradually but I just can not make it run:

The main class:

com.company package;
import javax.swing.JComponent;
import javax.swing. *;

main public class {

empty main public static (String[] args) {
int on = 1;
JFrame frame = new JFrame ();
frame.setSize (600,600);
frame.setTitle ("My program");
Box b = new box ();
frame.add (b);
frame.setVisible (true);
}
}

The class is called Box.java.

com.company package;
import java.awt. *;
import javax.swing. *;
import java.util.concurrent.TimeUnit;

public class Box extends JComponent {
int x = 300;
int y = 300;
width int = 100;
height int = 100;

public void paintComponent (Graphics g)
{
int on = 1;
while (en == 1) {
Color Black = new Color (0, 0, 0);
g.setColor (Black);
g.fillRect (x, y, width, height);
x ++;
and ++;
// I want it to stop for half a second here, but these next 4 lines do not work
long start1 = System.currentTimeMillis ();
try {
Thread.sleep (500);
}
capture (Exception ex) {}
}
}
}