E
Elrod
I am writing an application that has a "print preview" function. The
preview window uses a JPanel with an extended "paint" function to draw
the various bit of information. Depending upon the page being
previewed, the panel may pass its Graphics object to the paint method
of a component in the form being previewed do draw that component
verbatim to the preview. This works fine until I wish the scale the
Graphics object before drawing the component, at which point, I
recieve the following Exception (the exception shown is actually from
my mini-test application code shown below, not from the full
application I'm developing):
java.lang.InternalError: Win32OSSD_Lock cannot nest locks
at sun.java2d.loops.ScaledBlit.Scale(Native Method)
at sun.java2d.pipe.DrawImage.scaleSurfaceData(DrawImage.java:708)
at sun.java2d.pipe.DrawImage.transformImage(DrawImage.java:172)
at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:54)
at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:736)
at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:147)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2756)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2746)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4797)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740)
at javax.swing.JComponent.paint(JComponent.java:798)
at ipos3.PreviewTest$1.paint(PreviewTest.java:38)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:557)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4787)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740)
at javax.swing.JComponent._paintImmediately(JComponent.java:4685)
at javax.swing.JComponent.paintImmediately(JComponent.java:4488)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
The result is the same on every computer I've tried, all running
Windows XP Home or Pro, and Java 1.4.2
Below is a simple application I threw together in an attempt to
isolate the problem.
import javax.swing.*;
import java.awt.*;
public class PreviewTest extends JFrame implements
java.awt.event.ActionListener{
JButton btnPreview;
JDesktopPane desktop;
JInternalFrame content;
public PreviewTest() {
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setSize(500,500);
getContentPane().add(desktop = new
JDesktopPane(),BorderLayout.CENTER);
content = new JInternalFrame("Testing");
content.setSize(400,400);
content.getContentPane().add(new JTable(
new String[][] {
{ "0,0","0,1","0,2" },
{ "1,0","1,1","1,2" },
{ "2,0","2,1","2,2" }
},
new String[] { "Col 0","Col 1","Col 2" }
));
desktop.add(content,1);
content.show();
getContentPane().add(btnPreview = new
JButton("Preview"),BorderLayout.NORTH);
btnPreview.addActionListener(this);
}
public void actionPerformed(java.awt.event.ActionEvent e) {
JInternalFrame preview = new JInternalFrame("Preview") {
public void paint(Graphics g) {
super.paint(g);
g.translate(20,20);
// The following line is what's causing the problem
// comment it out, and the preview button works
((Graphics2D)g).scale(0.5,0.5);
content.getContentPane().paint(g);
}
};
preview.setSize(350,350);
desktop.add(preview,1);
preview.show();
}
public static void main(String[] args) {
new PreviewTest().show();
}
}
preview window uses a JPanel with an extended "paint" function to draw
the various bit of information. Depending upon the page being
previewed, the panel may pass its Graphics object to the paint method
of a component in the form being previewed do draw that component
verbatim to the preview. This works fine until I wish the scale the
Graphics object before drawing the component, at which point, I
recieve the following Exception (the exception shown is actually from
my mini-test application code shown below, not from the full
application I'm developing):
java.lang.InternalError: Win32OSSD_Lock cannot nest locks
at sun.java2d.loops.ScaledBlit.Scale(Native Method)
at sun.java2d.pipe.DrawImage.scaleSurfaceData(DrawImage.java:708)
at sun.java2d.pipe.DrawImage.transformImage(DrawImage.java:172)
at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:54)
at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:736)
at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:147)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2756)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2746)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4797)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740)
at javax.swing.JComponent.paint(JComponent.java:798)
at ipos3.PreviewTest$1.paint(PreviewTest.java:38)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:557)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4787)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740)
at javax.swing.JComponent._paintImmediately(JComponent.java:4685)
at javax.swing.JComponent.paintImmediately(JComponent.java:4488)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
The result is the same on every computer I've tried, all running
Windows XP Home or Pro, and Java 1.4.2
Below is a simple application I threw together in an attempt to
isolate the problem.
import javax.swing.*;
import java.awt.*;
public class PreviewTest extends JFrame implements
java.awt.event.ActionListener{
JButton btnPreview;
JDesktopPane desktop;
JInternalFrame content;
public PreviewTest() {
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setSize(500,500);
getContentPane().add(desktop = new
JDesktopPane(),BorderLayout.CENTER);
content = new JInternalFrame("Testing");
content.setSize(400,400);
content.getContentPane().add(new JTable(
new String[][] {
{ "0,0","0,1","0,2" },
{ "1,0","1,1","1,2" },
{ "2,0","2,1","2,2" }
},
new String[] { "Col 0","Col 1","Col 2" }
));
desktop.add(content,1);
content.show();
getContentPane().add(btnPreview = new
JButton("Preview"),BorderLayout.NORTH);
btnPreview.addActionListener(this);
}
public void actionPerformed(java.awt.event.ActionEvent e) {
JInternalFrame preview = new JInternalFrame("Preview") {
public void paint(Graphics g) {
super.paint(g);
g.translate(20,20);
// The following line is what's causing the problem
// comment it out, and the preview button works
((Graphics2D)g).scale(0.5,0.5);
content.getContentPane().paint(g);
}
};
preview.setSize(350,350);
desktop.add(preview,1);
preview.show();
}
public static void main(String[] args) {
new PreviewTest().show();
}
}