package untitled1; import java.awt.*; import java.awt.event.*; import java.applet.*; public class phone extends Applet { PhoneCard phone; Keypad keys; String[] keylist = {"1","2","3","4","5","6","7","8","9","*","0","#"}; boolean isStandalone = false; /**Get a parameter value*/ public String getParameter(String key, String def) { return isStandalone ? System.getProperty(key, def) : (getParameter(key) != null ? getParameter(key) : def); } /**Construct the applet*/ public phone() { } /**Initialize the applet*/ public void init() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } keys = new Keypad(keylist,4,3); add(keys); phone = new PhoneCard(); add(phone); } class Keypad extends Panel{ public Keypad(String[] keylist,int r,int c){ setLayout(new GridLayout(r,c,15,2)); for( int i=0;i add(new Button(keylist[i])); } } } class PhoneCard extends Panel{ CardLayout c1; public PhoneCard(){ c1 = new CardLayout(); setLayout(c1); add("1",new Label("1")); add("2",new Label("2")); add("3",new Label("3")); add("4",new Label("4")); add("5",new Label("5")); add("6",new Label("6")); add("7",new Label("7")); add("8",new Label("8")); add("9",new Label("9")); add("*",new Label("*")); add("0",new Label("0")); add("#",new Label("#")); } public void showd(String s){ c1.show(this,s); } } public boolean action(Event e,Object button){ if(e.target instanceof Button) phone.showd((String)button); return true; } /**Component initialization*/ private void jbInit() throws Exception { } /**Get Applet information*/ public String getAppletInfo() { return "Applet Information"; } /**Get parameter info*/ public String[][] getParameterInfo() { return null; } }