Extended Exercise Adding a Gui q We can










- Slides: 10
Extended Exercise – Adding a Gui q We can now make use of the Java Swing classes to add a Gui to our model q Java classes can be added to the model as references and shown on Object Model Diagrams q Java classes can also simply be added as attributes q To generate the appropriate Import statements, we will need to add dependencies with “Usage” stereotypes to the Java packages or classes. Rhapsody in J Tool Training "Essential" © I-Logix 1999 -2002 v 4. 01 07/07/2002 1 www. telelogic. com
Adding Java Packages q Add the java. awt & javax. swing packages to the browser q We must now change the Component so that no code is generated for the java packages Rhapsody in J Tool Training "Essential" © I-Logix 1999 -2002 v 4. 01 07/07/2002 2 www. telelogic. com
Adding a JFrame & Text. Field q Add a JFrame and Text. Field to the Display Class: Rhapsody in J Tool Training "Essential" © I-Logix 1999 -2002 v 4. 01 07/07/2002 3 www. telelogic. com
Adding a Font q Add attributes FONT_SIZE and FONT_NAME to the Display class: Rhapsody in J Tool Training "Essential" © I-Logix 1999 -2002 v 4. 01 07/07/2002 4 www. telelogic. com
Accessors and Mutators q Since some of our attributes are final, we can not have any mutators q Set the properties so that neither mutators or accessors are generated for all attributes in the Display class Rhapsody in J Tool Training "Essential" © I-Logix 1999 -2002 v 4. 01 07/07/2002 5 www. telelogic. com
Modifying the Show Operation q Modify the Show Operation of the Display Class: Rhapsody in J Tool Training "Essential" © I-Logix 1999 -2002 v 4. 01 07/07/2002 6 www. telelogic. com
Initializing the Display Gui q Add a new Constructor to the Display class: Don’t forget that to save typing, text can be cut and pasted from the report. Rhapsody in J Tool Training "Essential" © I-Logix 1999 -2002 v 4. 01 07/07/2002 7 www. telelogic. com
Adding Dependencies q In order to generate the appropriate import statements, we need to add dependencies to the java packages. These dependencies could also be modelled on Object Model Diagrams Rhapsody in J Tool Training "Essential" © I-Logix 1999 -2002 v 4. 01 07/07/2002 8 www. telelogic. com
Gen Make & Run q Save Generate, Make & Run q Inject an ev. Start event into the Cash. Register object If there is an error, it may be because the import statements have not been generated in the Display. java file, doing a Re Generate will create them. Rhapsody in J Tool Training "Essential" © I-Logix 1999 -2002 v 4. 01 07/07/2002 9 www. telelogic. com
Rhapsody in J Tool Training "Essential" © I-Logix 1999 -2002 v 4. 01 07/07/2002 10 www. telelogic. com