whats wrong with this error?
[COLOR="Red"]Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Arrays.java:2760) at java.util.Arrays.copyOf(Arrays.java:2734) at java.util.ArrayList.ensureCapacity(ArrayList.java:167) at java.util.ArrayList.add(ArrayList.java:351) at java.awt.Container.addImpl(Container.java:1054) at java.awt.Container.add(Container.java:365) at xTestx.NewMain.main(NewMain.java:69)[/COLOR]
this is the code
package xTestx; import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.Color; import java.awt.Graphics; import java.awt.Container; /** * * @author */ public class NewMain { public static void main(String[] args) { JFrame window; Container container; window = new JFrame(); window.setSize(400, 400); window.setLocation(200, 300); window.setVisible(true); while (true) { JPanel panel = new JPanel() { Color color; @Override public void paintComponent(Graphics g) { super.paintComponent(g); int x = (int) (Math.floor(Math.random() * 3) + 1); switch (x) { case 1: color = Color.BLACK; break; case 2: color = Color.BLUE; break; case 3: color = Color.GREEN; break; default: color = Color.PINK; break; } g.setColor(color); g.fillRect(50, 50, 50, 50); } }; container = window.getContentPane(); container.add(panel); } } }
i just to make a simple program that demonstrates a shape that continuesly change color while running..