JSR-295 Demo: Ticker Demo

This page describes a simple Beans Binding demo with NetBeans 6.


  • NetBeans 6.0 M10 or newer.
  • Ticker bean (and its BeanInfo) available in an opened compiled project (or installed in the Palette). Download, open and build the Ticker Project.


  • Create new JFrame.
  • Invoke File > New File ... > Java GUI Forms ... > JFrame Form.
  • Press Next, press Finish.
  • DnD the Ticker bean into the upper left corner of the designer.
  • Resize the right edge of the Ticker bean to make 'YOU FORGOT' label visible.
  • Optional: Make the Ticker bean resizable by pressing the left-right arrow
     in the form toolbar.
  • Show the properties of the Ticker bean in the property sheet.
  • Insert GUI components that will control the ticker.
  • Insert JLabel below the ticker bean and change its text to 'Label:'.
  • Insert JTextField next to label and align it on the baseline with the label.
  • Make the added text field bigger (resize its right edge).
  • Insert another JLabel below the first one and change its text to 'Speed:'.
  • Insert JSlider next to label.
  • Insert JCheckBox below the other components and change its text to 'Squared LEDs'.
  • Optional: Invoke Set Default Size action from the contextual menu of the frame.
  • Bind the JTextField.
  • Select the JTextField and switch the Property window to Bindings category.
  • Press ... button next to text binding property to invoke the binding customizer.
  • Select ticker1 as a Binding Source.
  • Select label as a Binding Expression.
  • Press OK.
  • Note that the text field changed its text immediately to reflect the binding.
  • Bind the JSlider.
  • Select the JSlider.
  • Invoke Bind > value action from its contextual menu.
  • Select ticker1 as a Binding Source.
  • Select speed as a Binding Expression.
  • Select Advanced tab to show other aspects of the binding that you can configure.
  • Press OK.
  • Bind the JCheckBox.
  • Select the JCheckBox.
  • Press ... button next to selected binding property in the Properties window.
  • Select ticker1 as a Binding Source.
  • Select squaredLeds as a Binding Expression.
  • Press OK.
  • Preview (invoke Preview Design action from form toolbar) or execute
     the form (press Shift F6) and show how the components are bound.
  • Switch to Source code and highlight addBinding calls to show
     how simple it is to create the binding. You may also highlight
     bindingContext.bind() call at the end of initComponents() to show
     where the bindings are realized.

Optionally you can bind more ticker properties to more controls, e.g. the text size to a slider.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo