FileDocCategorySizeDatePackage
DateBeanCustomizer_batch.javaAPI DocExample6235Sat Sep 12 03:01:00 BST 1998borland.samples.beans.customizer

DateBeanCustomizer_batch

public class DateBeanCustomizer_batch extends JPanel implements Customizer

Fields Summary
PropertyChangeSupport
pcs
DateBean
bean
Integer
oldStyle
Boolean
oldUseMonthString
BorderLayout
borderLayout1
JPanel
southPanel
FlowLayout
fL1
JPanel
buttonPanel
GridLayout
gL1
JButton
apply
JLabel
title
JPanel
centerPanel
BorderLayout
bL2
ChoicePanel
choices
JPanel
eastPanel
JCheckBox
useMS
JButton
revert
Constructors Summary
public DateBeanCustomizer_batch()


    
    // all the neat stuff lives in setObject()
  
Methods Summary
public voidaddPropertyChangeListener(java.beans.PropertyChangeListener parm1)

    if(pcs == null)
      pcs = new PropertyChangeSupport(this);
    pcs.addPropertyChangeListener(parm1);
  
voidapply_actionPerformed(java.awt.event.ActionEvent e)

    if(bean != null){
      changeStyleProperty(new Integer(choices.getSelectedItem()));
      changeUseMonthStringProperty(new Boolean(useMS.isSelected()));
    }
  
private voidchangeStyleProperty(java.lang.Integer newValue)

    Integer currentStyle = new Integer(bean.getStyle());
    bean.setStyle(newValue.intValue());
    if(pcs != null)
      pcs.firePropertyChange("style", currentStyle, newValue);
  
private voidchangeUseMonthStringProperty(java.lang.Boolean newValue)

    Boolean currentStyle = new Boolean(bean.getUseMonthString());
    bean.setUseMonthString(newValue.booleanValue());
    if(pcs != null)
      pcs.firePropertyChange("useMonthString", currentStyle, newValue);

  
public java.awt.InsetsgetInsets()

 return new Insets(5,5,5,5); 
private voidjbInit()

    this.setLayout(borderLayout1);
    southPanel.setLayout(fL1);
    fL1.setAlignment(2);
    gL1.setColumns(1);
    gL1.setHgap(5);
    apply.setText("Apply");
    apply.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        apply_actionPerformed(e);
      }
    });
    title.setText("Date Bean Customizer");
    useMS.setText("Use Month String");
    revert.setText("Revert");
    revert.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        revert_actionPerformed(e);
      }
    });
    centerPanel.setLayout(bL2);
    buttonPanel.setLayout(gL1);
    this.add(southPanel, BorderLayout.SOUTH);
    southPanel.add(buttonPanel, null);
    buttonPanel.add(apply, null);
    buttonPanel.add(revert, null);
    this.add(title, BorderLayout.NORTH);
    this.add(centerPanel, BorderLayout.CENTER);
    centerPanel.add(choices, BorderLayout.CENTER);
    centerPanel.add(eastPanel, BorderLayout.EAST);
    eastPanel.add(useMS, null);
  
public voidremovePropertyChangeListener(java.beans.PropertyChangeListener parm1)

    if(pcs != null)
      pcs.removePropertyChangeListener(parm1);
  
voidrevert_actionPerformed(java.awt.event.ActionEvent e)

    changeStyleProperty(oldStyle);
    choices.setSelectedItem(oldStyle.intValue());

    changeUseMonthStringProperty(oldUseMonthString);
    useMS.setSelected(oldUseMonthString.booleanValue());
  
public voidsetObject(java.lang.Object in)

    // jbInit() is fired from here instead of the constructor because it
    // is assumed in the Beans Spec that setObject() is called first and is
    // handled before any re-parenting of the Customizer by an IDE
    try { jbInit(); } catch (Exception e) { e.printStackTrace(); }

    if(in instanceof DateBean){
      bean = (DateBean)in;

      // capture old state values for use by revert
      oldStyle = new Integer(bean.getStyle());
      oldUseMonthString = new Boolean(bean.getUseMonthString());

      // seed the customizer with copies the right settings for the current copy
      choices.setSelectedItem(bean.getStyle());
      useMS.setSelected(bean.getUseMonthString());
      }
    else
      System.out.println("how'd that happen?");