We can rotate the cube to show more than one face of it. The first step is to create the desired transformation using a Transform3D object. After call the rotX method of Transform3D object and apply it to a TransformGroup object, the cube included by the TransformGroup object is rotated.


public class RotateCube extends JFrame {
  public RotateCube() {

  public BranchGroup createSceneGraph() {
    BranchGroup objRoot = new BranchGroup();

    // Create the Transform3D object
    Transform3D rotate=new Transform3D();

    // instantiate the TransformGroup object
    TransformGroup objRotate=new TransformGroup(rotate);
    // Add the Cube into the TransformGroup object
    objRotate.addChild(new ColorCube(0.4));


    return objRoot;
  public static void main(String[] args){