Draw on the right, write (Umple) model code on the left. Analyse models and generate code. This tool stores your data in cookies and on a server. I understand. Click to learn about privacy. Download Donate For help: User manual Ask questions Report issue
/* This example demonstrates an example of using the internal, depends, external, before and after keywords to interface umple code to code in another system. The internal keyword is suitable for situations where the developer doesn't want setter/getters to be generated. GUI windows are an example of such a case. A GUI window/unit contains several components but the rest of the program may only need the value stored within those components. So it's a good practice to hide UI components from classes other than the containing one. */ // required to make HelloInternals class a JFrame external JFrame{} class HelloInternals { // HelloInternals extends JFrame isA JFrame; // importing required classes depend javax.swing.JFrame; depend javax.swing.JLabel; /* messageLabel is a component of the frame; often we don't want sub-components of a GUI unit to be settable/gettable. By making them internal Umple will avoid generating setter/getter for messageLabel. Using lazy Umple will avoid adding a constructor parameter for this component */ lazy internal JLabel messageLabel; // the contents of messageLabel String message; /* before getting the message, this code updates the message attribute using the text from messageLabel */ before getMessage { message=messageLabel.getText(); } /* after setting the messae, this code updates messageLabel to contain the newly updated message */ after setMessage { messageLabel.setText(message); } // using after constructor is a good way of // initiating a GUI unit after constructor { getContentPane().setLayout(null); messageLabel=new JLabel(message); messageLabel.setBounds(10, 10, 200, 20); add(messageLabel); pack(); setSize(250, 200); } } //$?[End_of_model]$? // @@@skipcppcompile - Contains Java Code // @@@skipphpcompile - Contains Java Code // @@@skiprubycompile - Contains Java Code // @@@skippythoncompile - Contains Java Code