// import java.applet.*; import java.awt.*; import java.awt.event.*; class ButtonPanel extends Panel { ButtonPanel () { FlowLayout fl = new FlowLayout (FlowLayout.CENTER); setLayout (fl); fl.setHgap (200); fl.setVgap (5); add (new Button ("Smiley"), FlowLayout.LEFT); add (new Button ("Frowny"), FlowLayout.LEFT); setBackground (Color.pink); } } public class t2 extends Applet { Image imgQ, imgSmiley, imgFrowny; Button bHead, bTail; TextField nWins, nLoses; Dimension dim; Label lab; public void init() { setBackground (Color.white); resize (500,300); // setSize (500,500) dim = getSize(); System.out.println ("whats up?"); System.out.println (getDocumentBase()); imgQ = getImage (getDocumentBase(), "Question.gif"); imgSmiley = getImage (getDocumentBase(), "Smiley.gif"); imgFrowny = getImage (getDocumentBase(), "Frowny.gif"); lab = new Label ("Mind Reader"); bHead = new Button ("Heads?"); bTail= new Button ("Tails"); // add (bHead); // add (bTail); setLayout (new BorderLayout ()); add ("North", lab); add ("East", new Button ("East")); add ("West", new Button ("West")); add ("South", new ButtonPanel ()); // add (new ButtonPanel ()); // repaint (); } public boolean action (Event evt, Object arg) { if (evt.target.equals (bHead)) {System.out.println ("bHead"); repaint();} else if (evt.target.equals (bTail)) System.out.println ("bTail"); else return super.action (evt, arg); return true; } public void paint( Graphics g ) { // g.drawString ( "Hello World!", 30, 30 ); dim = getSize(); g.drawImage (imgQ, dim.width/2-40, 50, this); g.drawImage (imgSmiley, 20, 150, this); g.drawImage (imgFrowny, dim.width-100, 150, this); } }