import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class pictureshower extends Applet implements ActionListener { Image mycard; Button myButton=new Button("Show Pictures 1, 2, or 3"); TextField myTextField=new TextField("1 "); static int choice=0; public void init() { add(myButton); add(myTextField); myButton.addActionListener(this); } public void actionPerformed(ActionEvent event) { String temp; Object source=event.getSource(); if(source.equals(myButton)) { temp=myTextField.getText().trim(); //trim off spaces in textfield choice=Integer.parseInt(temp); repaint(); System.out.println(choice); } } public void paint(Graphics g) { resize(370,350); //myButton.setBounds(100,100,100,30); //myTextField.setBounds(100,200,100,30); System.out.println(choice); if(choice ==1) { mycard=getImage(getCodeBase(), "helmet.jpg"); g.drawImage(mycard, 120,70, this); } if(choice ==2) { mycard=getImage(getCodeBase(), "diros.jpg"); g.drawImage(mycard, 100,70, this); } if(choice ==3) { mycard=getImage(getCodeBase(), "corinth.jpg"); g.drawImage(mycard, 120,70, this); } } }