-
Bug
-
Resolution: Fixed
-
P3
-
1.3.0
-
beta
-
x86
-
windows_2000
Name: rmT116609 Date: 03/26/2001
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
#
# HotSpot Virtual Machine Error, EXCEPTION_ACCESS_VIOLATION
# Please report this error at
# http://java.sun.com/cgi-bin/bugreport.cgi
#
# Error ID: 4F533F57494E13120E43505002D4
#
The above error occurs when a component overrides method
getCursor() and returns null.
Please the run program below and run the mouse over the
blue rectangle. This should cause HotSpot to crash.
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class CursorBug extends JLayeredPane {
public static final int WEEK_DAY_WIDTH = 100;
public static final int WEEK_END_WIDTH = 70;
public static final int ROW_HEIGHT = 30;
public CursorBug() {
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
// Set our background to white
g.setColor(Color.white);
g.fillRect(0, 0, getMaximumWidth(), getMaximumHeight());
paintDisarmed(g);
}
private void paintDisarmed(Graphics g) {
// Paint the vertical divides between each day
int h = getMaximumHeight();
int x = 0;
// Grey line
g.setColor(Color.gray);
for(int i = 0; i < 5; i++) {
x += WEEK_DAY_WIDTH;
g.drawLine(x, 0, x, h-1);
}
x += WEEK_END_WIDTH;
g.drawLine(x, 0, x, h-1);
}
public Dimension getMinimumSize() {
return new Dimension(WEEK_DAY_WIDTH, ROW_HEIGHT);
}
public Dimension getPreferredSize() {
return new Dimension(getMaximumWidth(), ROW_HEIGHT * 15);
}
public Dimension getMaximumSize() {
return new Dimension(getMaximumWidth(), getMaximumHeight());
}
public int getMaximumWidth() {
return (WEEK_DAY_WIDTH * 5) + (WEEK_END_WIDTH * 2);
}
public int getMaximumHeight() {
return ROW_HEIGHT * 24;
}
/**
* Test
*/
public static void main(String[] args) {
try {
UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
} catch (Exception e) {
System.err.println("Couldn't use the system-platform look and feel: "+ e);
}
JFrame f = new JFrame("Cursor Bug");
JPanel p = new JPanel(new BorderLayout());
CursorBug ws = new CursorBug();
// Add a Ribbon
Ribbon r = new Ribbon();
ws.add(r);
r.setBounds(50, 50, 75, 75);
JScrollPane jsp = new JScrollPane(ws,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
p.add(jsp, BorderLayout.CENTER);
f.getContentPane().add(p);
f.pack();
f.show();
}
}
class Ribbon extends JPanel {
public Ribbon() {
}
/**** THIS IS THE BUG !!!! ****/
public Cursor getCursor() {
return null;
}
/*****************************/
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.blue);
Dimension d = getSize();
g.fillRect(0, 0, d.width, d.height);
}
}
/* eof */
(Review ID: 119262)
======================================================================