To inherit from an external class, use the *extends* keyword according to the syntax: ConstOrAltClass : ConstructionClass | AlternationClass *common* List(PartOrSyntax) ClassParents. ClassParents = [ "*extends*" Superclass ] [ "*implements*" Commalist(Interface) ] . In your example, you write: (@ import netscape.application.*; @) ... MyButton = *extends* Button. It seems that you should also be able to write: MyButton = *extends* netscape.application.Button. but this is not possible with the current Demeter/Java. -- Karl L. From dmann@mars.org Tue Feb 25 05:53:20 1997 Sender: dmann@ccs.neu.edu From: David Mann To: lieber@ccs.neu.edu CC: dougo@ccs.neu.edu, johan@ccs.neu.edu Subject: There must be a better way.... Hi y'all, I'm working on creating the GUI for VisualTraverse. This evening I've had an interesting time trying to integrate objects defined in external packages (namely netscape.application) into my demeter program. I import the proper headers, but if I wanted to use something like the following in the classgraph: netscape.application.Button :MyButton. MyButton =. Then demjava chokes on the "." in "netscape.application.Button". If I just use the following: Button :MyButton. MyButton =. then demjava creates an abstract class of Button that conflicts with the netscape button class. What is the "Right" way of doing this? I figured out a workaround but it is really gross. The following are the .cd file and .beh file for an application. Note that in the .cd file, I had to manually include "import demeter.*;". These .cd and beh files actually work, but there must be a better way of doing this.. ________________________________ //prog.cd (@ import netscape.application.*; import netscape.util.*; import java.io.*; import java.util.*; import demeter.*; class UIButton extends netscape.application.Button { UIButton(UIPoint ul, UIPoint lr,msg messg) { super(ul.get_x().intValue(),ul.get_y().intValue(), lr.get_x().intValue(),lr.get_y().intValue()); setTitle(messg.get_name()); } } class HelloWorld extends Application { TextField textField; public void init() { super.init(); mainRootView().setColor(Color.lightGray); textField = new TextField(64, 24, 128, 24); textField.setStringValue("Hello World"); mainRootView().addSubview(textField); try{ UIList a=UIList.parse(System.in); a.g_print(); } catch (ParseError e){ System.out.println("Parsing Eror!!!!!"); } } } @) Main =. PrintingVisitor =. UIList =ElementList. UIElement :ButtonHolder|TextFieldHolder. ButtonHolder ="button" msg Coords";". TextFieldHolder ="label" msg";". msg =String. //Coords is x,y, width,height Coords ="{"
    UIPoint "," UIPoint"}". ElementList = NList(UIElement). UIPoint ="(" Integer "," Integer ")". NList(S) ~S {S}. _______________________________________________________________ //prog.beh UIList { (@ void g_print() { PrintingVisitor pv=new PrintingVisitor(); this.t(pv); } @) traversal t(PrintingVisitor pv) {to *;} } ButtonHolder { (@ UIButton button; public void g_makeUI(){ button=new UIButton(get_coords().get_ul(), get_coords().get_lr(), get_msg()); } @) } Main { (@ public static void main(String args[]) throws Exception { HelloWorld app; ExternalWindow mainWindow; Size size; app = new HelloWorld(); mainWindow = new ExternalWindow(); app.setMainRootView(mainWindow.rootView()); size = mainWindow.windowSizeForContentSize(320, 200); mainWindow.sizeTo(size.width, size.height); mainWindow.show(); app.run(); //UIList a=UIList.parse(System.in); //a.g_print(); } @) } PrintingVisitor { before ButtonHolder (@ System.out.println("button:"); @) before TextFieldHolder (@ System.out.println("label:"); @) before msg (@ System.out.println(" "+host.get_name()); @) }