/** Listener to handle button actions */
 public void actionPerformed(ActionEvent e) {
   // Check if the user changed the service filter option
   if (e.getSource() == service_box) {
     service_list.setEnabled(service_box.isSelected());
     service_list.clearSelection();
     remove_service_button.setEnabled(false);
     add_service_field.setEnabled(service_box.isSelected());
     add_service_field.setText("");
     add_service_button.setEnabled(false);
   }
   // Check if the user pressed the add service button
   if ((e.getSource() == add_service_button) || (e.getSource() == add_service_field)) {
     String text = add_service_field.getText();
     if ((text != null) && (text.length() > 0)) {
       service_data.addElement(text);
       service_list.setListData(service_data);
     }
     add_service_field.setText("");
     add_service_field.requestFocus();
   }
   // Check if the user pressed the remove service button
   if (e.getSource() == remove_service_button) {
     Object[] sels = service_list.getSelectedValues();
     for (int i = 0; i < sels.length; i++) {
       service_data.removeElement(sels[i]);
     }
     service_list.setListData(service_data);
     service_list.clearSelection();
   }
 }
  private JPanel createDynamicCenterPanel(PrimitiveForm primitiveForm, DOTProperty property) {
    final JTable theTable = new JTable();
    PrimitiveFormPropertyPair pfpPair =
        new PrimitiveFormPropertyPair(primitiveForm.getName(), property);
    _dynamicTables.put(pfpPair, theTable);
    DOTPoint dotPoint = (DOTPoint) _dotDefinitionDialogFrame.getScratchDisplayObjectType();
    final DynamicDOTItemManager tableModel =
        (DynamicDOTItemManager) dotPoint.getTableModel(primitiveForm, property);
    theTable.setModel(tableModel);

    class NumberComparator implements Comparator<Number> {

      public int compare(Number o1, Number o2) {
        final double d1 = o1.doubleValue();
        final double d2 = o2.doubleValue();
        if (d1 < d2) {
          return -1;
        }
        if (d1 == d2) {
          return 0;
        }
        return 1;
      }
    }
    TableRowSorter<DynamicDOTItemManager> tableRowSorter =
        new TableRowSorter<DynamicDOTItemManager>();
    tableRowSorter.setModel(tableModel);
    tableRowSorter.setComparator(4, new NumberComparator());
    tableRowSorter.setComparator(5, new NumberComparator());
    theTable.setRowSorter(tableRowSorter);

    JButton newDOTItemButton = new JButton("Neue Zeile");
    newDOTItemButton.setEnabled(_dotDefinitionDialogFrame.isEditable());
    JButton deleteDOTItemButton = new JButton("Zeile löschen");
    deleteDOTItemButton.setEnabled(false);
    JButton showConflictsButton = new JButton("Zeige Konflikte");

    addButtonListeners(
        primitiveForm, property, newDOTItemButton, deleteDOTItemButton, showConflictsButton);
    addListSelectionListener(theTable, deleteDOTItemButton);

    JPanel dotButtonsPanel = new JPanel();
    dotButtonsPanel.setLayout(new SpringLayout());

    dotButtonsPanel.add(newDOTItemButton);
    dotButtonsPanel.add(deleteDOTItemButton);
    dotButtonsPanel.add(showConflictsButton);

    dotButtonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
    SpringUtilities.makeCompactGrid(dotButtonsPanel, 1, 5, 20);

    JPanel thePanel = new JPanel();
    thePanel.setLayout(new SpringLayout());
    thePanel.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.BLACK));
    thePanel.add(new JScrollPane(theTable));
    thePanel.add(dotButtonsPanel);
    SpringUtilities.makeCompactGrid(thePanel, 2, 20, 5);

    return thePanel;
  }
 /**
  * Reset the image rollover icon as enabled/disabled.
  *
  * @param enabled, the status to draw the image rollover icon for.
  */
 public void updateImageRollover(boolean enabled) {
   if (enabled) {
     pbImageRollover.setIcon(UIImages.get(IMAGE_ROLLOVER_ICON));
   } else {
     pbImageRollover.setIcon(UIImages.get(IMAGE_ROLLOVEROFF_ICON));
   }
 }
 public CFSecuritySwingISOCurrencyAskDeleteJPanel(
     ICFSecuritySwingSchema argSchema, ICFSecurityISOCurrencyObj argFocus) {
   super();
   final String S_ProcName = "construct-schema-focus";
   if (argSchema == null) {
     throw CFLib.getDefaultExceptionFactory()
         .newNullArgumentException(getClass(), S_ProcName, 1, "argSchema");
   }
   // argFocus is optional; focus may be set later during execution as
   // conditions of the runtime change.
   swingSchema = argSchema;
   swingFocus = argFocus;
   // Construct the various objects
   textAreaMessage = new JTextArea("Are you sure you want to delete this ISO Currency?");
   actionOk = new ActionOk();
   actionCancel = new ActionCancel();
   buttonOk = new JButton(actionOk);
   buttonCancel = new JButton(actionCancel);
   attrJPanel = argSchema.getISOCurrencyFactory().newAttrJPanel(argFocus);
   scrollPane = new CFHSlaveJScrollPane(attrJPanel);
   // Lay out the widgets
   setSize(1024, 480);
   Dimension min = new Dimension(480, 300);
   setMinimumSize(min);
   add(textAreaMessage);
   textAreaMessage.setBounds(0, 0, 1024, 50);
   int xparts = (768 - (2 * 125)) / 3;
   add(buttonOk);
   buttonOk.setBounds(xparts, 55, 125, 40);
   add(buttonCancel);
   buttonCancel.setBounds(xparts + 125 + xparts, 55, 125, 40);
   add(scrollPane);
   scrollPane.setBounds(0, 100, 1024, 480 - 100);
 }
Example #5
0
  public PostTestFrame() {
    setTitle("PostTest");

    northPanel = new JPanel();
    add(northPanel, BorderLayout.NORTH);
    northPanel.setLayout(new GridLayout(0, 2));
    northPanel.add(new JLabel("Host: ", SwingConstants.TRAILING));
    final JTextField hostField = new JTextField();
    northPanel.add(hostField);
    northPanel.add(new JLabel("Action: ", SwingConstants.TRAILING));
    final JTextField actionField = new JTextField();
    northPanel.add(actionField);
    for (int i = 1; i <= 8; i++) northPanel.add(new JTextField());

    final JTextArea result = new JTextArea(20, 40);
    add(new JScrollPane(result));

    JPanel southPanel = new JPanel();
    add(southPanel, BorderLayout.SOUTH);
    JButton addButton = new JButton("More");
    southPanel.add(addButton);
    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            northPanel.add(new JTextField());
            northPanel.add(new JTextField());
            pack();
          }
        });

    JButton getButton = new JButton("Get");
    southPanel.add(getButton);
    getButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            result.setText("");
            final Map<String, String> post = new HashMap<String, String>();
            for (int i = 4; i < northPanel.getComponentCount(); i += 2) {
              String name = ((JTextField) northPanel.getComponent(i)).getText();
              if (name.length() > 0) {
                String value = ((JTextField) northPanel.getComponent(i + 1)).getText();
                post.put(name, value);
              }
            }
            new SwingWorker<Void, Void>() {
              protected Void doInBackground() throws Exception {
                try {
                  String urlString = hostField.getText() + "/" + actionField.getText();
                  result.setText(doPost(urlString, post));
                } catch (IOException e) {
                  result.setText("" + e);
                }
                return null;
              }
            }.execute();
          }
        });

    pack();
  }
  /** Simple test program. */
  public static void main(String[] args) {
    final JFrame frame = new JFrame("Testing AddPersonDialog");
    JButton button = new JButton("Click me");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            FamilyTree tree = new FamilyTree();
            AddPersonDialog dialog = new AddPersonDialog(frame, tree);
            dialog.pack();
            dialog.setLocationRelativeTo(frame);
            dialog.setVisible(true);

            Person newPerson = dialog.getPerson();
            if (newPerson != null) {
              tree.addPerson(newPerson);
              PrettyPrinter pretty = new PrettyPrinter(new PrintWriter(System.out, true));
              pretty.dump(tree);
            }
          }
        });
    frame.getContentPane().add(button);

    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(1);
          }
        });
    frame.pack();
    frame.setVisible(true);
  }
  /**
   * Shows given list of reading lists.
   *
   * @param lists lists.
   */
  protected void setReadingLists(ReadingList[] lists) {
    tblReadingLists.setEnabled(lists != null);
    btnAddReadingList.setEnabled(lists != null);
    btnRemoveList.setEnabled(lists != null);

    readingListsModel.setLists(lists);
  }
Example #8
0
 /** Method called by grid component each time a row is selected. */
 public void setLastRow(boolean isLastRecord) {
   lastButton.setEnabled(!isLastRecord);
   nextButton.setEnabled(!isLastRecord);
   nextPgButton.setEnabled(!isLastRecord);
   controlPageNr.setEnabled(true);
   //    controlPageNr.setEnabled(resultSetController.getTotalResultSetLength()!=-1);
 }
Example #9
0
 @Override
 public Component getListCellRendererComponent(
     JList<? extends E> list, E value, int index, boolean isSelected, boolean cellHasFocus) {
   label.setText(Objects.toString(value, ""));
   this.list = list;
   this.index = index;
   if (isSelected) {
     setBackground(list.getSelectionBackground());
     label.setForeground(list.getSelectionForeground());
   } else {
     setBackground(index % 2 == 0 ? EVEN_COLOR : list.getBackground());
     label.setForeground(list.getForeground());
   }
   MutableComboBoxModel m = (MutableComboBoxModel) list.getModel();
   if (index < 0 || m.getSize() - 1 <= 0) {
     setOpaque(false);
     deleteButton.setVisible(false);
     label.setForeground(list.getForeground());
   } else {
     boolean f = index == rolloverIndex;
     setOpaque(true);
     deleteButton.setVisible(true);
     deleteButton.getModel().setRollover(f);
     deleteButton.setForeground(f ? Color.WHITE : list.getForeground());
   }
   return this;
 }
 /** Requests the list of all lost packages */
 private void buttonShowLostActionPerformed(ActionEvent event) {
   this.packages = DataAdapter.getLostPackages();
   this.jListPackages.setListData(new Vector(this.packages));
   jButtonSetLost.setEnabled(false);
   jButtonSetFound.setEnabled(this.packages.size() > 0);
   jListScans.setListData(new Vector());
 }
 /** Stop talking to the server */
 public void stop() {
   if (socket != null) {
     // Close all the streams and socket
     if (out != null) {
       try {
         out.close();
       } catch (IOException ioe) {
       }
       out = null;
     }
     if (in != null) {
       try {
         in.close();
       } catch (IOException ioe) {
       }
       in = null;
     }
     if (socket != null) {
       try {
         socket.close();
       } catch (IOException ioe) {
       }
       socket = null;
     }
   } else {
     // Already stopped
   }
   // Make sure the right buttons are enabled
   start_button.setEnabled(true);
   stop_button.setEnabled(false);
   setStatus(STATUS_STOPPED);
 }
 /** Start talking to the server */
 public void start() {
   String codehost = getCodeBase().getHost();
   if (socket == null) {
     try {
       // Open the socket to the server
       socket = new Socket(codehost, port);
       // Create output stream
       out = new ObjectOutputStream(socket.getOutputStream());
       out.flush();
       // Create input stream and start background
       // thread to read data from the server
       in = new ObjectInputStream(socket.getInputStream());
       new Thread(this).start();
     } catch (Exception e) {
       // Exceptions here are unexpected, but we can't
       // really do anything (so just write it to stdout
       // in case someone cares and then ignore it)
       System.out.println("Exception! " + e.toString());
       e.printStackTrace();
       setErrorStatus(STATUS_NOCONNECT);
       socket = null;
     }
   } else {
     // Already started
   }
   if (socket != null) {
     // Make sure the right buttons are enabled
     start_button.setEnabled(false);
     stop_button.setEnabled(true);
     setStatus(STATUS_ACTIVE);
   }
 }
 /** Show the filter dialog */
 public void showDialog() {
   empty_border = new EmptyBorder(5, 5, 0, 5);
   indent_border = new EmptyBorder(5, 25, 5, 5);
   include_panel =
       new ServiceFilterPanel("Include messages based on target service:", filter_include_list);
   exclude_panel =
       new ServiceFilterPanel("Exclude messages based on target service:", filter_exclude_list);
   status_box = new JCheckBox("Filter messages based on status:");
   status_box.addActionListener(this);
   status_active = new JRadioButton("Active messages only");
   status_active.setSelected(true);
   status_active.setEnabled(false);
   status_complete = new JRadioButton("Complete messages only");
   status_complete.setEnabled(false);
   status_group = new ButtonGroup();
   status_group.add(status_active);
   status_group.add(status_complete);
   if (filter_active || filter_complete) {
     status_box.setSelected(true);
     status_active.setEnabled(true);
     status_complete.setEnabled(true);
     if (filter_complete) {
       status_complete.setSelected(true);
     }
   }
   status_options = new JPanel();
   status_options.setLayout(new BoxLayout(status_options, BoxLayout.Y_AXIS));
   status_options.add(status_active);
   status_options.add(status_complete);
   status_options.setBorder(indent_border);
   status_panel = new JPanel();
   status_panel.setLayout(new BorderLayout());
   status_panel.add(status_box, BorderLayout.NORTH);
   status_panel.add(status_options, BorderLayout.CENTER);
   status_panel.setBorder(empty_border);
   ok_button = new JButton("Ok");
   ok_button.addActionListener(this);
   cancel_button = new JButton("Cancel");
   cancel_button.addActionListener(this);
   buttons = new JPanel();
   buttons.setLayout(new FlowLayout());
   buttons.add(ok_button);
   buttons.add(cancel_button);
   panel = new JPanel();
   panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
   panel.add(include_panel);
   panel.add(exclude_panel);
   panel.add(status_panel);
   panel.add(buttons);
   dialog = new JDialog();
   dialog.setTitle("SOAP Monitor Filter");
   dialog.setContentPane(panel);
   dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
   dialog.setModal(true);
   dialog.pack();
   Dimension d = dialog.getToolkit().getScreenSize();
   dialog.setLocation((d.width - dialog.getWidth()) / 2, (d.height - dialog.getHeight()) / 2);
   ok_pressed = false;
   dialog.show();
 }
 /** Listener to handle service list selection changes */
 public void valueChanged(ListSelectionEvent e) {
   if (service_list.getSelectedIndex() == -1) {
     remove_service_button.setEnabled(false);
   } else {
     remove_service_button.setEnabled(true);
   }
 }
    public void mousePressed(java.awt.event.MouseEvent e) {
      isClick = true;
      JButton b = (JButton) e.getSource();
      // check to see if the target button can be moved
      if (!solved && check(buttons.indexOf(b))) {
        // hide the target button
        b.setVisible(false);

        // Figure out the bounds of the areas where source
        // and target buttons are located
        int menuOffset = getJMenuBar().getHeight();
        dragSourceArea = b.getBounds();
        dragTargetArea = ((JButton) buttons.get(hiddenIndex)).getBounds();
        dragSourceArea.translate(0, menuOffset);
        dragTargetArea.translate(0, menuOffset);

        // setup the bounds of the panel to limit the locations on the drag
        // layer
        panelArea = new Rectangle(0, menuOffset, getJPanel().getWidth(), getJPanel().getHeight());

        // Setup and show the drag button on the upper layer
        getDragButton().setText(b.getText());
        getDragButton().setBounds(dragSourceArea);
        getDragButton().setVisible(true);

        // Offset when repositioning the drag button later
        cursorOffset = new Point(e.getX(), e.getY());
      }
    }
 private void jbInit() throws Exception {
   border1 = BorderFactory.createEmptyBorder(20, 20, 20, 20);
   contentPane.setBorder(border1);
   contentPane.setLayout(borderLayout1);
   controlsPane.setLayout(gridLayout1);
   gridLayout1.setColumns(1);
   gridLayout1.setHgap(10);
   gridLayout1.setRows(0);
   gridLayout1.setVgap(10);
   okButton.setVerifyInputWhenFocusTarget(true);
   okButton.setMnemonic('O');
   okButton.setText("OK");
   buttonsPane.setLayout(flowLayout1);
   flowLayout1.setAlignment(FlowLayout.CENTER);
   messagePane.setEditable(false);
   messagePane.setText("");
   borderLayout1.setHgap(10);
   borderLayout1.setVgap(10);
   this.setTitle("Subscription Authorization");
   this.getContentPane().add(contentPane, BorderLayout.CENTER);
   contentPane.add(controlsPane, BorderLayout.SOUTH);
   controlsPane.add(responsesComboBox, null);
   controlsPane.add(buttonsPane, null);
   buttonsPane.add(okButton, null);
   contentPane.add(messageScrollPane, BorderLayout.CENTER);
   messageScrollPane.getViewport().add(messagePane, null);
 }
Example #17
0
  public IGEgui() {
    start = new JPanel();
    randomizer = new JPanel();

    randomButton = new JButton("Randomize");
    locationButton = new JButton("Randomize");
    locationField = new JTextField(10);
    welcomeL = new JLabel();
    instructL = new JLabel();
    restaurantL = new JLabel();

    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setTitle("Random Restaurant Generator");
    setSize(300, 150);

    locationButton.addActionListener(this);
    randomButton.addActionListener(this);

    welcomeL.setText("Welcome to the Random Restaurant Generator!");
    instructL.setText("Please enter your location (Zip code/City, State)");
    restaurantL.setText("");

    start.add(welcomeL);
    start.add(instructL);
    start.add(locationField);
    start.add(locationButton);
    randomizer.add(restaurantL);
    randomizer.add(randomButton);

    setContentPane(start);
  }
Example #18
0
  protected void setBgColor(Color bgColor) {
    setBackgroundColor(bgColor);

    panelForBtns.setBackground(Util.getBgColor());
    addButton.setBackground(Util.getBgColor());
    removeButton.setBackground(Util.getBgColor());
  }
Example #19
0
 /** Method called by grid component each time a row is selected. */
 public void setFirstRow(boolean isFirstRecord) {
   firstButton.setEnabled(!isFirstRecord);
   prevPgButton.setEnabled(!isFirstRecord);
   prevButton.setEnabled(!isFirstRecord);
   controlPageNr.setEnabled(true);
   //    controlPageNr.setEnabled(resultSetController.getTotalResultSetLength()!=-1);
 }
  public SwingThreadFrame() {
    setTitle("SwingThreadTest");

    final JComboBox combo = new JComboBox();
    combo.insertItemAt(new Integer(Integer.MAX_VALUE), 0);
    combo.setPrototypeDisplayValue(combo.getItemAt(0));
    combo.setSelectedIndex(0);

    JPanel panel = new JPanel();

    JButton goodButton = new JButton("Good");
    goodButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            new Thread(new GoodWorkerRunnable(combo)).start();
          }
        });
    panel.add(goodButton);
    JButton badButton = new JButton("Bad");
    badButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            new Thread(new BadWorkerRunnable(combo)).start();
          }
        });
    panel.add(badButton);
    panel.add(combo);
    add(panel);
    pack();
  }
  /**
   * Builds reading lists tab.
   *
   * @return component.
   */
  protected JComponent buildReadingListsTab() {
    // Wording
    JComponent wording = msg(Strings.message("guide.dialog.readinglists.wording"));

    // Buttons
    Dimension btnSize = new Dimension(20, 20);
    btnAddReadingList.setPreferredSize(btnSize);
    btnRemoveList.setPreferredSize(btnSize);
    FlowLayout layout = new FlowLayout(FlowLayout.LEFT);
    JPanel bbar = new JPanel(layout);
    bbar.add(btnAddReadingList);
    bbar.add(btnRemoveList);
    layout.setHgap(0);
    layout.setVgap(0);

    // Panel
    BBFormBuilder builder = new BBFormBuilder("0:grow");
    builder.setDefaultDialogBorder();

    builder.append(wording);
    builder.appendUnrelatedComponentsGapRow(2);
    builder.appendRow("min:grow");
    builder.append(new JScrollPane(tblReadingLists), 1, CellConstraints.FILL, CellConstraints.FILL);
    builder.append(bbar);

    return builder.getPanel();
  }
Example #22
0
  public AnimationFrame() {
    ArrayComponent comp = new ArrayComponent();
    add(comp, BorderLayout.CENTER);

    final Sorter sorter = new Sorter(comp);

    JButton runButton = new JButton("Run");
    runButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            sorter.setRun();
          }
        });

    JButton stepButton = new JButton("Step");
    stepButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            sorter.setStep();
          }
        });

    JPanel buttons = new JPanel();
    buttons.add(runButton);
    buttons.add(stepButton);
    add(buttons, BorderLayout.NORTH);
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    Thread t = new Thread(sorter);
    t.start();
  }
Example #23
0
  public void JudgeWhoIsWinner() // 判断胜负
      {
    String winner = "";

    if (white == 0) {
      JOptionPane.showMessageDialog(null, "黑方胜!" + black + ":" + white);
      //			JOptionPane.showMessageDialog(null, "游戏结束!用时" + time + "秒");
      submit.setEnabled(false);
      winner = "黑";
    }
    if (black == 0) {
      JOptionPane.showMessageDialog(null, "白方胜!" + white + ":" + black);
      //			JOptionPane.showMessageDialog(null, "游戏结束!用时" + time + "秒");
      submit.setEnabled(false);
      winner = "白";
    }
    if (black + white == 64) {
      if (white > black) {
        JOptionPane.showMessageDialog(null, "白方胜!" + white + ":" + black);
        //				JOptionPane.showMessageDialog(null, "游戏结束!用时" + time + "秒");
        submit.setEnabled(false);
        winner = "白";
      } else if (black > white) {
        JOptionPane.showMessageDialog(null, "黑方胜!" + black + ":" + white);
        //				JOptionPane.showMessageDialog(null, "游戏结束!用时" + time + "秒");
        submit.setEnabled(false);
        winner = "白";
      } else if (black == white) {
        JOptionPane.showMessageDialog(null, "和局!");
        //				JOptionPane.showMessageDialog(null, "游戏结束!用时" + time + "秒");
        winner = "";
      }
    }
  }
Example #24
0
 // Skapar de grafiska komponenterna för menyn
 public void createLabels() {
   // Skapar textfält för nick och intellegens och lägger till dem i en lista
   for (int i = 0; i < 4; i++) {
     textfields.add(new JTextField(20));
     intfields.add(new JTextField(20));
   }
   // Skapar checkboxes för att bestämma om spelaren är ett AI och lägger till den i en lista
   for (int i = 0; i < 4; i++) {
     boxes.add(new JCheckBox());
     boxes.get(i).addActionListener(this);
   }
   // Lägger till labels med förbestämd text i panelen
   for (int i = 0; i < 4; i++) {
     panel.add(new JLabel(labeltext[i]));
   }
   // Lägger till textfields och checkboxes i panelen
   for (int i = 4; i < 8; i++) {
     panel.add(new JLabel(labeltext[i]));
     panel.add(textfields.get(i - 4));
     panel.add(boxes.get(i - 4));
     panel.add(intfields.get(i - 4));
     intfields.get(i - 4).setVisible(false);
   }
   // Lägger till några tomma labels i panelen för att skapa mellanrum och symetri
   for (int i = 0; i < 5; i++) {
     panel.add(new JLabel(" "));
   }
   // Lägger till knapparna och lägger actionlisteners på dem
   panel.add(go);
   go.addActionListener(this);
   panel.add(help);
   help.addActionListener(this);
 }
Example #25
0
 public void evaluate() {
   try {
     // clear problems and console messages
     problemsView.setText("");
     consoleView.setText("");
     // update status view
     statusView.setText(" Parsing ...");
     tabbedPane.setSelectedIndex(0);
     LispExpr root = Parser.parse(textView.getText());
     statusView.setText(" Running ...");
     tabbedPane.setSelectedIndex(1);
     // update run button
     runButton.setIcon(stopImage);
     runButton.setActionCommand("Stop");
     // start run thread
     runThread = new RunThread(root);
     runThread.start();
   } catch (SyntaxError e) {
     tabbedPane.setSelectedIndex(0);
     System.err.println(
         "Syntax Error at " + e.getLine() + ", " + e.getColumn() + " : " + e.getMessage());
   } catch (Error e) {
     // parsing error
     System.err.println(e.getMessage());
     statusView.setText(" Errors.");
   }
 }
  /*-------------------------------------------------------------------------*/
  public FoeTypeSelection(int dirtyFlag) {
    this.dirtyFlag = dirtyFlag;
    List<String> foeTypesList =
        new ArrayList<String>(Database.getInstance().getFoeTypes().keySet());

    Collections.sort(foeTypesList);
    int max = foeTypesList.size();
    checkBoxes = new HashMap<String, JCheckBox>();

    JPanel panel = new JPanel(new GridLayout(max / 2 + 2, 2, 3, 3));

    selectAll = new JButton("Select All");
    selectAll.addActionListener(this);
    selectNone = new JButton("Select None");
    selectNone.addActionListener(this);

    panel.add(selectAll);
    panel.add(selectNone);

    for (String s : foeTypesList) {
      JCheckBox cb = new JCheckBox(s);
      checkBoxes.put(s, cb);
      cb.addActionListener(this);
      panel.add(cb);
    }

    JScrollPane scroller = new JScrollPane(panel);
    this.add(scroller);
  }
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == jb1) {
     try {
       strategyFrame =
           new StrategyFrame(
               trainingTeaBLService.showFrameStrategy(), trainingTeaBLService, jb1.getText());
       strategyFrame.setTrainingTeaWindow(this.trainingTeaWindow);
     } catch (RemoteException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
     }
   } else if (e.getSource() == jb2) {
     try {
       strategyFrame =
           new StrategyFrame(
               trainingTeaBLService.showFrameStrategy(), trainingTeaBLService, jb2.getText());
       strategyFrame.setTrainingTeaWindow(this.trainingTeaWindow);
     } catch (RemoteException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
     }
   } else if (e.getSource() == refresh) {
     refresh();
   }
 }
Example #28
0
  public PlayerPanel(ActionListener listener) {

    Dimension size;
    Insets in = this.getInsets();

    this.numberOfPlayersButtons = new ArrayList<JButton>(this.possiblePlayersAmount);
    this.colorButtons = new LinkedList<JButton>();

    label = new JLabel("Escolha a quantidade de jogadores:");
    this.add(label);

    size = label.getPreferredSize();
    label.setBounds(90, 5 + in.top, size.width, size.height);

    for (int i = 0; i < this.possiblePlayersAmount; i++) {

      JButton tempButton = new JButton(String.format("%d", i + 3));
      numberOfPlayersButtons.add(tempButton);

      size = tempButton.getPreferredSize();
      tempButton.setBounds(45 + 75 * i + in.left, 80 + in.top, size.width, size.height);
      tempButton.addActionListener(listener);

      this.add(tempButton);
    }

    this.setSize(this.getPreferredSize());
    this.setLayout(null);
    this.listener = listener;
  }
  public void actionPerformed(ActionEvent evt) {
    // Get button clicked
    JButton buttonClicked = (JButton) evt.getSource();
    String actionCommand = new String(buttonClicked.getActionCommand());

    if (actionCommand.equals("Submit")) {
      System.out.println(clientUser.getLogon() + ": updating ticket...");

      // Recover ticket and update it
      Ticket ticketToUpdate = ticket;
      ticketToUpdate.setDesc(clientTicketDialog.getSummaryDescriptionField());
      ticketToUpdate.setResolution(clientTicketDialog.getResolutionDescriptionField());

      // Call checkInTicket() on the RMI object to update the ticket on the server
      try {
        ticketServerObject.checkInTicket(ticketToUpdate);
        // Refresh the activeTickets HashMap
        owner.getActiveTickets();
      } catch (RemoteException re) {
        System.out.println(re.getMessage());
      }

      // Close the ClientTicketDialog
      clientTicketDialog.setVisible(false);
      clientTicketDialog.dispose();
    }
  }
 /** Enalbe all the view history related toolbar icons. */
 public void enableHistoryButtons() {
   pbBack.setEnabled(history.canGoBack());
   pbShowBackHistory.setEnabled(history.canGoBack());
   pbForward.setEnabled(history.canGoForward());
   pbShowForwardHistory.setEnabled(history.canGoForward());
   tbrToolBar.repaint();
 }