import java.awt.*; import java.awt.event.*; import java.applet.*; /** This is the main class of the demo-applet. */ public class applet_pattern_befehl extends Applet { ConstructionPanel constructionPanel; /** Destroys the applet */ public void destroy() { remove(constructionPanel); } /** Gets applet information */ public String getAppletInfo() { return "Implementation of the pattern 'command'"; } /** The method creates an instance of the class ConstructionPanel and two normal buttons. It then adds several elements to the ConstructionPanel. */ public void init() { setLayout(new BorderLayout()); constructionPanel = new ConstructionPanel(); Panel buttonPanel = new Panel(); add("Center",constructionPanel); add("South",buttonPanel); // the buttons - they will be added to the applet-window // and to the constructionPanel MyButton button1 = new MyButton("Button1"); MyButton button2 = new MyButton("Button2"); buttonPanel.add(button1); buttonPanel.add(button2); // This demo uses only three normal commands and one // macro-command. It is not difficult to add more of them. MacroCommand macro = new MacroCommand(); TestCommand1 command1 = new TestCommand1(); TestCommand2 command2 = new TestCommand2(); TestCommand3 command3 = new TestCommand3(); constructionPanel.addButton(button1,35,35); constructionPanel.addButton(button2,35,75); constructionPanel.addMacroCommand(macro,"macro1",200,65); constructionPanel.addCommand(command1,"Simple Win",350,25); constructionPanel.addCommand(command2,"System-Info",350,65); constructionPanel.addCommand(command3,"Filechooser",350,105); } /** main function */ public static void main(String[] args) { Frame f = new Frame("Pattern Command"); applet_pattern_befehl applet = new applet_pattern_befehl(); applet.init(); applet.start(); f.add("Center",applet); f.setSize(300,300); f.setVisible(true); } }