public void actionPerformed(ActionEvent ae) {
   String cmd = ae.getActionCommand();
   if (JOkCancelPanel.OK.equals(cmd)) {
     // update evaluator
     evaluator.name = tfName.getText();
     evaluator.type = (byte) cbType.getSelectedIndex();
     evaluator.ignoreDiagonals = cbDiagonals.isSelected();
     evaluator.investments = (byte) cbInvestment.getSelectedIndex();
     evaluator.orgFile = orgFile;
     setVisible(false);
   } else if (JOkCancelPanel.CANCEL.equals(cmd)) {
     // don't update evaluator
     setVisible(false);
   } else if (CMD_CHOOSE_FILE.equals(cmd)) {
     // get a file dialog
     JFrame f = new JFrame();
     JFileChooser jfc = Application.getFileChooser();
     int res = jfc.showOpenDialog(f);
     Application.setWorkingDirectory(jfc.getCurrentDirectory());
     if (res == JFileChooser.CANCEL_OPTION) {
       return;
     }
     orgFile = jfc.getSelectedFile();
     lOrgFileName.setText("File: " + orgFile.getName());
   }
 }
Beispiel #2
0
 /* The following two methods activate the scoring buttons. */
 protected void clickScoreCell(int code, Match m) {
   Player p = m.getCurrentPlayer();
   int gameNum = m.getGameNum();
   Evaluator eval = new Evaluator();
   eval.evaluate(db, code, p, gameNum);
   show_scoreSheet(p, gameNum);
   disable_AllCells();
   rollButton.setEnabled(false);
   nextPlayerJButton.setEnabled(true);
 }
Beispiel #3
0
  /**
   * This method is called if the applet is run as an standalone program. It creates a frame for the
   * applet and adds the applet to that frame.
   */
  public static void main(String args[]) {
    Evaluator a = new Evaluator();
    a.init();
    a.start();

    Frame f = new Frame("Evaluator");
    f.add("Center", a);
    f.setSize(400, 200);
    f.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    //		f.show();
    f.setVisible(true);
  }
    public Editor(JFrame parent, Evaluator evaluator) {
      super(parent, "Structure");
      setModal(true);
      this.evaluator = evaluator;

      getContentPane().setLayout(new BorderLayout());

      // name and type
      JPanel pNameType = new JPanel(new GridLayout(2, 1));
      JPanel pName = new JPanel(new BorderLayout());
      pName.add(new JLabel("Name: "), BorderLayout.WEST);
      tfName = new JTextField(evaluator.getName());
      pName.add(tfName, BorderLayout.CENTER);
      pNameType.add(pName);
      JPanel pType = new JPanel(new BorderLayout());
      pType.add(new JLabel("Type: "), BorderLayout.WEST);
      cbType = new JComboBox(types);
      cbType.setEditable(false);
      cbType.setSelectedIndex(evaluator.type);
      cbType.addItemListener(this);
      pType.add(cbType, BorderLayout.CENTER);
      pNameType.add(pType);
      getContentPane().add(pNameType, BorderLayout.NORTH);

      // options panel
      this.clOptions = new CardLayout();
      this.pOptions = new JPanel(clOptions);

      JPanel pConstraintRoot = new JPanel(new BorderLayout());
      Box pConstraintOpts = new Box(BoxLayout.Y_AXIS);
      JPanel pDiagonals = new JPanel(new BorderLayout());
      cbDiagonals = new JCheckBox("Ignore Diagonals", evaluator.ignoreDiagonals);
      pDiagonals.add(cbDiagonals, BorderLayout.CENTER);
      pConstraintOpts.add(pDiagonals);
      JPanel pInvestment = new JPanel(new BorderLayout());
      pInvestment.add(new Label("Investments "), BorderLayout.WEST);
      cbInvestment = new JComboBox(investments);
      cbInvestment.setEditable(false);
      cbInvestment.setSelectedIndex(evaluator.investments);
      pInvestment.add(cbInvestment, BorderLayout.CENTER);
      pConstraintOpts.add(pInvestment);
      JPanel pOrganization = new JPanel(new GridLayout(2, 1));
      lOrgFileName = new JLabel("File: <none selected>");
      pOrganization.add(lOrgFileName);
      JPanel pFileChoose = new JPanel(new FlowLayout(FlowLayout.CENTER));
      JButton bFileChoose = new JButton("Choose File...");
      bFileChoose.addActionListener(this);
      bFileChoose.setActionCommand(CMD_CHOOSE_FILE);
      pFileChoose.add(bFileChoose);
      pOrganization.add(pFileChoose);
      pConstraintOpts.add(pOrganization);
      pConstraintRoot.add(pConstraintOpts, BorderLayout.NORTH);
      pOptions.add(pConstraintRoot, types[CONSTRAINT]);

      JPanel pSizeRoot = new JPanel(new BorderLayout());
      pOptions.add(pSizeRoot, types[EFFECTIVE_SIZE]);
      clOptions.first(pOptions);

      getContentPane().add(BorderLayout.CENTER, pOptions);

      // ok/cancel panel
      JOkCancelPanel okCancelPanel = new JOkCancelPanel();
      okCancelPanel.addActionListener(this);
      getContentPane().add(BorderLayout.SOUTH, okCancelPanel);

      pack();
    }