Introduction
This book is a guide to writing code for COMSOL® models and applications using the Method Editor. The Method Editor is an important part of the Application Builder and is available in the COMSOL Desktop® environment in the Windows® version of COMSOL Multiphysics. For an introduction to using the Application Builder and its Form Editor and Method Editor, see the book Introduction to the Application Builder.
Writing a method is needed when an action is not already available in the standard run commands associated with functionality in the model tree nodes of the Model Builder. A method may, for example, contain loops, process inputs and outputs, and send messages and alerts to the user of the application.
In the Model Builder, the model tree is a graphical representation of the data structure that represents a model. This data structure is called the model object and stores the state of the underlying COMSOL Multiphysics model that is embedded in an application.
The contents of the application tree in the Application Builder is accessed through the application object, which is an important part of the model object. You can write code using the Method Editor to directly access and change the user interface of a running application, for example, to update button text, icons, colors, and fonts.
In the COMSOL Multiphysics environment, you use the Java® programming language to write methods, which means that you can utilize the extensive collection of Java® libraries. In addition to the Java® libraries, the Application Builder includes a built-in library for building applications and modifying the model object. A number of tools and resources are available to help you automatically create code for methods. For more information on autogeneration of code, see the book Introduction to the Application Builder.
This book assumes no prior knowledge of the Java® programming language. However, some familiarity with a programming language is helpful.