![]() |
![]() |
![]() |
![]() |
The Composer Window for a Canvas object
Canvas Property Notebooks
The 'Canvas' property page contains several settings which affect how the Java source code is generated. The new JavaBean can extend one of four posible choices: Component, Container, JComponent, or Canvas. The generated Java class will have its name specified by the text in Object Name, and it will extend the chosen parent class.
The Canvas Composer has a special page labelled 'Canvas Methods'. It contains two methods:
The getPreferredSize() should return the best size for the component being created. For example, the code
would make the preferred size of the Canvas 300 pixels wide and 200 pixels high. New Canvas objects start with a preferred size of (200,200).
The paint() method contains all of the instructions for drawing the component. Each of the palette buttons write some code to this area. The user can also write code here as well. The working model will display the appearance of the component based upon the drawing instructions in the paint() method. The paint method of a Canvas object might be called very frequently, so it is a bad idea to have computationally intensive code in this area.
Data Representations, Inc. http://www.datarepresentations.com support@datarepresentations.com sales@datarepresentations.com |
![]() |
![]() |
![]() |
![]() |