In 3D computer graphics, everything is modeled and rendered with vertex-based data.LineArray object describes a set of vertices, and each two vertices defines the endpoints of a line.

This program uses multiple LineArray objects to draw lines to represent the x, y, and z axis.

 public class AxisApp extends JFrame {
  public AxisApp() {
    ....
  }

  public BranchGroup createSceneGraph() {
    BranchGroup objRoot = new BranchGroup();
    
    // Create X axis
    LineArray axisXLines=new LineArray(2,LineArray.COORDINATES);
    objRoot.addChild(new Shape3D(axisXLines));
      
    axisXLines.setCoordinate(0,new Point3f(-1.0f,0.0f,0.0f));
    axisXLines.setCoordinate(1,new Point3f(1.0f,0.0f,0.0f));        
    
    // Create Y axis  
    LineArray axisYLines=new LineArray(2,LineArray.COORDINATES|LineArray.COLOR_3);
    objRoot.addChild(new Shape3D(axisYLines));
      
    axisYLines.setCoordinate(0,new Point3f(0.0f,-1.0f,0.0f));
    axisYLines.setCoordinate(1,new Point3f(0.0f,1.0f,0.0f));
      
    // Create Z axis with arrow
    Point3f z1=new Point3f(0.0f,0.0f,-1.0f);
    Point3f z2=new Point3f(0.0f,0.0f,1.0f);
      
    LineArray axisZLines=new LineArray(10,LineArray.COORDINATES|LineArray.COLOR_3);
    objRoot.addChild(new Shape3D(axisZLines));
      
    axisZLines.setCoordinate(0,z1);
    axisZLines.setCoordinate(1,z2);
    axisZLines.setCoordinate(2,z2);
    axisZLines.setCoordinate(3,new Point3f(0.1f,0.1f,0.9f));
    axisZLines.setCoordinate(4,z2);
    axisZLines.setCoordinate(5,new Point3f(-0.1f,0.1f,0.9f));
    axisZLines.setCoordinate(6,z2);
    axisZLines.setCoordinate(7,new Point3f(0.1f,-0.1f,0.9f));
    axisZLines.setCoordinate(8,z2);
    axisZLines.setCoordinate(9,new Point3f(-0.1f,-0.1f,0.9f));
      
    return objRoot;
  }
}