コード例 #1
0
    /**
     * Updates the <code>Toolbar</code> represented by this folder.
     *
     * @param cookies array of instance cookies for the folder
     * @return the updated <code>ToolbarPool</code> representee
     */
    protected Object createInstance(InstanceCookie[] cookies)
        throws java.io.IOException, ClassNotFoundException {
      // refresh the toolbar's content
      getToolbar().removeAll();
      for (int i = 0; i < cookies.length; i++) {
        try {
          Object obj = cookies[i].instanceCreate();
          if (obj instanceof Presenter.Toolbar) {
            obj = ((Presenter.Toolbar) obj).getToolbarPresenter();
          }
          if (obj instanceof Component) {
            Component comp = (Component) obj;
            getToolbar().add(comp);
          }
        } catch (java.io.IOException ex) {
        } catch (ClassNotFoundException ex) {
        }
      }

      // invalidate the toolbar and its parent
      toolbar.invalidate();
      java.awt.Container parent = toolbar.getParent();
      if (parent != null) {
        parent.validate();
        parent.repaint();
      }
      return toolbar;
    }
コード例 #2
0
  public java.awt.Container createControlPanel() {
    java.awt.Container panel2 = Box.createVerticalBox();
    panel2 = super.createControlPanel();

    brainPlay = new JCheckBox("Brain Play", false);
    if (testMode) brainPlay.setSelected(true);
    panel2.add(brainPlay);

    JPanel row2 = new JPanel();

    // ADVERSARY slider
    row2.add(Box.createVerticalStrut(12));
    row2.add(new JLabel("Adversary:"));

    adversary = new JSlider(0, 100, 0); // min, max, current
    adversary.setPreferredSize(new Dimension(100, 15));
    row2.add(adversary);

    JPanel text = new JPanel();
    text.add(adStat = new JLabel(adversaryOff));
    panel2.add(text);

    panel2.add(row2);

    JPanel row3 = new JPanel();

    // Mr. Happy slider
    row3.add(Box.createVerticalStrut(12));
    row3.add(new JLabel("CELAB"));

    happy = new JSlider(0, 100, 0); // min, max, current
    happy.setPreferredSize(new Dimension(100, 15));
    row3.add(happy);

    JPanel text2 = new JPanel();
    text2.add(adHappy = new JLabel(happyOff));
    panel2.add(text2);

    panel2.add(row3);

    return (panel2);
  }