Example #1
0
 protected void setSimpleDisplayUpdate() {
   view().setDisplayUpdate(new SimpleUpdateStrategy());
   fUpdateButton.setText("Simple Update");
   fSimpleUpdate = true;
 }
Example #2
0
 protected void setBufferedDisplayUpdate() {
   view().setDisplayUpdate(new BufferedUpdateStrategy());
   fUpdateButton.setText("Buffered Update");
   fSimpleUpdate = false;
 }
Example #3
0
  /**
   * Creates the buttons shown in the buttons panel. Override to add additional buttons.
   *
   * @param panel the buttons panel.
   */
  protected void createButtons(JPanel panel) {
    panel.add(new Filler(24, 20));

    JComboBox drawingChoice = new JComboBox();
    drawingChoice.addItem(fgUntitled);

    String param = getParameter("DRAWINGS");
    if (param == null) {
      param = "";
    }
    StringTokenizer st = new StringTokenizer(param);
    while (st.hasMoreTokens()) {
      drawingChoice.addItem(st.nextToken());
    }
    // offer choice only if more than one
    if (drawingChoice.getItemCount() > 1) {
      panel.add(drawingChoice);
    } else {
      panel.add(new JLabel(fgUntitled));
    }

    drawingChoice.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              loadDrawing((String) e.getItem());
            }
          }
        });

    panel.add(new Filler(6, 20));

    JButton button;
    button = new CommandButton(new DeleteCommand("Delete", this));
    panel.add(button);

    button = new CommandButton(new DuplicateCommand("Duplicate", this));
    panel.add(button);

    button = new CommandButton(new GroupCommand("Group", this));
    panel.add(button);

    button = new CommandButton(new UngroupCommand("Ungroup", this));
    panel.add(button);

    button = new JButton("Help");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            showHelp();
          }
        });
    panel.add(button);

    fUpdateButton = new JButton("Simple Update");
    fUpdateButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            if (fSimpleUpdate) {
              setBufferedDisplayUpdate();
            } else {
              setSimpleDisplayUpdate();
            }
          }
        });
  }