示例#1
0
文件: Cent.java 项目: Auzzy/personal
  public void init() {
    setBackground(Color.white);
    addKeyListener(this);
    img = createImage(dimX, dimY);
    buf = img.getGraphics();
    all = getGraphics();

    mode = new CheckboxGroup();
    end = new Checkbox("ENDURANCE", mode, false);
    reg = new Checkbox("CLASSIC", mode, true);
    add(end);
    add(reg);
    end.addKeyListener(this);
    reg.addKeyListener(this);

    who = new TextField();
    add(who);
    who.addActionListener(this);
    who.addKeyListener(this);
    who.hide();

    hard = new TextField();
    add(hard);
    hard.addActionListener(this);
    hard.addKeyListener(this);
    hard.hide();

    key[0] = KeyEvent.VK_LEFT;
    key[1] = KeyEvent.VK_UP;
    key[2] = KeyEvent.VK_RIGHT;
    key[3] = KeyEvent.VK_DOWN;

    lev[0] = new Color(0, 0, 75); // dark blue
    lev[1] = Color.red;
    lev[2] = Color.blue;
    lev[3] = Color.magenta;
    lev[4] = Color.yellow;
    lev[5] = new Color(0, 75, 0); // dark green
    lev[6] = Color.orange;
    lev[7] = Color.cyan;
    lev[8] = Color.pink;
    lev[9] = new Color(100, 0, 0); // dark red

    setup();
    highScores();
  }
示例#2
0
 /**
  * Adds a checkbox; does not make it recordable if isPreview is true. With isPreview true, the
  * checkbox can be referred to as previewCheckbox from hereon.
  */
 private void addCheckbox(String label, boolean defaultValue, boolean isPreview) {
   String label2 = label;
   if (label2.indexOf('_') != -1) label2 = label2.replace('_', ' ');
   if (checkbox == null) {
     checkbox = new Vector(4);
     c.insets = getInsets(15, 20, 0, 0);
   } else c.insets = getInsets(0, 20, 0, 0);
   c.gridx = 0;
   c.gridy = y;
   c.gridwidth = 2;
   c.anchor = GridBagConstraints.WEST;
   Checkbox cb = new Checkbox(label2);
   grid.setConstraints(cb, c);
   cb.setState(defaultValue);
   cb.addItemListener(this);
   cb.addKeyListener(this);
   add(cb);
   checkbox.addElement(cb);
   // ij.IJ.write("addCheckbox: "+ y+" "+cbIndex);
   if (!isPreview && (Recorder.record || macro)) // preview checkbox is not recordable
   saveLabel(cb, label);
   if (isPreview) previewCheckbox = cb;
   y++;
 }