-
Bug
-
Resolution: Fixed
-
P4
-
1.3.0
-
beta
-
x86
-
windows_nt
Name: boT120536 Date: 11/09/2000
faun:~>java -version
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)
If the VM is running and ctrl-alt-delete happens (perhaps screensaver
also), the entire video context is affected. Once the desktop is restored,
drawstring seems to take much longer to generate results. This could be a
duplicate of Bug Id 4282147.
This application demonstrates the effect:
-------------------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* Usage: execute java Gui, and click on the Repaint Canvas button many times
* Once a sufficient sample is achieved, press the Reset Counter button
* and hit CTRL-ALT-DELETE and the CANCEL on your Windows NT machine.
* Repeat the sequence of Repaint Canvas presses and observe that the new
* average is higher than the old one (stored in the 'Reset' button)
**/
public class Gui extends JFrame {
MyCanvas canvas;
JButton resetButton;
/** Build the GUI */
public Gui ()
{
super( "Test GUI" );
canvas = new MyCanvas();
JButton repaintButton = new JButton("Repaint Canvas");
repaintButton.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent evt )
{
canvas.repaint();
}
});
resetButton = new JButton("Reset counter");
resetButton.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent evt )
{
resetButton.setText("Previous Avg = " + canvas.getAvg() );
canvas.resetAvg();
}
});
getContentPane().add( "North", resetButton );
getContentPane().add( "Center", canvas );
getContentPane().add( "South", repaintButton );
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public static void main( String[] args )
{
Gui gui = new Gui();
gui.pack();
gui.setVisible(true);
}
private class MyCanvas extends Canvas
{
int reps;
long sum;
public MyCanvas()
{
setSize( 200, 100 );
resetAvg();
}
public int getAvg()
{
if (reps == 0)
return 0;
else
return (int)(sum / reps);
}
public void resetAvg()
{
reps = 0;
sum = 0;
}
public void paint( Graphics g )
{
long time = System.currentTimeMillis();
Dimension d = getSize();
Color c = g.getColor();
g.setColor( new Color(128,0,128,128) );
g.fillOval(0,0,d.width, d.height);
g.drawString("Hello world", d.width/2, d.height/2);
g.setColor(c);
System.out.print("Paint took " + (System.currentTimeMillis()-time) + " ms");
sum += System.currentTimeMillis() - time;
reps++;
System.out.println(",\t Average = " + getAvg() + " ms");
}
}
}
(Review ID: 111929)
======================================================================