import java.awt.*; import java.awt.event.*; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.FileInputStream; import java.io.IOException; /** This class reads a help text file and pops it up in a scrolling dialogue * window. * * @author Russell Young tetrii@young-0.com * @version 1.0 */ /* Feel free to use, distribute, or change, with the only restriction that you * should not remove my name from the original code, and you should document * your changes so there is no confusion about whose bugs they are. */ class help extends Dialog { ScrollPane sp = null; // This is the location of the help file help(Frame frame, String helpFile) throws IOException { super(frame, "Tetrii description", true); Panel p; Button b; if (sp == null) { p = new Panel(new GridLayout(0, 1)); String s = null; sp = new ScrollPane(); BufferedReader text = new BufferedReader (new InputStreamReader (new FileInputStream(helpFile))); while ((s = text.readLine()) != null) p.add(new Label(s)); sp.add(p); } add("Center", sp); p = new Panel(); p.add(b = new Button("OK")); add("South", p); b.addActionListener(new okButton(this)); setSize(500, 300); validate(); show(); } } class okButton implements ActionListener { private Dialog dialog; okButton(Dialog d) {dialog = d;} public void actionPerformed(ActionEvent e) {dialog.dispose();} }