/* We compute the name of the file being sourced from the evaluator's source input stack and use this to label the newly created frame. */ fr = new Frame("Omega:"+sourceStack().peek()); b = new JButton("Omega Help"); /* Now we look for the image `help.gif' relative to this directory. We can do this by peeling the script name from the current object on the source stack. We do this using the getParent() facility of the File class. Then we set the icon of the button. */ url = sourceStack().lastElement(); url = new URL(url, new File(url.getFile()).getParent()+"/help.gif"); b.setIcon(new ImageIcon(url)); b.setToolTipText("Click to bring up the help system"); /* Ensure the Function Action Listener is available. If it has been created previously, we will get that version. Otherwise, it will be created. */ dynamicClassLoader().defineClass("java.awt.event.ActionListener","FunctionActionListener"); /* Register the simple function whose body is simply help() as a listener on this button. The second argument to FunctionActionListener is the current evaluator. */ b.addActionListener(new FunctionActionListener(function(x) {show(x);help();}, this)); fr.setLayout(new BorderLayout()); fr.add("Center", b); fr.pack(); fr.resize(new Dimension(150,150)); fr.show(); defaultWindow = fr;