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

Unable to iconify 2 frames at the same time

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 6u2
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      OPERATING SYSTEM(S):
      Windows XP Professional SP2

      FULL JDK VERSION(S):
      java version "1.6.0_02"
      Java(TM) SE Runtime Environment (build 1.6.0_02-b06)
      Java HotSpot(TM) Client VM (build 1.6.0_02-b06, mixed mode)

      STEPS TO REPRODUCE:

      1. Install SUN JDK 1.6.0_02-b06
      2. Compile the program mentioned below with the above mentioned build.
      3. Now run the program .
      4. Now click on "Z-Order" and select "Z-Order Test".
      5. Select radio button "Frame 1" and click on "Show Window" (It will
         pop up "Frame 1" windows.)
      6. Select radio button "Frame 2" and click on "Show Window" (It will
         pop up "Frame 2" windows.)
      7. Select radio button "Frame 2" ,select "iconified" and click on "Set
         State".("Frame 2" will be iconified.)
      8. Now,select radio button "Frame 1" ,select "iconified" and click on
         "Set State".

      Observed result:
      "Frame 1" is getting iconified as expected but "Frame 2" is getting focus.

      Expected result:
      "Frame 2" should not get focused.


      TESTCASE SOURCE:

      import java.awt.*;
      import java.awt.event.*;
      import java.awt.geom.Dimension2D;
      import javax.swing.*;

      public class focus1 {

          JFrame frame;
      public static JDesktopPane desktop;
          public static InternalFrameFocusTest_a mif;
      static JPopupMenu popup;

      public focus1() {
      frame = new JFrame("Internal Frame Test");
      desktop = new JDesktopPane();
      mif = new InternalFrameFocusTest_a();

      int inset = 50;
      Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
      frame.setBounds(inset, inset, screenSize.width - inset * 2,
      screenSize.height - inset * 2);

      frame.setContentPane(desktop);
      desktop.add(mif);
      frame.setExtendedState(frame.MAXIMIZED_BOTH);
      frame.setVisible(true);
      }
              public static void main(String[] args) {
      new focus1();
      }
      }

      class InternalFrameFocusTest_a extends JInternalFrame
       {
         Container c;
         JMenuBar menuBar;
         JMenu zMenu;
         public static JPopupMenu popup;
         JMenuItem zSwingMenuItem,menuItem;
            
         public InternalFrameFocusTest_a() {
      super("Internal Frame Test", true, // resizable
      true, // closable
      true, // maximizable
      true);// iconifiable

      c = this.getContentPane();

      menuBar = new JMenuBar();
      this.setJMenuBar(menuBar);
      menuBar.setFocusable(false);
      zMenu = new JMenu("Z-Order");
      zMenu.setMnemonic(KeyEvent.VK_Z);
      zMenu.setName("Z-Order");
      menuBar.add(zMenu);

      zSwingMenuItem = new JMenuItem("ZTest", KeyEvent.VK_S);
      zSwingMenuItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ae) {
      JInternalFrame frame = new JInternalFrame("Z-Order Test",
      false, true, false, true);
      frame.getContentPane().add(new InternalZTest());
      focus1.desktop.add(frame);
      frame.setSize(200, 500);
      frame.toFront();
      frame.setVisible(true);
      }
      });
      zMenu.add(zSwingMenuItem);

      // Create the popup menu.
      popup = new JPopupMenu();
      menuItem = new JMenuItem("Native L&F");
      menuItem.setMnemonic(KeyEvent.VK_N);
      menuItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ae) {
      try {
      UIManager.setLookAndFeel(UIManager
      .getSystemLookAndFeelClassName());
      } catch (Exception e) {
      e.printStackTrace(System.out);
      }
      SwingUtilities.updateComponentTreeUI(focus1.mif);
      focus1.mif.pack();
      }
      });

      popup.add(menuItem);
      this.pack();
      this.setVisible(true);
             }
       }

       class InternalZTest extends JPanel {
      JInternalFrame frame1,frame2;
      JButton showButton,setStateButton;
      JRadioButton rButton1,rButton2,iconifiedOption,normalOption;
      JPanel P1, P2, P3;
      boolean f1, f2, f3; // which rButton has been pressed
      public InternalZTest() {
      frame1 = new JInternalFrame("Internal frame1");
      frame2 = new JInternalFrame("Internal frame2");
      frame1.setSize(150, 200);
      frame2.setSize(150, 200);
      rButton1 = new JRadioButton("Frame1");
      rButton2 = new JRadioButton("Frame2");
      setupControl();
      }
      public void setupControl() {
      rButton1.setMnemonic(KeyEvent.VK_1);
      rButton1.addItemListener(new ItemListener() {
      public void itemStateChanged(ItemEvent ie) {
      f1 = true;
      f2 = false;
      f3 = false;
      }
      });
      rButton2.setMnemonic(KeyEvent.VK_2);
      rButton2.addItemListener(new ItemListener() {
      public void itemStateChanged(ItemEvent ie) {
      f2 = true;
      f1 = false;
      f3 = false;
      }
      });

      ButtonGroup bGroup = new ButtonGroup();
      bGroup.add(rButton1);
      bGroup.add(rButton2);

      showButton = new JButton("Show window");
      showButton.setMnemonic(KeyEvent.VK_S);
      showButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ae) {
      if (f1) {
      frame1.show();
      }
      if (f2) {
      frame2.show();
      }
      }
      });

      iconifiedOption = new JRadioButton("Iconified");
      iconifiedOption.setMnemonic(KeyEvent.VK_I);

      normalOption = new JRadioButton("Normal");
      normalOption.setMnemonic(KeyEvent.VK_N);

      ButtonGroup setStateGroup = new ButtonGroup();
      setStateGroup.add(iconifiedOption);
      setStateGroup.add(normalOption);

      setStateButton = new JButton("Set State");
      setStateButton.setMnemonic(KeyEvent.VK_S);
      setStateButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ae) {
      try {
      if (f1 && iconifiedOption.isSelected()) {
      frame1.setIcon(true);
      } else {
      frame1.setIcon(false);
      }
      if (f2 && iconifiedOption.isSelected()) {
      frame2.setIcon(true);
      } else {
      frame2.setIcon(false);
      }
      }catch (Exception e) {
      e.printStackTrace(System.err);
      }
      }
      });
      P1 = new JPanel();
      P2 = new JPanel();
      P3 = new JPanel();
      this.setLayout(new BorderLayout());
      this.setSize(200,500);
      P1.setLayout(new GridLayout(8,0));
      P1.setBorder(BorderFactory.createCompoundBorder(BorderFactory
      .createTitledBorder("Frames"), BorderFactory
      .createEmptyBorder(5, 5, 5, 5)));
      P2.setLayout(new GridLayout(3,0));
      P2.setBorder(BorderFactory.createCompoundBorder(BorderFactory
      .createTitledBorder("Frame's State"), BorderFactory
      .createEmptyBorder(5, 5, 5, 5)));
      P1.add(rButton1);
      P1.add(rButton2);
      P1.add(showButton);
      P2.add(normalOption);
      P2.add(iconifiedOption);
      P2.add(setStateButton);
      this.add(P1, BorderLayout.NORTH);
      this.add(P2, BorderLayout.CENTER);
      this.add(P3, BorderLayout.SOUTH);

      focus1.desktop.add(frame1);
      focus1.desktop.add(frame2);
      }
      }

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            elarsen Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: