// ButtonBook // (c) Catfish Software, Aug. 9, 1997 // import java.applet.Applet; import java.awt.*; class GoButton extends Button{ String gopage; public GoButton(String label, int gopage) { super(label); this.gopage = "page"+(gopage); } } public class ButtonBook extends Applet { public void init() { setLayout(new CardLayout()); setFont(new Font("TimesRoman", Font.BOLD, 18)); int pages = Integer.parseInt(getParameter("pages")); for (int j = 0; j < pages; j++) { Panel page = new Panel(); page.setLayout(new BorderLayout()); String pagetext = getParameter("text"+(j)); if (pagetext == null) { showStatus("Page text error"); break; } TextArea ta = new TextArea(pagetext.replace('|','\n')); ta.setEditable(false); page.add("Center", ta); Panel btns = new Panel(); for (int i = 0; i < 2; i++) { GoButton b; String label = getParameter("btnl"+(j)+(i)); if (label == null) { showStatus("Bottun label error"); break; } int gopage = Integer.parseInt(getParameter("btng"+(j)+(i))); b= new GoButton(label, gopage); btns.add(b); } page.add("South", btns); add("page"+(j), page); } } public ButtonBook() {} public boolean action(Event e, Object o) { if (e.target instanceof GoButton) { GoButton b = (GoButton)(e.target); ((CardLayout)this.getLayout()).show(this, b.gopage); return true; } return false; } }