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

JTabbedpane - painting the wrong tab

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • orion3
    • client-libs
    • None
    • b24
    • sparc
    • solaris_9

      Attached is the test code to reproduce the problem.

      While i click on repaint button it paints the second tabs contents. I think the problem is calling setVisible on b2. If not fixable atleast it should be documented.


      /*
       * JTabTest.java
       *
       * Created on November 5, 2004, 3:07 PM
       */
      import javax.swing.*;
      import javax.swing.event.*;
      import java.awt.event.*;
      import java.awt.*;
      /**
       *
       * @author vp151719
       */
      public class JTabTest {
          
          /** Creates a new instance of JTabTest */
          public JTabTest() {
          }
          
          /**
           * @param args the command line arguments
           */
          static int i = 0;
          public static void main(String[] args) {
              JFrame fr = new JFrame("JTabTest");
              //System.out.println("dfsdfs");
              final JTabbedPane tab = new JTabbedPane(){
                  public void paint(Graphics g){
                      //System.out.println("werwerwerewr " + i++);
                      super.paint(g);
                  }
              };
                 
              JButton b3 = new JButton("Repaint");
              final JButton b1 = new JButton("Hello"){
                   public void paint(Graphics g){
                      System.out.println("b1");
                      super.paint(g);
                  }
              };
              final JButton b2 = new JButton("Good"){
                   public void paint(Graphics g){
                      System.out.println("b2");
                      //Thread.dumpStack();
                      super.paint(g);
                  }
              };
              b2.setBackground(Color.BLUE);
              b3.addActionListener(new ActionListener(){
                  public void actionPerformed(ActionEvent e){
                    b1.setText("tergrfgdsg1");
                    b1.setText("tergrfgdsg2");
                    b2.setText("Morning");
                    b2.setText("Morning1");
                    b2.setText("Morning2");
                    b2.setText("Morning3");
                    b2.setText("Morning4");
                    /*tab.revalidate();
                    tab.repaint();*/
                    
                  }
              });
              
              tab.add(b1);
              tab.setSelectedIndex(0);
              tab.add(b2);
              
              b2.setVisible(true);
              fr.getContentPane().add(tab);
              fr.getContentPane().add(b3,"South");
              fr.pack();
              fr.setVisible(true);
              fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          }
          
      }

      ###@###.### 2004-11-08 05:00:22 GMT

            alexp Alexander Potochkin (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: