FileDocCategorySizeDatePackage
CustomerPanel.javaAPI DocExample3571Sun Mar 02 22:05:04 GMT 1997bank.client

CustomerPanel

public class CustomerPanel extends imaginary.gui.PersistentPanel implements RemotePanel

Fields Summary
private AccountSetPanel
accounts_panel
private TextField
id_field
private Label
id_label
private TextField
name_field
private Label
name_label
Constructors Summary
public CustomerPanel(imaginary.persist.RemoteLockHolder h)


         
        super(h);
        createComponents();
    
public CustomerPanel(imaginary.persist.RemoteLockHolder h, imaginary.persist.RemotePersistent p)

        super(h, p);
        createComponents();
    
Methods Summary
protected voidcleanUp()

        RemoteObservable o = getObserved();

        if( o != null ) {
            try {
                o.deleteObserver(this);
            }
            catch( RemoteException e ) {
            }
        }
        accounts_panel.cleanUp();
    
protected voidcreateComponents()

        RemoteCustomer c = (RemoteCustomer)getObserved();
        
        setLayout(null);
        { // ID
            id_label.reshape(insets().left + 12,insets().top + 24,88,24);
            add(id_label);
            id_field.setEditable(false);
            id_field.reshape(insets().left + 108,insets().top + 24,120,24);
            add(id_field);
        }
        { // Name
            name_label.reshape(insets().left + 36,insets().top + 72,64,24);
            add(name_label);
            name_field = new TextField();
            name_field.setEditable(false);
            name_field.reshape(insets().left + 108,insets().top + 72,204,24);
            add(name_field);
        }
        { // Accounts and buttons
            Button[] b = new Button[2];
            
            b[0] = new Button(">>");
            b[1] = new Button("<<");

            if( c == null ) {
                accounts_panel = new AccountSetPanel(b, getLockHolder());
            }
            else {
                accounts_panel = new AccountSetPanel(b, getLockHolder(),
                                                     c.getAccountSet());
            }
            accounts_panel.reshape(insets().left + 12,insets().top + 120, 348,
                                   120);
            add(accounts_panel);
            b[0].reshape(insets().left + 384,insets().top + 144,36,24);
            add(b[0]);
            b[1].reshape(insets().left + 384,insets().top + 180,36,24);
            add(b[1]);
        }
        if( c != null ) {
            observeChange();
        }
    
public bank.server.RemoteAccountgetSelectedAccount()

        return accounts_panel.getSelectedAccount();
    
public voidobserveChange()

        RemoteCustomer c = (RemoteCustomer)getObserved();

        try {
            id_field.setText("" + c.getId());
            name_field.setText(c.getLastName() + ", " + c.getFirstName());
        }
        catch( RemoteException e ) {
            e.printStackTrace();
            id_field.setText("");
            name_field.setText("");
        }