예제 #1
0
  public DemoCheckBox() {

    // Set title
    setTitle("Check Box and Radio Button Demo");

    // Mark the default check box and radio button
    cbDriver.setSelected(true);
    rbSingle.setSelected(true);

    // Add the radio buttons to a button group
    ButtonGroup bgMaritalStatus = new ButtonGroup();
    bgMaritalStatus.add(rbMarried);
    bgMaritalStatus.add(rbSingle);
    bgMaritalStatus.add(rbDivorced);

    // Create container and layout
    Container contentPane = getContentPane();
    EasyGridLayout layout = new EasyGridLayout();
    contentPane.setLayout(layout);

    // Set constraints
    layout.setConstraints(lbCheck, 1, 1, 1, 1);
    layout.setConstraints(lbRadio, 2, 1, 1, 1);
    layout.setConstraints(tfCheck, 1, 2, 1, 1);
    layout.setConstraints(tfRadio, 2, 2, 1, 1);
    layout.setConstraints(cbDriver, 3, 1, 1, 1);
    layout.setConstraints(cbPassenger, 4, 1, 1, 1);
    layout.setConstraints(rbMarried, 3, 2, 1, 1);
    layout.setConstraints(rbSingle, 4, 2, 1, 1);
    layout.setConstraints(rbDivorced, 5, 2, 1, 1);
    layout.setConstraints(btGetStates, 6, 1, 2, 1);

    // Add controls to container
    contentPane.add(lbCheck);
    contentPane.add(lbRadio);
    contentPane.add(tfCheck);
    contentPane.add(tfRadio);
    contentPane.add(cbDriver);
    contentPane.add(cbPassenger);
    contentPane.add(rbMarried);
    contentPane.add(rbSingle);
    contentPane.add(rbDivorced);
    contentPane.add(btGetStates);

    // Specify listeners
    btGetStates.addActionListener(new GetStatesListener());
    addWindowListener(new MyWindowAdapter());
  }
예제 #2
0
  public ERView() {

    // Set title and initialize
    setTitle("Emergency Room");
    erModel = new ERModel(this, 3);
    ButtonGroup bgCondition = new ButtonGroup();
    bgCondition.add(cbFair);
    bgCondition.add(cbCritical);
    bgCondition.add(cbSerious);
    cbFair.setSelected(true);

    // Create container and layout
    Container contentPane = getContentPane();
    EasyGridLayout layout = new EasyGridLayout();
    contentPane.setLayout(layout);

    // Set constraints
    JScrollPane spOutput = new JScrollPane(taOutput);
    layout.setConstraints(lbName, 1, 1, 1, 1);
    layout.setConstraints(tfName, 1, 2, 1, 1);
    layout.setConstraints(cbFair, 2, 1, 1, 1);
    layout.setConstraints(cbCritical, 3, 1, 1, 1);
    layout.setConstraints(cbSerious, 4, 1, 1, 1);
    layout.setConstraints(btSchedule, 2, 2, 1, 1);
    layout.setConstraints(btNext, 3, 2, 1, 1);
    layout.setConstraints(btAll, 4, 2, 1, 1);
    layout.setConstraints(spOutput, 5, 1, 2, 1);

    // Add controls to container
    contentPane.add(lbName);
    contentPane.add(tfName);
    contentPane.add(cbFair);
    contentPane.add(cbCritical);
    contentPane.add(cbSerious);
    contentPane.add(btSchedule);
    contentPane.add(btNext);
    contentPane.add(btAll);
    contentPane.add(spOutput);

    // Specify listeners
    btSchedule.addActionListener(new ButtonListener());
    btNext.addActionListener(new ButtonListener());
    btAll.addActionListener(new ButtonListener());
    addWindowListener(new MyWindowAdapter());
  }