Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8511575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:02:12+00:00 2026-06-11T04:02:12+00:00

i am learning java3D 1.5.2 and already done some ColorCube testing. The last java3D

  • 0

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

Picture:
enter image description here

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.

Question: 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?

Here is a short pseude-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
                           }
                 }
        } 
}

Here is some of the initialisation of java3D i mentioned:

            GraphicsConfiguration GC_me=SimpleUniverse.getPreferredConfiguration();
            Canvas3D Canvas_me=new Canvas3D(GC_me);
            SimpleUniverse Space_me = new SimpleUniverse(Canvas_me);

Thanks.

Here is a full 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<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<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<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<4000;j++)
       {
           ran[j]=(float) Math.random();
           ran2[j]=(float) Math.random();
       }

       for(i=0;i<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<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();
           }
       }
   }}}

Thank you for your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:02:14+00:00Added an answer on June 11, 2026 at 4:02 am

    Second try : Move following lines of code from your thread into the applet’s init method to ensure that they run in the event dispatching thread (EDT).

    private SimpleUniverse my_space = null;
    public void init()
    {
       System.out.println(" started! ");
       GraphicsConfiguration GC_me = SimpleUniverse.getPreferredConfiguration();
       Canvas3D Canvas_me = new Canvas3D(GC_me);
       my_space = new SimpleUniverse(Canvas_me);
       setLayout(new BorderLayout());
       add("Center", Canvas_me);
    }
    

    Please, save your 200 reputation as I’m not registered. When do i register i dont know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Learning some VBA. So far, I've constructed this piece of code which should allow
Learning Scala currently and needed to invert a Map to do some inverted value->key
Learning about notifyAll made me question something about notify: in a typical situation we
Learning spine.js I completed both the tutorials no problem, seems like a great framework,
Learning java server technologies, trying to clarify some things. There are few technologies that
I'm learning ActionScript/Flash. I love to play with text, and have done a lot
learning about loops (still a beginner) in VB.net. I have got the below code
Learning flex, What would be the appropriate way to add some AS in a
Learning about Explicit Cursors and trying to create my frst one.: SET SERVEROUTPUT ON
Learning a bit about the differences between XHTML and HTML, I looked at the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.