The NodeView displays the data of the NodeModel in a specific way. This can be done either by using Java components such as javax.swing.JTable or javax.swing.JTree or by drawing the data using the java.awt.Graphics object. In the latter case a javax.swing.JPanel can be used and the paintComponent(Graphics) method must be overridden. There are four sites in the NodeView to place your code:

NodeView constructor:

  1. constructor
  2. modelChanged
  3. onOpen
  4. onClose
  5. The constructor is called whenever the view is opened. This is the best place to initialize the fields, data structures, and components you need. When everything is initialized and the preferences are set, call the setComponent(Component). Only one component can be set with this method, thus, if you have several components you have the make a composite by your own and set this composite. It is good practice to call this method only once and then in the constructor. Note: you can leave the view open, when resetting the node or even change the input of the node, i.e. all operations related to the data of the model cannot be placed in the contructor. Hence, the modelChanged method informs the view about changes in the underlying NodeModel. It is possible to open several views for a single NodeModel, though. Local functionality, such as selection, has to be administered in the NodeView. Corresponding data structures can be initialized in the NodeView's constructor.

    Example #1:

    protected ValueCounterNodeView(final NodeModel nodeModel) {
        m_panel = new YourSpecializedPanel();

What are you looking for?