Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4833956

Parent JFrame is not active after closing child dialog

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.3.1_06
    • Fix Version/s: None
    • Component/s: client-libs
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_2000

      Description

      OS: Windows2000 SP3
      J2SE version: 1.3.1_06

      Parent JFrame is not active after closing child dialog.
      Parent JFrame should be active after closing child dialog.
      We observed this problem with Windows2000, and the behavior seems
      fine with RedHat Linux.

      Procedure to reproduce the problem:
      1) Click [Print] button on JFrame
      2) JDialog comes up and click [Cancel] button
      3) JFrame is not active and other(like DOS Prompt) is active.

      Behavior of Windows and RedHat Linux is different and behavior of
      RedHat Linux seems correct.

      Sample code:
      ===================================================================
      import java.awt.*;
      import java.awt.print.*;
      import javax.swing.*;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;

      public class PrinterDialogTest extends JFrame implements Printable{

              private JPanel panel = null;

              public static void main(String[] arg){
                      new PrinterDialogTest();
              }

              PrinterDialogTest(){
                      super("Main Frame");
                      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                      initialize();
              }

              private void initialize(){
                      panel = new JPanel();
                      panel.setLayout(new BorderLayout());
                      JButton button = new JButton();
                      button.setText("print");
                      button.addActionListener(
                              new ActionListener(){
                                      public void actionPerformed(ActionEvent e){
                                              button_actionPerformed(e);
                                      }
                              }
                      );
                      panel.add(button);
                      getContentPane().add(panel);
                      pack();
                      setVisible(true);
              }

              public void button_actionPerformed(ActionEvent e){
                      PrinterJob printerJob = PrinterJob.getPrinterJob();
                      if (printerJob.printDialog()) {
                              // cPanel:\225`\211\346\203R\203\223\203|\201[\203l\203\223\203g
                              printerJob.setPrintable(this);
                              try {
                                      printerJob.print();
                              }catch (PrinterException pe){
                                      pe.printStackTrace();
                              }
                      }
              }
              public int print(Graphics g, PageFormat pf, int index){
                      return Printable.PAGE_EXISTS;
              }

      }

      ===================================================================


        Attachments

          Activity

            People

            • Assignee:
              son Oleg Sukhodolsky (Inactive)
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: