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

javax.swing.JDesktopPane/getAllFrames() returns invalid value in GTK+ LAF

    XMLWordPrintable

    Details

      Description

      FULL PRODUCT VERSION :
      Java(TM) SE Runtime Environment (build 1.6.0-b105)
      Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      libgtk 2.10.6, KDE: 3.5.5

      A DESCRIPTION OF THE PROBLEM :
      Documentation [1] for JDesktopPane states that getAllFrames "Returns iconified frames as well as expanded frames.". However, in GTK+ look and feel it returns only expanded frames.

      [1] http://java.sun.com/javase/6/docs/api/javax/swing/JDesktopPane.html#getAllFrames()

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the attached test case. It should throw assertion error.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      getAllFrames should always return all iconified and all expanded frames.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;
      public class Test extends JFrame {
      JDesktopPane desktop;

      Test() {
      super("Test JDesktop");
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      setSize(800, 600);

      // create desktop and frames
      desktop = new JDesktopPane();
      add(desktop);
      JInternalFrame frame1 = createFrame("1");
      desktop.add(frame1);
      JInternalFrame frame2 = createFrame("2");
      desktop.add(frame2);

      // minimize frames
      makeIcon(frame1);
      //makeIcon(frame2);

      // test Metal
      testLAF("javax.swing.plaf.metal.MetalLookAndFeel");
      // test GTK+
      testLAF("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");

      setVisible(true);
      }

      void testLAF(String clazz) {
      System.err.println(clazz);
      try {
      UIManager.setLookAndFeel(clazz);
      SwingUtilities.updateComponentTreeUI(this);
      int numFrames = desktop.getAllFrames().length;
      if (numFrames != 2)
      throw new AssertionError("desktop.getAllFrames().length != 2 (" + numFrames + ") in " + clazz);
      }
      catch (Exception e) {
      e.printStackTrace();
      }
      }

      JInternalFrame createFrame(String title) {
      JInternalFrame f = new JInternalFrame(title);
      f.setSize(100, 100);
      f.setVisible(true);

      return f;
      }

      void makeIcon(JInternalFrame f) {
      try {
      f.setIcon(true);
      }
      catch (java.beans.PropertyVetoException e) {
      e.printStackTrace();
      }
      }

      public static void main(String[] args) {
      new Test();
      }

      }
      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            keshah Ketan Shah (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Imported:
              Indexed: