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

JTabbedPane shows blank panel (panel does have data!)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 1.2.2
    • Fix Version/s: None
    • Component/s: client-libs

      Description



      Name: skT45625 Date: 03/31/2000


      Classic VM (build JDK-1.2.2-001, native threads, symcjit)

      Attached is a trivial Java Application which reproduces my problem. The code
      works correctly with Swing 1.0.3. It
      does not work correctly with Swing 1.1.1, or in JDK 1.2.2. (At first we
      were trying to convert to Swing 1.1.1, but now we have decided
      to convert to JDK 1.2.2, so are no longer interested in Swing 1.1.1).

      In my real app, I have a JTabbedPane with one
      or more tabs displaying info about an object. When the user selects a
      different object, I show new information
      in the JTabbedPane -- sometimes in the same tab panels as for the
      previous object (but with new info in each
      panel!), and sometimes with a somewhat different set of tab panels.
      The application does a removeAll() old panels
      and then adds back the panels needed for the newly selected object.
      It works correctly in JDK 1.1.8 + Swing 1.0.3.

      Swing 1.1.1/JDK 1.2.2 problem: Blank panels displayed.

      The trivial app simply keeps adding back
      the same 3 panels, with new data in each panel. Obviously, each set of
      panels has a top-most panel which shows when the new set of panels gets
      displayed. The first time, the top panel
      displays correctly. When you click to bring up
      the second set of panels, the top panel is *blank*. If you select a
      different panel in the group and then reselect
      the originally top-most panel, it shows correctly.
      If, when a given set of
      panels is showing, you select one
      of the lower-priority panels, and then
      click to bring up a new set of panels, the
      top panel of the new set displays correctly,
      but if you then go on to another set of panels, the top panel displays
      blank in the subsequent sets of panels.

      A fix or workaround will be appreciated.
      This is our prime production system application.
      It looks like a Swing 1.1.1 bug to me.

      Trivial program to recreate bug follows:


      /*
      Trivial application that tests JTabbedPane - 3/00 BMcC SMARTS
      ###@###.### 914.948.6200 ext 7250

      Do a full compile when changing Swingall.jar files
      between 1.0l.3 and 1.1.1 (remove old object code before compile)
      */

      import java.awt.*;
      import java.awt.event.ActionListener;
      import java.awt.event.ActionEvent;
      import java.awt.event.MouseEvent;
      import java.awt.BorderLayout;

      // Comment out following import stmts to test with Swing 1.0.3

      import javax.swing.event.TreeSelectionEvent;
      import javax.swing.event.TreeSelectionListener;
      import javax.swing.JTabbedPane;
      import javax.swing.JFrame;
      import javax.swing.JPanel;
      import javax.swing.*;
      import javax.swing.tree.DefaultMutableTreeNode;
      import javax.swing.tree.DefaultTreeModel;
      import javax.swing.tree.MutableTreeNode;

      import javax.swing.UIManager;

      // Comment out following import stmts to test with Swing 1.1.1
      /*
      import com.sun.java.swing.event.TreeSelectionEvent;
      import com.sun.java.swing.event.TreeSelectionListener;
      import com.sun.java.swing.JTabbedPane;
      import com.sun.java.swing.JFrame;
      import com.sun.java.swing.JLabel;
      import com.sun.java.swing.*;
      import com.sun.java.swing.tree.DefaultMutableTreeNode;
      import com.sun.java.swing.tree.DefaultTreeModel;
      import com.sun.java.swing.tree.MutableTreeNode;
      */

      import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;



      public class TrivialApplication extends JFrame {

          public JLabel j1,j2,j3;
          public int status;
          JTabbedPane tp = null;

      public static void main(String args[]) {
      TrivialApplication ta = new TrivialApplication();
      ta.init();
      ta.setVisible(true);
      }

      public TrivialApplication() {
      super("JTabbedPane test v1.1");
      //setBounds(100,50,300,450);
      }

      public void init() {

      try {
      WindowsLookAndFeel m = new WindowsLookAndFeel();
      UIManager.setLookAndFeel(m);
      } catch (Exception e) {
      System.out.println("Set Look and feel error: " + e +
      " / " + UIManager.getLookAndFeel());
      }


      JButton b = new JButton("Exit Application");
      b.addActionListener (new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      System.exit(0);
      }

      } );


      // Clicking this button will cause next set of data to
      // show in tabbed panels

      JButton du = new JButton("Click here to Set New Panel Data");
      du.addActionListener (new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      //tp.setSelectedIndex(-1);
      //tp.removeAll(); // remove all panels
      //int ix = 2;
      //for (;ix >= 0; --ix) {
      // tp.removeTabAt(0);
      //}

      //tp.addTab("t1", j1);
      //tp.removeAll();

      if (status == 1) {
      status = 2;
      j1.setText("text1-1");
      j2.setText("text1-2");
      j3.setText("text1-3");
      } else if (status == 2) {
      status = 3;
      j1.setText("text2-1");
      j2.setText("text2-2");
      j3.setText("text2-3");
      } else if (status == 3) {
      status = 1;
      j1.setText("text3-1");
      j2.setText("text3-2");
      j3.setText("text3-3");
      }

      tp.removeAll();
      tp.addTab("t1", j1);
      tp.removeTabAt(0);

      // add same panels, but with new data (in reality,
      // mostly the same panels would be added, but
      // sometimes a different panel would be added or
      // one of the panels previously showing would not be added)
      tp.addTab("t1", j1);
      tp.addTab("t2", j2);
      tp.addTab("t3", j3);
      //tp.setSelectedIndex(-1);
      }
      } );

      JPanel jfa = new JPanel();
      jfa.add(du);
      jfa.add(b);

      tp = new JTabbedPane(SwingConstants.TOP);
      tp.setBorder(BorderFactory.createLoweredBevelBorder());

      //getContentPane().add(du, BorderLayout.NORTH);
      getContentPane().add(jfa, BorderLayout.NORTH);
      getContentPane().add(tp, BorderLayout.CENTER);
      //getContentPane().add(jfa, BorderLayout.CENTER);
      //getContentPane().add(b, BorderLayout.SOUTH);

      pack();
      setBounds(100,50,400,450);

      j1 = new JLabel("Tab 1");
      j2 = new JLabel("Tab 2");
      j3 = new JLabel("Tab 3");
      tp.addTab("t1", j1);
      tp.addTab("t2", j2);
      tp.addTab("t3", j3);
      status = 1;
      //tp.setSelectedIndex(-1);
      }

      }
      (Review ID: 103136)
      ======================================================================
      This reproducable in kestrel-rc2 also.

      suresh.kondamareddy@eng 2000-03-31

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                amfowler Anne Fowler (Inactive)
                Reporter:
                skondamasunw Suresh Kondamareddy (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: