Beispiel #1
0
  private AbstractButton createButton() {
    final String action = getAction();

    final AbstractButton button;
    if (toggleButton) {
      button = new CToggleButton(this);
      button.setSelectedIcon(iconPressed);
    } else {
      final CButton cbutton = new CButton(this);
      if (buttonDefaultCapable != null) {
        cbutton.setDefaultCapable(buttonDefaultCapable);
      }
      button = cbutton;
    }

    button.setName(action);
    button.setIcon(icon);
    button.setText(buttonText);

    button.setActionCommand(action);
    button.setMargin(buttonInsets);
    button.setSize(BUTTON_SIZE);

    //
    // Action
    button.getActionMap().put(action, this);

    //
    // Update button state from this action
    updateButtonPressedState(button);
    replaceAcceleratorKey(button, getAccelerator(), null);

    return button;
  }
 private void prepareButton(
     AbstractButton button,
     String actionKey,
     String buttonLabelText,
     String toolTipText,
     URL url) {
   Action action =
       new AbstractAction(actionKey) {
         public void actionPerformed(ActionEvent evt) {}
       };
   button.setAction(action);
   button.setActionCommand(actionKey);
   button.setIcon(new ImageIcon(url));
   button.setText(buttonLabelText);
   button.setToolTipText(toolTipText);
   button.addActionListener(this);
 }
Beispiel #3
0
  /**
   * Descripción de Método
   *
   * @param button
   * @param cmd
   * @param file
   */
  private void setButton(AbstractButton button, String cmd, String file) {
    String text = Msg.getMsg(m_ctx, cmd);

    button.setToolTipText(text);
    button.setActionCommand(cmd);

    //

    ImageIcon ii24 = Env.getImageIcon(file + "24.gif");

    if (ii24 != null) {
      button.setIcon(ii24);
    }

    button.setMargin(AppsAction.BUTTON_INSETS);
    button.setPreferredSize(AppsAction.BUTTON_SIZE);
    button.addActionListener(this);
  } // setButton
  /** Creates the And/Or radio buttons, their button group and a panel for them */
  private JComponent createLogicalButtons() {

    andButton = new JRadioButton(I18N.getString("AttributeResearchPanel.logicalAnd"));
    andButton.setBorder(BorderFactory.createEmptyBorder(2, 10, 2, 10));
    andButton.setActionCommand(logicalRelationships[0]);
    andButton.doClick();

    orButton = new JRadioButton(I18N.getString("AttributeResearchPanel.logicalOr"));
    orButton.setBorder(BorderFactory.createEmptyBorder(2, 10, 5, 10));
    orButton.setActionCommand(logicalRelationships[1]);

    ActionListener bal =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JRadioButton rb = (JRadioButton) e.getSource();
            currentRelationship = rb.getActionCommand();
          }
        };
    andButton.addActionListener(bal);
    orButton.addActionListener(bal);

    ButtonGroup bg = new ButtonGroup();
    bg.add(andButton);
    bg.add(orButton);
    JPanel b = new JPanel();
    LayoutManager lm = new BoxLayout(b, BoxLayout.PAGE_AXIS);
    b.setLayout(lm);
    b.setAlignmentX(Component.LEFT_ALIGNMENT);
    b.setBorder(
        BorderFactory.createTitledBorder(I18N.getString("AttributeResearchPanel.logicalLink")));

    // add a bit of space
    b.add(Box.createRigidArea(new Dimension(20, 10)));
    b.add(andButton);
    b.add(Box.createRigidArea(new Dimension(20, 10)));
    b.add(orButton);
    b.setPreferredSize(new Dimension(150, 100));

    return b;
  }
  public HexagonViewerAdvance(String[] args) {
    FormPanel panel = new FormPanel("ise/ct/plugins/HexagonViewerForm.jfrm");
    super.add(panel);

    // add references to configurable components on form
    worldMap = panel.getComponentByName("HexagonViewerImage");

    statusTitle = panel.getComponentByName("StatusTitle");
    fileTitle = panel.getLabel("FileTitle");
    fileProgress = panel.getProgressBar("FileProgress");
    iterationTitle = panel.getLabel("IterationTitle");
    iterationProgress = panel.getProgressBar("IterationProgress");
    cycleTitle = panel.getLabel("CycleTitle");
    cycleProgress = panel.getProgressBar("CycleProgress");

    currentTitle = panel.getComponentByName("CurrentTitle");
    commentTitle = panel.getLabel("CommentTitle");
    commentLabel = panel.getLabel("CommentLabel");
    phaseTitle = panel.getLabel("PhaseTitle");
    phaseLabel = panel.getLabel("PhaseLabel");
    turnTitle = panel.getLabel("TurnTitle");
    turnProgress = panel.getProgressBar("TurnProgress");

    showPaths = panel.getCheckBox("ShowPaths");
    showPaths.setActionCommand("showpaths");
    showPaths.setSelected(true);
    doShowPaths = true;
    showPaths.addItemListener(this);

    playButton = panel.getButton("PlayButton");
    stepButton = panel.getButton("StepButton");
    endButton = panel.getButton("EndButton");
    playButton.setActionCommand("play");
    stepButton.setActionCommand("step");
    endButton.setActionCommand("end");
    playButton.addItemListener(this);
    stepButton.addItemListener(this);
    endButton.addItemListener(this);
    playButton.setEnabled(true);
    stepButton.setEnabled(true);
    endButton.setEnabled(true);

    playButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            JButton s = (JButton) ae.getSource();
            if (s.getText().equalsIgnoreCase("Pause")) {
              s.setText("Play");
              Simulator.controlPanel.paused = true;
              Simulator.controlPanel.step = false;
            } else {
              s.setText("Pause");
              Simulator.controlPanel.paused = false;
              Simulator.controlPanel.step = false;
            }
          }
        });

    stepButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            playButton.setText("Play");
            Simulator.controlPanel.paused = true;
            Simulator.controlPanel.step = true;
          }
        });

    endButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            Simulator.experimentLength = Simulator.cycle;
            Simulator.controlPanel.paused = false;
          }
        });

    cycleTitle = panel.getLabel("CycleTitle");
    phaseTitle = panel.getLabel("PhaseTitle");
    inspectorTitle = panel.getLabel("InspectorTitle");
    cycleProgress = panel.getProgressBar("CycleProgress");

    seperator1 = panel.getComponentByName("Seperator1");
    seperator2 = panel.getComponentByName("Seperator2");
    seperator3 = panel.getComponentByName("Seperator3");
    seperator4 = panel.getComponentByName("Seperator4");

    // inspector JScrollPane and JTree
    inspectorScrollPane = panel.getComponentByName("InspectorScrollPane");
    inspectorTree = new JTree();
    inspectorTree.setRowHeight(iconSize);
    inspectorTree.setCellRenderer(
        new DefaultTreeCellRenderer() {
          private static final long serialVersionUID = 1L;

          public Icon getLeafIcon() {
            Icon icon;
            if (this.getText().equals(AUCTION_NAME)) {
              icon = new ImageIcon(createAuctionIcon(iconSize, iconSize));
            } else {
              icon = new ImageIcon(createAgentIcon(this.getText(), iconSize, iconSize));
            }
            return icon;
          }
        });

    getRootPane().setDefaultButton((JButton) playButton);
    super.addComponentListener(this); // resize events etc.

    // set the parameters this frame
    setSize(600, 500);
    setLocation(200, 100);
    setTitle("Hexagon Viewer Advance");
    setVisible(true);
  }