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

[macosx] Intermittently only some components refresh

XMLWordPrintable

      FULL PRODUCT VERSION :
      JDK 8 build 88

      ADDITIONAL OS VERSION INFORMATION :
      MacOS 10.8.3

      A DESCRIPTION OF THE PROBLEM :
      This is intended to mimic in a small applet the component display problems illustrated at http://segal.org/java/refresh3/. The basic problem is that intermittently some components don't refresh.

      REGRESSION. Last worked in version 6u45

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Example 1:
      1. Load the applet at http://segal.org/java/refresh4/, with full source code given below.
      2. Click the Refresh button in the applet several times.

      Example 2:
      1. Load the applet at http://segal.org/java/refresh5/, with full source code given below.
      2. Click the " Change panel once " button in the applet several times.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      All components should update in all refreshes in both examples.
      ACTUAL -
      In each of the two examples, intermittently some components don't update, similar to the behavior seen in a large applet as shown at http://www/segal.org/refresh3/.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      None.

      It should be noted that Example 2 was subject of a previous sun bug report, determined years ago to be attributable to the following bugs in Java for Windows fixed long ago:
      http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5065001
      http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6229122

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Source code for Example 1:
      import java.applet.*;
      import java.awt.*;
      import java.awt.event.*;

      public class CanvasTable3 extends Applet implements ActionListener {

      Button b;
      Panel labelPanel;
      int labels;
      int count;
      Font f;

      public void init()
      {
      f = new Font( " SansSerif " , Font.BOLD, 15);
      b = new Button( " Refresh " );
      add(b);
      b.addActionListener(this);
      labels = 200;
      labelPanel = new Panel();
      labelPanel.setLayout(new GridLayout(labels/20, 20, 4, 4));
      labelPanel.setBackground(Color.green);
      addElements();
      add(labelPanel);
      }

      final void addElements()
      {
      LabelCanvas[] myLabel = new LabelCanvas[labels];
      Color color = ((count%2 == 0)? Color.orange : Color.yellow);
      count++;
      for (int i=0; i<labels; i++)
      {
      myLabel[i] = new LabelCanvas(String.valueOf(i), f);
      myLabel[i].setBackground(color);
      labelPanel.add(myLabel[i]);
      }
      }

      public void actionPerformed(ActionEvent ae)
      {
      if (ae.getSource() == b)
      {
      labelPanel.removeAll();
      addElements();
      validate();
      }
      }
      } // END OF Class CanvasTable3



      class LabelCanvas extends Canvas {

      Font f;
      String label;

      LabelCanvas(String label, Font f)
      {
      this.label = label;
      this.f = f;
      }

      public final void paint(Graphics g)
      {
      g.setFont(f);
      g.drawString(label, 0, 25);
      }

      public final Dimension getMinimumSize()
      {
      return (new Dimension(30, 30));
      }

      public final Dimension getPreferredSize()
      {
      return(getMinimumSize());
      }
      } // END OF Class LabelCanvas



      Source code for Example 2:

      import java.applet.*;
      import java.awt.*;
      import java.awt.event.*;

      public class StressNotify extends Applet implements ActionListener {

      Button onceButton, manyButton;
      LabelPanel labelPanelGreen, labelPanelRed;
      int panelShowing = -1;
      static final int RED = 0;
      static final int GREEN = 1;
      Panel panel;

      public void init()
      {
      onceButton = new Button( " Change panel once " );
      add(onceButton);
      onceButton.addActionListener(this);
      manyButton = new Button( " Change panel many times " );
      add(manyButton);
      manyButton.addActionListener(this);
      panel = new Panel();
      add(panel);
      addLabelPanel(GREEN);
      }

      void addLabelPanel(int panelToAdd)
      {
      panel.removeAll();
      if (panelToAdd == GREEN)
      {
      labelPanelGreen = new LabelPanel(Color.green);
      panel.add(labelPanelGreen);
      }
      else if (panelToAdd == RED)
      {
      labelPanelRed = new LabelPanel(Color.red);
      panel.add(labelPanelRed);
      }
      panelShowing = panelToAdd;
      }

      public void actionPerformed(ActionEvent ae)
      {
      if (ae.getSource() == onceButton)
      {
      addLabelPanel(1 - panelShowing);
      validate();
      }
      else if (ae.getSource() == manyButton)
      {
      for (int i=0; i<101; i++)
      {
      addLabelPanel(1 - panelShowing);
      validate();
      }
      }
      }
      } // END OF Class StressNotify


      class LabelPanel extends Panel {

      int labels = 200;

      LabelPanel(Color color)
      {
      setLayout(new GridLayout(labels/20, 20, 4, 4));
      setBackground(color);
      Label[] myLabel = new Label[labels];
      for (int i=0; i<labels; i++)
      {
      myLabel[i] = new Label(String.valueOf(i));
      myLabel[i].setBackground(color);
      add(myLabel[i]);
      }
      }
      } // END OF Class LabelPanel
      ---------- END SOURCE ----------

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: