package applets; import java.applet.*; import java.awt.*; import java.awt.image.*; import java.io.*; import java.util.Date; import java.net.URL; import shout3d.core.*; import shout3d.*; public class ChangeTexturesApplet extends Shout3DApplet{ String s1 = "Choose Textures"; Choice choiceButton; private Font f; public void init(){ super.init() ; setLayout(new BorderLayout()); Panel buttonsPanel = new Panel() ; Label sLabel1 = new Label(s1); choiceButton = new Choice(); choiceButton.addItem("Matt"); choiceButton.addItem("Arun"); choiceButton.addItem("Sampras"); buttonsPanel.setLayout(new GridLayout(10, 1, 10, 10)) ; buttonsPanel.add(choiceButton); buttonsPanel.add(sLabel1); add( "East", buttonsPanel); } public void initShout3DPanel(){ panel = new ChangeTexturesPanel(this); } public boolean handleEvent(Event event) { if (event.target == choiceButton && event.target instanceof Choice) { changeTexture(choiceButton.getSelectedIndex()); return(true); } else return(super.handleEvent(event)); } public void changeTexture(int texture_number){ String[] urlVals1 = {"matt.jpg"}; String[] urlVals2 = {"arun.jpg"}; String[] urlVals3 = {"sampras.gif"}; ImageTexture image_texture; if ((image_texture = (ImageTexture) getNodeByName("Face_Image") ) == null) throw new Shout3DException("Could not find node Face_Image"); if (image_texture != null){ if (texture_number==0) image_texture.url.setValue(urlVals1); else if (texture_number==1) image_texture.url.setValue(urlVals2); else if (texture_number==2) image_texture.url.setValue(urlVals3); } } }