FileDocCategorySizeDatePackage
OpenAccountDialog.javaAPI DocExample2869Sun Mar 02 22:07:12 GMT 1997bank.client

OpenAccountDialog

public class OpenAccountDialog extends Dialog implements ActionListener, TextListener

Fields Summary
private Label
id_label
private TextField
id_field
private Button
ok_button
private Button
cancel_button
Constructors Summary
public OpenAccountDialog(Frame parent, boolean modal)

        super(parent, modal);
        setTitle("Open Customer Accounts");
        setLayout(null);
        addNotify();
        resize(insets().left + insets().right + 309,insets().top +
               insets().bottom + 109);
        setBackground(new Color(12632256));
        { // ID
            id_label = new Label("Customer ID:",Label.RIGHT);
            id_label.reshape(insets().left + 24,insets().top + 12,100,24);
            add(id_label);
            id_field = new TextField();
            id_field.addTextListener(this);
            id_field.reshape(insets().left + 144,insets().top + 12,100,24);
            add(id_field);
        }
        { // buttons
            ok_button = new Button("OK");
            ok_button.addActionListener(this);
            ok_button.reshape(insets().left + 72,insets().top + 60,60,24);
            ok_button.enable(false);
            add(ok_button);
            cancel_button = new Button("Cancel");
            cancel_button.addActionListener(this);
            cancel_button.reshape(insets().left + 156,insets().top + 60,60,24);
            add(cancel_button);
        }
    
Methods Summary
public synchronized voidactionPerformed(java.awt.event.ActionEvent event)

        hide();
        if( event.getSource() == ok_button ) {
            int id;
            
            try {
                BankClient frame = (BankClient)getParent();
                
                id = Integer.parseInt(id_field.getText());
                frame.loadCustomer(id);
            }
            catch( NumberFormatException e ) {// this should not happen
                e.printStackTrace();
            }
        }
    
public synchronized voidtextValueChanged(java.awt.event.TextEvent event)

        String txt = id_field.getText();
        int id;

        if( txt.length() < 1 ) {
            ok_button.enable(false);
            return;
        }
        try {
            id = Integer.parseInt(txt);
            ok_button.enable(true);
        }
        catch( NumberFormatException e ) {
            ok_button.enable(false);
        }