title: Java3D drawing empty white window in an applet
body: <p>i am learning java3D 1.5.2 and already done some ColorCube testing. The last java3D applet i done is about 2000 ColorCubes rotating, translating in both themselves and whole universe. The cubes are generated as a leaf-node-array of the transform branch group</p>
  
  <p>Picture:
  <img src="https://i.stack.imgur.com/yMkG3.jpg" alt="enter image description here"></p>
  
  <p>My problem is: sometimes it shows well without any problem but sometimes  window is white and nothing shows until i resize the window or make it full-screen.</p>
  
  <p><strong>Question:</strong> Can you give me some hints about this problem? I am not using any repaint() or similar methods. Java3D thread is drawing whole thing i assume. How can i overcome this drawing-update problem?</p>
  
  <p>Here is a short pseude-code:</p>
  
  <pre><code>class myclass extends Applet
  {
      public void init()
          {
             //some init here
          }
  
      public void start()
          {
             //i make my thread start here
             mythread.start();
          }
  
      public void stop()
          {
             //...i make my thread pause here
          }
  
      public void destroy()
          {
             // Here i release the thread
          }
  
      public void paint()
          {
             //nothing here. its empty
          }
  
      public class my_thread extends Thread
          {
              public void run()
                   {
                          //here i use the java3D to initialize java3D things
                          while(working)
                             {
                                 // here i change 2000 colorcubes' displacement and rotation
                             }
                   }
          } 
  }
  </code></pre>
  
  <p>Here is some of the initialisation of java3D i mentioned:</p>
  
  <pre><code>            GraphicsConfiguration GC_me=SimpleUniverse.getPreferredConfiguration();
              Canvas3D Canvas_me=new Canvas3D(GC_me);
              SimpleUniverse Space_me = new SimpleUniverse(Canvas_me);
  </code></pre>
  
  <p>Thanks.</p>
  
  <p>Here is a full code:</p>
  
  <pre><code>package fiziksel_model;
  
  
  import java.awt.*;
  import java.applet.*;
  
  import javax.media.j3d.*;
  import javax.vecmath.*;
  
  import com.sun.j3d.utils.*;
  import com.sun.j3d.utils.geometry.ColorCube;
  import com.sun.j3d.utils.universe.SimpleUniverse;
  
  
  public class yabanci extends Applet{
  
  /**
  * Version 1
  */
  
  
  private static final long serialVersionUID = 1L;
  
  
  
  public drawer_thread palette=new drawer_thread();
  int i;
  public void init()
  {
     System.out.println(" started! ");
  
  
  
  }
  //Geometry geom;
  public void start()
  {
     System.out.println(" continuing...");
  
  
     palette.start();
  
  
  }
  public void stop()
  {
     System.out.println(" stopped! ");
  
  }
  public void destroy()
  {
     System.out.println(" destroyed!");
  
  }
  public void paint(Graphics g)
  {
  
             System.out.println(" painted! ");// does not print anything.
  }
  
  
  public class drawer_thread extends Thread
  {
  
     public void run()
     {
         Vector3f temp_vect=new Vector3f();
         ColorCube color_box=new ColorCube(0.2f);
  
         GraphicsConfiguration GC_me=SimpleUniverse.getPreferredConfiguration();
         Canvas3D Canvas_me=new Canvas3D(GC_me);
         SimpleUniverse my_space = new SimpleUniverse(Canvas_me);
  
         BranchGroup cube_barrage = new BranchGroup();
         Transform3D rotator_element=new Transform3D();
         Transform3D temp_rotator=new Transform3D();
  
  
         cube_barrage.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
         cube_barrage.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
         cube_barrage.setCapability(TransformGroup.ALLOW_CHILDREN_READ);
         cube_barrage.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
         setLayout(new BorderLayout());
  
  
  
  
         TransformGroup rotator1=new TransformGroup(rotator_element);
         TransformGroup rotator2=new TransformGroup(rotator_element);
         TransformGroup rotator3=new TransformGroup(rotator_element);
         TransformGroup rotator4=new TransformGroup(rotator_element);
  
         Vector3f translation[]=new Vector3f[4000];
         TransformGroup core1[]=new TransformGroup[4000];
         TransformGroup core2[]=new TransformGroup[4000];
         TransformGroup core3[]=new TransformGroup[4000];
         Transform3D core_move1[]=new Transform3D[4000];
         Transform3D core_move2[]=new Transform3D[4000];
         Transform3D core_move3[]=new Transform3D[4000];
         for(int j=0;j&lt;4000;j++)
         {
         translation[j]=new Vector3f();
         core1[j]=new TransformGroup();core2[j]=new TransformGroup();
         core_move1[j]=new Transform3D();
         core_move2[j]=new Transform3D();    
         core_move3[j]=new Transform3D();
         }
  
         for(int j=0;j&lt;4000;j++)
         {
         translation[j]=new Vector3f();
         translation[j].x=(float) (j/10.0);
         translation[j].y=(float)(-0.5+Math.random()*1.0);
         translation[j].z=(float)(-0.5+Math.random()*1.0);
  
         core_move1[j].setTranslation(translation[j]);
         core_move2[j].setTranslation(translation[j]);
         core_move3[j].setTranslation(translation[j]);
  
         core1[j]=new TransformGroup(core_move1[j]);
         core2[j]=new TransformGroup(core_move1[j]);
         core3[j]=new TransformGroup(core_move1[j]);
         core1[j].setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
         core1[j].setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
         core2[j].setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
         core2[j].setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
  
         core3[j].setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
         core3[j].setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
         }
  
  
  
  
  
  
         rotator1.addChild(rotator2);
         rotator2.addChild(rotator3);rotator3.addChild(rotator4);
         rotator1.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
         rotator1.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
         rotator2.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
         rotator2.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
         rotator3.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
         rotator3.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
         rotator4.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
         rotator4.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
  
  
  
  
         for(int j=0;j&lt;4000;j++)
         {
              rotator4.addChild(core1[j]);
              core1[j].addChild(core2[j]);
              core2[j].addChild(core3[j]);
              core3[j].addChild(new ColorCube(0.1));
         }
  
  
         cube_barrage.addChild(rotator1);
  
  
         cube_barrage.compile();
         my_space.addBranchGraph(cube_barrage);
         add("Center", Canvas_me);
         //Canvas_me.validate();
  
         my_space.getViewingPlatform().setNominalViewingTransform();
         float ran[]=new float [4000];
         float ran2[]=new float [4000];
         Vector3f temp_vector=new Vector3f();
         for(int j=0;j&lt;4000;j++)
         {
             ran[j]=(float) Math.random();
             ran2[j]=(float) Math.random();
         }
  
         for(i=0;i&lt;10000;i++)
         {
  
  
  
             rotator1.getTransform(temp_rotator);
             temp_rotator.setScale(0.1+0.05*Math.abs(Math.sin(i*0.03)));
             rotator1.setTransform(temp_rotator);
  
             rotator2.getTransform(temp_rotator);
             temp_rotator.rotX(i*0.03);
             rotator2.setTransform(temp_rotator);
  
             rotator3.getTransform(temp_rotator);
             temp_rotator.rotY(i*0.03);
             rotator3.setTransform(temp_rotator);
  
             rotator4.getTransform(temp_rotator);
             temp_rotator.rotZ(i*0.03);
             rotator4.setTransform(temp_rotator);
  
  
             for(int j=0;j&lt;4000;j++)
             {
                 core1[j].getTransform(temp_rotator);
                 temp_rotator.get(temp_vector);
                 temp_vector.x+=(float) (-0.5+Math.random())*0.02;
                 temp_vector.y+=(float) (-0.5+Math.random())*0.02;
                 temp_vector.z+=(float) (-0.5+Math.random())*0.02;
  
                 temp_rotator.setTranslation(temp_vector);
                 core1[j].setTransform(temp_rotator);
  
                 core2[j].getTransform(temp_rotator);
  
  
                 temp_rotator.rotZ(i*0.03+0.01*ran[j]*i);
  
                 core2[j].setTransform(temp_rotator);
  
  
                 core2[j].getTransform(temp_rotator);
                 temp_rotator.rotY(i*0.02+0.01*ran2[j]*i);
                 core2[j].setTransform(temp_rotator);
             }
  
  
             System.out.println(i);
             try {
                 sleep(40);
             } catch (InterruptedException e) {
                 // TODO Auto-generated catch block
                 e.printStackTrace();
             }
         }
     }}}
  </code></pre>
  
  <p>Thank you for your time. </p>