-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
5.0
-
generic
-
windows_xp
It happens 80% of the time using Mozilla when the dialog is cancelled but less frequent in IE and appletviewer.
Here is the code that demonstrates the problem:
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.awt.print.*;
import javax.swing.*;
public class AWTPrintTest extends JApplet implements Printable {
private JButton jButton1 = new JButton();
public AWTPrintTest() {
}
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
jButton1.setText("PRINT");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton1_actionPerformed(e);
}
});
jButton1.setBounds(new Rectangle(165, 248, 80, 30));
this.setSize(new Dimension(400,300));
this.getContentPane().setLayout(null);
this.getContentPane().setBackground(Color.pink);
this.getContentPane().add(jButton1, BorderLayout.SOUTH);
}
public void start() {
}
public void stop() {
}
public void destroy() {
}
public String getAppletInfo() {
return "Applet inf";
}
public String[][] getParameterInfo() {
return null;
}
public void paint(Graphics g) {
super.paint(g);
g.setColor(Color.black);
g.drawString("Hello World", 20, 100);
}
public int print(Graphics g, PageFormat pf, int page) throws PrinterException {
return Printable.NO_SUCH_PAGE;
}
void jButton1_actionPerformed(ActionEvent e) {
PrinterJob printJob = null;
PageFormat pageFormat = null;
boolean bPrintFlg = true;
try{
printJob = PrinterJob.getPrinterJob();
}
catch(SecurityException se){
bPrintFlg = false;
}
if (bPrintFlg) {
printJob.pageDialog(printJob.defaultPage());
System.out.println("AWTPrintTest: getActiveWindow after pageDialog = "+KeyboardFocusManager.
getCurrentKeyboardFocusManager().getActiveWindow());
printJob.printDialog();
System.out.println("AWTPrintTest: getActiveWindow after printDialog = "+KeyboardFocusManager.
getCurrentKeyboardFocusManager().getActiveWindow());
}
}
}
=============
Here is the code that demonstrates the problem:
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.awt.print.*;
import javax.swing.*;
public class AWTPrintTest extends JApplet implements Printable {
private JButton jButton1 = new JButton();
public AWTPrintTest() {
}
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
jButton1.setText("PRINT");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton1_actionPerformed(e);
}
});
jButton1.setBounds(new Rectangle(165, 248, 80, 30));
this.setSize(new Dimension(400,300));
this.getContentPane().setLayout(null);
this.getContentPane().setBackground(Color.pink);
this.getContentPane().add(jButton1, BorderLayout.SOUTH);
}
public void start() {
}
public void stop() {
}
public void destroy() {
}
public String getAppletInfo() {
return "Applet inf";
}
public String[][] getParameterInfo() {
return null;
}
public void paint(Graphics g) {
super.paint(g);
g.setColor(Color.black);
g.drawString("Hello World", 20, 100);
}
public int print(Graphics g, PageFormat pf, int page) throws PrinterException {
return Printable.NO_SUCH_PAGE;
}
void jButton1_actionPerformed(ActionEvent e) {
PrinterJob printJob = null;
PageFormat pageFormat = null;
boolean bPrintFlg = true;
try{
printJob = PrinterJob.getPrinterJob();
}
catch(SecurityException se){
bPrintFlg = false;
}
if (bPrintFlg) {
printJob.pageDialog(printJob.defaultPage());
System.out.println("AWTPrintTest: getActiveWindow after pageDialog = "+KeyboardFocusManager.
getCurrentKeyboardFocusManager().getActiveWindow());
printJob.printDialog();
System.out.println("AWTPrintTest: getActiveWindow after printDialog = "+KeyboardFocusManager.
getCurrentKeyboardFocusManager().getActiveWindow());
}
}
}
=============
- relates to
-
JDK-4276029 Dismissing Dialog causing java plug-in console to come to the front
-
- Closed
-