TOC PREV NEXT INDEX



Working with JavaBeans


In the previous section we added several parts to our application, one of which is the Knob bean that we imported earlier. Working with JavaBeans is very similar to working with parts that are preinstalled on the palette. Lets look at the properties page for this bean.

  1. Click once on the Knob in the Working Model.

Simplicity generates a custom property page for any bean that you import using the bean's exposed properties. From left to right, you see a list of property names, an input field, the data type, and the default value. Any properties which you leave blank will keep their default value.

  1. Enter 32 for the minimum.
  2. Enter 212 for the maximum.
  3. Enter 73 for the value.
  4. Enter 35 for the radius.

Handling events with JavaBeans works exactly the same as with other parts.

  1. Select the 'Listeners' page of the Knob.
  2. Check 'Listen for KnobTurn events'. A message will be briefly displayed in the Java Console as Simplicity sets up the new event type. When this finishes a 'KnobTurn' tab will appear.
  3. Choose the KnobTurn tab.
  4. Press Code Sourcerer and choose 'Ask a part about one of its properties...'. Press Next.
  5. Choose 'bean2' from the list. Press Next.
  6. Choose 'value'. Press Done. Press Ok in the dialog which then appears.
  7. Press Code Sourcerer and choose 'Change a property of an existing part...'. Press Next.
  8. Choose 'jProgressBar3' from the list. Press Next.
  9. Choose 'current value'. Press Done.
  10. In the generated code, replace 0 with "value".

The final code should appear as

int value = bean2.getValue();
jProgressBar3.setValue(value);

You can test this by turning the knob using the mouse. The progress bar should respond by showing the mercury level.


Data Representations, Inc.
http://www.datarepresentations.com
support@datarepresentations.com
sales@datarepresentations.com
TOC PREV NEXT INDEX