Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.jgoodies.binding.tutorial.basics
Class EditorCopyingExample  view EditorCopyingExample download EditorCopyingExample.java

java.lang.Object
  extended bycom.jgoodies.binding.tutorial.basics.EditorCopyingExample

public final class EditorCopyingExample
extends java.lang.Object

Builds an editor that copies data from the domain back and forth. This approach is known as the "copying" approach or "push/pull".

The event handling used to enable and disable the composer text field is invoked by a ChangeListener that hooks into the classical check box. Note that this lacks the domain logic, where the composer is set to null if the classical property is set to false. This logic is deferred until the component values are written to the edited Album via #updateModel when OK is pressed.

Version:
$Revision: 1.4 $

Nested Class Summary
private  class EditorCopyingExample.CancelAction
           
private  class EditorCopyingExample.ClassicalChangeHandler
           
private  class EditorCopyingExample.OKAction
           
private  class EditorCopyingExample.ResetAction
           
 
Field Summary
private  javax.swing.text.JTextComponent artistField
           
private  javax.swing.JButton cancelButton
           
private  javax.swing.JCheckBox classicalBox
           
private  javax.swing.text.JTextComponent composerField
           
private  com.jgoodies.binding.tutorial.Album editedAlbum
          Refers to the Album that is to be edited by this example editor.
private  javax.swing.JButton okButton
           
private  javax.swing.JButton resetButton
           
private  javax.swing.text.JTextComponent titleField
           
 
Constructor Summary
EditorCopyingExample()
          Constructs an editor for an example Album.
EditorCopyingExample(com.jgoodies.binding.tutorial.Album album)
          Constructs an editor for an Album to be edited.
 
Method Summary
 javax.swing.JComponent build()
          Builds and returns the editor panel.
private  javax.swing.JComponent buildButtonBar()
           
private  void initComponents()
          Creates and intializes the UI components.
private  void initEventHandling()
          Observes the classical check box to update the composer field's enablement and contents.
static void main(java.lang.String[] args)
           
private  void updateComposerField()
          Updates the composer field's enablement and contents.
private  void updateModel()
          Reads the values from this editor's components and set the associated Album properties.
private  void updateView()
          Reads the property values from the edited Album and sets them in this editor's components.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

editedAlbum

private final com.jgoodies.binding.tutorial.Album editedAlbum
Refers to the Album that is to be edited by this example editor.


titleField

private javax.swing.text.JTextComponent titleField

artistField

private javax.swing.text.JTextComponent artistField

classicalBox

private javax.swing.JCheckBox classicalBox

composerField

private javax.swing.text.JTextComponent composerField

okButton

private javax.swing.JButton okButton

cancelButton

private javax.swing.JButton cancelButton

resetButton

private javax.swing.JButton resetButton
Constructor Detail

EditorCopyingExample

public EditorCopyingExample()
Constructs an editor for an example Album.


EditorCopyingExample

public EditorCopyingExample(com.jgoodies.binding.tutorial.Album album)
Constructs an editor for an Album to be edited.

Method Detail

main

public static void main(java.lang.String[] args)

initComponents

private void initComponents()
Creates and intializes the UI components.


initEventHandling

private void initEventHandling()
Observes the classical check box to update the composer field's enablement and contents. For demonstration purposes a listener is registered that writes all changes to the console.


updateView

private void updateView()
Reads the property values from the edited Album and sets them in this editor's components.


updateModel

private void updateModel()
Reads the values from this editor's components and set the associated Album properties.


build

public javax.swing.JComponent build()
Builds and returns the editor panel.


buildButtonBar

private javax.swing.JComponent buildButtonBar()

updateComposerField

private void updateComposerField()
Updates the composer field's enablement and contents. Sets the enablement according to the selection state of the classical check box. If the composer is not enabled, we copy the domain logic and clear the composer field's text.