Hi there,
I'm working on a project that is supposed to show a moving rectangular. I am a beginner in Java and we have just learnt about GUI. My problem is that after I run the program on Eclipse, nothing appears on screen. I'm using Macbook pro. I don't have this problem when I use windows. Therefore, it should be something related to Mac. If there's a programmer here who uses Mac instead of windows, would you please help me with this issue?
Here is my code:


import java.awt.*;
import javax.swing.*;

class PaintingFrame extends JFrame
{
public PaintingFrame()
{
super();
setSize(600, 400);
setVisible(true);
}
public void paint(Graphics g)
{
super.paint(g);
int x = 100; int y = 100;
int w = 100; int h = 100;
Color bg = this.getBackground();
Color fg = Color.RED;
while (true)
{
try {
g.setColor(fg);
g.fillRect(x, y, w, h);
Thread.sleep(20);
g.setColor(bg);
g.fillRect(x, y, w, h);
x = x + 3;
} catch (InterruptedException e)
{ }
}
}
}

public class GraphicsDemo {
public static void main(String[] args) {
PaintingFrame pf = new PaintingFrame();
}
}