import java.applet.Applet; import java.awt.*; import java.awt.event.*; import javax.swing.*; import com.sun.j3d.utils.geometry.*; import com.sun.j3d.utils.universe.SimpleUniverse; import javax.media.j3d.*; import javax.vecmath.*; public class Kuubilisamine1a extends JApplet implements ActionListener{ TransformGroup keere1; Button nupp=new Button("Lisa kuup"); BranchGroup juur = new BranchGroup(); public Kuubilisamine1a() { Canvas3D c = new Canvas3D(SimpleUniverse.getPreferredConfiguration()); getContentPane().add(c, BorderLayout.CENTER); getContentPane().add(nupp, BorderLayout.NORTH); juur.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE); juur.compile(); SimpleUniverse u = new SimpleUniverse(c); u.getViewingPlatform().setNominalViewingTransform(); u.addBranchGraph(juur); nupp.addActionListener(this); } public void actionPerformed(ActionEvent e){ BranchGroup oks1=new BranchGroup(); oks1.insertChild(new ColorCube(0.3), 0); oks1.compile(); juur.insertChild(oks1, 0); } public static void main(String[] args) { Frame f=new Frame("Kuubi lisamine"); f.add(new Kuubilisamine1a()); f.setSize(300, 300); f.setVisible(true); } }