Name: jk109818 Date: 10/22/2002
FULL PRODUCT VERSION :
java version "1.4.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)
AND
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows XP [Version 5.1.2600]
also on
Microsoft Windows 98
Microsoft Windows ME
A DESCRIPTION OF THE PROBLEM :
when starting my program and clicking on the button again
and again, not only the program will crash and will not
draw any more, the os graphical environment has also a
lack of ability to draw for instance popup menus correct.
A reebot is required.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Start the programm by "java TheExample"
2. Click on the button again and again until the
Frame won't repaint any more and all circles have
become white.
EXPECTED VERSUS ACTUAL BEHAVIOR :
you should be able to click as much as you like and
the frame should paint the circles always and without
questions :o)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TheExample extends JFrame
{
MyComponent mycomp = new MyComponent();
TheExample()
{
Container c = getContentPane();
c.setLayout(new BorderLayout() );
JLabel label = new JLabel("When clicking on the button 300
ovals will be drawn at random");
JButton button = new JButton("Many colorful ovals");
c.add(label, BorderLayout.NORTH);
c.add(button, BorderLayout.SOUTH);
c.add(mycomp, BorderLayout.CENTER);
button.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
mycomp.shuffle();
}
}
);
setSize(640, 480);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main(String[] ufz)
{
TheExample example = new TheExample();
example.show();
}
}
class MyComponent extends JComponent
{
Circle circles[] = new Circle[300];
MyComponent()
{
shuffle();
}
public void shuffle()
{
for (int i=0; i<circles.length; i++)
{
int x = (int)(Math.random() * getSize().width);
int y = (int)(Math.random() * getSize().height);
int width = (int)(Math.random() * 100);
int height = (int)(Math.random() * 100);
int r = (int)(Math.random() * 256);
int g = (int)(Math.random() * 256);
int b = (int)(Math.random() * 256);
Color color = new Color(r, g, b);
circles[i] = new Circle(x, y, width, height, color);
}
this.repaint(1);
}
public void paint(Graphics g)
{
for (int i=0; i<circles.length; i++)
{
int x = circles[i].getX();
int y = circles[i].getY();
int w = circles[i].getWidth();
int h = circles[i].getHeight();
Color c = circles[i].getColor();
g.setColor(c);
g.fillOval(x, y, w, h);
}
}
private class Circle
{
private int x, y, width, height;
private Color color;
Circle(int x, int y, int width, int height, Color color)
{
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.color = color;
}
public int getX()
{
return x;
}
public int getY()
{
return y;
}
public int getWidth()
{
return width;
}
public int getHeight()
{
return height;
}
public Color getColor()
{
return color;
}
}
}
---------- END SOURCE ----------
(Review ID: 164615)
======================================================================