/** 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();
   }
 }
Beispiel #2
0
 // サーバーから送られてきたメッセージの処理
 public void reachedMessage(String name, String value) {
   // チャットルームのリストに変更が加えられた
   if (name.equals("rooms")) {
     if (value.equals("")) {
       roomList.setModel(new DefaultListModel());
     } else {
       String[] rooms = value.split(" ");
       roomList.setListData(rooms);
     }
   }
   // ユーザーが入退室した
   else if (name.equals("users")) {
     if (value.equals("")) {
       userList.setModel(new DefaultListModel());
     } else {
       String[] users = value.split(" ");
       userList.setListData(users);
     }
   }
   // メッセージが送られてきた
   else if (name.equals("msg")) {
     msgTextArea.append(value + "\n");
   }
   // 処理に成功した
   else if (name.equals("successful")) {
     if (value.equals("setName")) msgTextArea.append(">名前を変更しました\n");
   }
   // エラーが発生した
   else if (name.equals("error")) {
     msgTextArea.append("ERROR>" + value + "\n");
   }
 }
Beispiel #3
0
 public void update() {
   setLabels();
   hallList.setListData(getHalls());
   roomItemsList.setListData(getRoomItems());
   Object[] items = (model.getPlayer().getItemList().toArray());
   playerItemsList.setListData(items);
   if (model.playerDied()) endGame("You Lose!");
 }
Beispiel #4
0
  public void p(Object obj) throws Exception {
    col = (Collection) obj;

    if (col != null) {
      Vector vec = new Vector(col);
      if (!(col instanceof List)) Collections.sort(vec);
      list.setListData(vec);
    } else {
      list.setListData(new Vector());
    }
  }
 /** Requests and displays all packages older than the date in the text field */
 private void buttonOldPackagesActionPerformed(ActionEvent event) {
   try {
     queryTime.setTime(dateFormatter.parse(jTextDate.getText().replace("-", "") + "2359"));
     this.packages = DataAdapter.getOlderPackages(queryTime);
     jListPackages.setListData(new Vector(this.packages));
     jButtonSetLost.setEnabled(this.packages.size() > 0);
     jButtonSetFound.setEnabled(false);
     jListScans.setListData(new Vector());
   } catch (Exception ex) {
     JOptionPane.showMessageDialog(this, "Invalid date entered");
   }
 }
  private void fetchAndSaveSelectedPaymentModes() {
    for (AmountInfo tempAI : vectAI) {
      vectPaymentModeIDs.add(tempAI.getPaymentMode());
      vectPaymentModeNames.add(UsefulMethods.getPaymentModeString(tempAI.getPaymentMode()));
    }

    jList1.setListData(vectPaymentModeNames.toArray());

    jList1.setListData(vectPaymentModeNames.toArray());
    try {
      jList1.setSelectedIndex(0);
    } catch (Exception e) {
    }
  }
Beispiel #7
0
  public void updateSearch() {
    if (search.getText().length() > 0) {
      Vector<Person> subset = new Vector<Person>();
      for (Person person : people) {
        if (person.fullName().contains(search.getText())) {
          subset.add(person);
        }
      }

      list.setListData(subset);
    } else {
      list.setListData(people);
    }
  }
  /** Updates the Rating-Lists */
  private void updateLists() {
    RatingComparator comperator = new RatingComparator();

    Vector<Rating> personalVector = new Vector<Rating>(mPlugin.getDatabase().getPersonalRatings());
    Collections.sort(personalVector, comperator);
    int index = mPersonalRatings.getSelectedIndex();
    mPersonalRatings.setListData(personalVector);
    mPersonalRatings.setSelectedIndex(index);

    Vector<Rating> overallVector = new Vector<Rating>(mPlugin.getDatabase().getServerRatings());
    Collections.sort(overallVector, comperator);
    index = mOverallRatings.getSelectedIndex();
    mOverallRatings.setListData(overallVector);
    mOverallRatings.setSelectedIndex(index);
  }
 /** 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());
 }
Beispiel #10
0
  /**
   * fill the Listbox with the list of games. Select the same game after filling that was selected
   * before if possible.
   */
  private void fillGameList(Vector<Game> withGames) {
    int oldIndex = lbGames.getSelectedIndex();
    // log.debug("list currently has "+lbGames.getModel().getSize()+" elements");

    Object temp = null;
    if (oldIndex >= 0) {
      try {
        temp = lbGames.getSelectedValue();
      } catch (Exception ex) {
      }
    }
    for (int i = 0; i < withGames.size(); i++) {
      lbGames.setListData(withGames);
    }
    btJoin.setEnabled((withGames.size() > 0));
    btView.setEnabled((withGames.size() > 0));
    if (oldIndex >= 0 && oldIndex < withGames.size()) {
      lbGames.setSelectedIndex(oldIndex);
      if (temp != null && !lbGames.getSelectedValue().equals(temp)) {
        lbGames.setSelectedIndex(-1);
      }
    }
    // log.debug("now it has "+lbGames.getModel().getSize()+" elements");
    this.updateUI();
  }
Beispiel #11
0
  @Override
  public void run() {
    try {
      host = InetAddress.getLocalHost().getHostName();
      s = new Socket(host, SERVER_PORT);
      output = new PrintWriter(s.getOutputStream(), true);
      input = new Scanner(s.getInputStream());
      output.println(name);

      while (!s.isClosed()) {

        if (input.hasNext()) {
          String msg = input.nextLine();

          if (msg.contains("!%#&")) {
            String tmp = msg.substring(4);
            tmp = tmp.replace("[", "");
            tmp = tmp.replace("]", "");

            String[] users = tmp.split(", ");

            activelist.setListData(users);
          } else {
            history.append(msg + "\n");
          }
        }
      }
    } catch (IOException e) {
      System.out.println(e);
      JOptionPane.showMessageDialog(null, "Unable to connect to the server.");
      System.exit(0);
    }
  }
  // FUNCTION TO GENERATE A STRING OF 10 ADDRESS REFERENCES
  public void autoGenerateString() {
    int random;

    for (int i = 0; i < 10; i++) {

      // RANDOMLY SELECT AN INDEX BETWEEN 0 AND 255
      random = (int) (Math.random() * 256);

      // ADD THE ADDRESS AT THIS INDEX IN ARRAY addresses TO THE LIST OF ADDRESS REFERENCE STRINGS
      //	listData[i] = addresses[random];
      listData.add(addresses[random]);
    }

    // ADD THIS LIST TO THE LISTBOX
    addRefStrList.setListData(listData);

    // ENABLE THE Next BUTTON AND DISABLE Back BUTTON
    //		moveStatus = 0;
    next.setEnabled(true);
    back.setEnabled(false);

    // UPDATE THE PROGRESS FIELD
    tProgress.setText(
        "We have automatically generated an address string of 10 addresses for you to work with."
            + "\nClick on \"Next\" to continue.");
  } // END FUNCTION autoGenerateString
  /** Accepts button clicking */
  @Override
  public void actionPerformed(ActionEvent event) {
    // close dialog and save changes to the region
    if (event.getSource() == okButton) {
      Terrain r = new Terrain(null);
      r.setBackground((String) terrain.getSelectedItem());
      r.setName(nameField.getText());
      r.setRate((Integer) eRateSpinner.getValue());
      r.setFormations(formations);
      if (index == -1) parent.regions.add(r);
      else parent.regions.set(index, r);
      parent.regionList.setListData(parent.regions);
      parent.regionPane.setViewportView(parent.regionList);
      dispose();
    }

    // close dialog without saving changes
    if (event.getSource() == cancelButton) dispose();

    if (fList.getSelectedIndex() != -1) {
      // edit a formation
      if (event.getSource() == fEdtButton) new FormationDialog(this, fList.getSelectedIndex());
      // remove a formation
      else if (event.getSource() == fRemButton) {
        formations.remove(fList.getSelectedIndex());
        fList.setListData(formations);
        fPane.setViewportView(fList);
      }
    }
    // create a new formation
    if (event.getSource() == fAddButton) new FormationDialog(this);
  }
 private void refreshList() {
   OWLModel owlModel = ((ImportWizard) getWizard()).getOWLModel();
   Collection availOntologies = new LinkedHashSet();
   for (Iterator it = owlModel.getRepositoryManager().getProjectRepositories().iterator();
       it.hasNext(); ) {
     Repository rep = (Repository) it.next();
     availOntologies.addAll(new TreeSet(rep.getOntologies()));
   }
   for (Iterator it = owlModel.getRepositoryManager().getGlobalRepositories().iterator();
       it.hasNext(); ) {
     Repository rep = (Repository) it.next();
     availOntologies.addAll(new TreeSet(rep.getOntologies()));
   }
   Collection importedOntologies = owlModel.getAllImports();
   for (Iterator it = availOntologies.iterator(); it.hasNext(); ) {
     URI uri = (URI) it.next();
     if (importedOntologies.contains(uri.toString())) {
       it.remove();
     }
   }
   try {
     availOntologies.remove(new URI(owlModel.getDefaultOWLOntology().getURI()));
   } catch (URISyntaxException e) {
     System.err.print(e.getMessage());
   }
   list.setListData(availOntologies.toArray());
 }
  /** update our data */
  void updateData() {

    // find out which one is selected
    final int curSel = _myList.getSelectedIndex();

    // create an object to put the data into
    final Vector<WorldLocationHolder> list = new Vector<WorldLocationHolder>(0, 1);

    if (getPath() != null) {
      final int len = getPath().size();
      for (int i = 0; i < len; i++) {
        final WorldLocation thisLoc = getPath().getLocationAt(i);
        final WorldLocationHolder holder = new WorldLocationHolder(thisLoc, i + 1);
        list.add(holder);
      }
    }

    // and put the data into the list
    _myList.setListData(list);

    // select the previous item
    if (curSel != -1 && curSel < _myPath.size()) _myList.setSelectedIndex(curSel);

    // update the list
    _myPlotter.update();
  }
  private void loadFile(String basename) {
    try {
      File wavFile = new File(wavDir, basename + db.getProp(db.WAVEXT));
      if (!wavFile.exists())
        throw new IllegalArgumentException("File " + wavFile.getAbsolutePath() + " does not exist");
      File labFile = new File(phoneLabDir, basename + db.getProp(db.LABEXT));
      if (!labFile.exists())
        throw new IllegalArgumentException("File " + labFile.getAbsolutePath() + " does not exist");
      // pm file is optional
      File pmFile = new File(pmDir, basename + db.getProp(PMEXT));
      if (pmFile.exists()) {
        System.out.println("Loading pitchmarks file " + pmFile.getAbsolutePath());
        pitchmarks = new ESTTextfileDoubleDataSource(pmFile).getAllData();
      } else {
        System.out.println("Pitchmarks file " + pmFile.getAbsolutePath() + " does not exist");
        pitchmarks = null;
      }

      AudioInputStream ais = AudioSystem.getAudioInputStream(wavFile);
      audioFormat = ais.getFormat();
      samplingRate = (int) audioFormat.getSampleRate();
      audioSignal = new AudioDoubleDataSource(ais).getAllData();

      String file = FileUtils.getFileAsString(labFile, "ASCII");
      String[] lines = file.split("\n");
      labels.setListData(lines);

      saveFilename.setText(basename);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Beispiel #17
0
  private void GetTasksForAsset(Asset SelectedAsset) {
    AssetTasks.clear();
    taskList.repaint();

    ResultSet tasksOnAssetListResultSet = null;
    Statement statement;
    try {
      statement = connection.createStatement();
      Asset asset = (Asset) assetList.getSelectedValue();
      tasksOnAssetListResultSet =
          statement.executeQuery("SELECT * FROM Task WHERE assetID = " + asset.getAssetID() + ";");

      randSQL.loadAllUsers();
      SetOfUsers allusers = randSQL.getAllUsers();

      while (tasksOnAssetListResultSet.next()) {
        int taskID;
        int projectID;
        User responsible = null;
        int taskPriority;
        String status;
        String taskName;
        String taskType;

        taskID = tasksOnAssetListResultSet.getInt("taskID");
        projectID = tasksOnAssetListResultSet.getInt("projectID");

        for (int i = 0; i < allusers.size(); i++) {
          if (tasksOnAssetListResultSet.getInt("responsiblePerson") == allusers.get(i).getUserID())
            ;
          {
            responsible = allusers.get(i);
            break;
          }
        }

        taskPriority = tasksOnAssetListResultSet.getInt("taskPriority");
        status = tasksOnAssetListResultSet.getString("status");
        taskName = tasksOnAssetListResultSet.getString("taskName");
        taskType = tasksOnAssetListResultSet.getString("type");

        Task newTask =
            new Task(
                taskID, responsible, taskName, taskPriority, status, projectID, asset, taskType);

        AssetTasks.add(newTask);
        taskList.setListData(AssetTasks);
        TasksListCellRenderer renderer =
            new TasksListCellRenderer(); // custom cell renderer to display property rather than
        // useless object.toString()
        taskList.setCellRenderer(renderer);
      }

      asset.setSetOfTasks(AssetTasks);

    } catch (SQLException ex) {
      Logger.getLogger(ManagerUI.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
Beispiel #18
0
 public void actionPerformed(ActionEvent evt) {
   JComboBox cb = (JComboBox) evt.getSource();
   String format = (String) cb.getSelectedItem();
   if (format.equals("all formats")) {
     format = null;
   }
   fileList.setListData(findFiles(AUDIO_DIR, format));
 }
Beispiel #19
0
 public void removeFriendFromList(String name) {
   for (int i = 0; i < list.size(); ) {
     if (list.get(i).toString().equals(name)) list.remove(i);
     else i++;
   }
   copy2view();
   list_fri.setListData(list_view.toArray());
 }
    /**
     * Reload the list of the connected clients and
     * show the dialog when the connection or the creation was successful.
     */
	public void update(Observable source, final Object parameter) {
		if(parameter == ServerMng.UPDATE_LIST){
			ConnectionInfo[] clients = model.getConnectedUsers();
			if(clients != null) 
				users.setListData(clients);
			else 
				users.setListData(new String[] {""});
		} 
		else if( parameter == ServerMng.CONNECTED ) {
			java.awt.EventQueue.invokeLater(new Runnable() {
				public void run() {
					setVisible(true);
				}
			});
			Dispatcher.initialize( progress );
		}
	}
 @Override
 public void removeUpdate(DocumentEvent e) {
   if (e.getDocument() == wordInput.getDocument()) {
     searchList.setListData(
         wordPanel.getDic().getNextWords(wordInput.getText(), SEARCH_LIST_CAPACITY));
     // searchList.setSelectedIndex(0);
   }
 }
Beispiel #22
0
 void lookup(String text) {
   NodeList nl = DOMInfoExtractor.locateNodes(document, ".//text()[contains(.,'" + text + "')]");
   System.out.println("find " + nl.getLength() + " items");
   FoundItem[] fis = new FoundItem[nl.getLength()];
   for (int i = 0; i < nl.getLength(); i++) {
     fis[i] = getFoundItem(nl.item(i), text);
   }
   foundList.setListData(fis);
 }
 public static void fresh_taskname() {
   task_name = new String[Runner.count_task];
   for (int i = 0; i < Runner.count_task; i++) {
     task_name[i] = Runner.task[i].get_taskname();
   }
   jl_taskname.setListData(task_name);
   jl_taskname.setSelectedIndex(0);
   jta_taskdescription.setText(MainFrame.str_description[0]);
 }
Beispiel #24
0
 public void addFriend2List(String name) {
   for (int i = 0; i < list.size(); ) {
     if (list.get(i).toString().equals(name)) return;
     else i++;
   }
   list.add(name);
   copy2view();
   list_fri.setListData(list_view.toArray());
 }
  // 构造函数
  public FindHelpList(final Vector<Point> test) {
    setContentPane(c1);
    setLayout(null);
    int pointsize; // 附近点的个数
    if (test.size() <= 100) pointsize = 100;
    else pointsize = 101;
    temtest = new Vector<Point>();
    for (int i = 0; i < pointsize; i++) temtest.add(test.elementAt(i)); // 把附近的100个点加入temtests容器中
    word = new Vector<String>();
    word.add("点击显示邻近的100个点和边");
    for (int i = 1; i < pointsize; i++)
      word.add(test.elementAt(i).getName() + "    NO." + i); // 把附近100个点的地名加入word容器中
    list = new JList<String>();
    list.setSelectionBackground(null);
    list.setForeground(Color.blue);
    JScrollPane scrollPane = new JScrollPane(list); // 创建滚动面板对象,设置显示内容为list
    scrollPane.setOpaque(false);
    scrollPane.getViewport().setOpaque(false);
    // list.setForeground(Color.WHITE);
    list.setBackground(new Color(0, 0, 0, 0));
    scrollPane.setLocation(0, 0);
    scrollPane.setSize(285, 470);
    add(scrollPane);
    list.setListData(word); // 将word加入list中
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    // 为list添加监视器
    list.addListSelectionListener(
        new ListSelectionListener() {

          @Override
          public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
              // TODO 自动生成的方法存根
              int selectedIndex = list.getSelectedIndex(); // 获取选择地点的下标
              if (selectedIndex < 0) return;
              Point selectedPoint = test.elementAt(selectedIndex); // 根据下表查找地点的坐标
              try {
                new historyfile("searchname", selectedPoint.getNum(), 0); // 把该地点加入到历史记录
              } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
              }
              // int x=selectedPoint.getX();
              // int y=selectedPoint.getY();
              MainFrame.getMainFrame().setNearPointVec(temtest); // 设置附近一百个点是temtest里面的一百个点
              MainFrame.getMainFrame().focusOnPoint(selectedPoint, false); // 定位到选择的点
              MainFrame.getMainFrame().setShowNear(); // 显示附近的点
            }
          }
        });

    this.setSize(300, 500);
    this.setLocationRelativeTo(null);
    this.setTitle("NearPoint Search");
    this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
    this.setVisible(true);
  }
Beispiel #26
0
  private void populateImageData() {
    CharData currentChar = (CharData) charListBox.getSelectedValue();
    if (currentChar == null) {
      imageListBox.setListData(new Object[0]);
      symField.setText("");
      alignSelector.setValue(0);
      rulesBox.setText("");
      alterBox.setText("");
      return;
    }
    imageListBox.setListData(trainer.getCharSet().get(currentChar).keySet().toArray());
    imageListBox.setSelectedIndex(0);

    symField.setText(currentChar.toString());
    alignSelector.setValue(currentChar.getAlign());
    rulesBox.setText(makeRuleString(currentChar.getMergeRules()));
    // alterBox.setText(makeAlternativesString(currentChar.getAlternatives()));
  }
Beispiel #27
0
  @Override
  public void pageListener(Page page) {

    if (page != null) {

      middleButton.setEnabled(true);
      initButton.setEnabled(true);
      endButton.setEnabled(true);

      if (page.getPageType().equals(Page.START)) {
        initButton.setSelected(true);
      } else if (page.getPageType().equals(Page.MIDDLE)) {
        middleButton.setSelected(true);
      } else {
        endButton.setSelected(true);
      }

      textArea.setEnabled(true);
      textArea.setText(page.getContent());

      choiceList.setListData(page.getChoices().toArray(new Choice[] {}));

      newButton.setEnabled(true);
      saveButton.setEnabled(true);

      currentPage = page;
    } else {
      middleButton.setSelected(true);
      textArea.setText(null);
      choiceList.setListData(new Choice[] {});
      newButton.setEnabled(false);
      editButton.setEnabled(false);
      deleteButton.setEnabled(false);
      saveButton.setEnabled(false);
      middleButton.setEnabled(false);
      initButton.setEnabled(false);
      endButton.setEnabled(false);
      textArea.setEnabled(false);

      textArea.setText(null);

      currentPage = null;
    }
  }
  /** Create the dialog. */
  public AdministrarAutos() {
    setModal(true);
    setModalityType(ModalityType.APPLICATION_MODAL);
    setResizable(false);
    setTitle("Administrar autos");
    setBounds(100, 100, 450, 300);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setLayout(new FlowLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);

    contentPanel.add(list);
    list.setListData(SistemaCocheras.getSistemaCocheras().listarAutos());
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
    getContentPane().add(buttonPane, BorderLayout.SOUTH);

    JButton okButton = new JButton("Modificar");
    okButton.setActionCommand("Modificar");
    buttonPane.add(okButton);
    getRootPane().setDefaultButton(okButton);
    okButton.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            try {
              if (!list.isSelectionEmpty()) {
                //                        JDialog dialog =
                // AsociarAuto.getInstance().modificar(((AutoView)list.getSelectedValue()).getIdAuto());
                // dialog.setVisible(true);
                // dialog.addWindowListener(new WindowAdapter() {
                // @Override
                // public void windowClosed(WindowEvent e) {
                //     list.removeAll();
                // list.setListData(SistemaCocheras.getSistemaCocheras().listarClientes());
                //   }
                // });
              }
            } catch (Exception e1) {
              showMessageDialog(null, e1.getMessage());
            }
          }
        });

    JButton cancelButton = new JButton("Cancelar");
    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        });
    cancelButton.setActionCommand("Cancel");
    buttonPane.add(cancelButton);

    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
  }
Beispiel #29
0
  public void ApplicantEnd(String messageSeqNum) {
    // Now that all Applicants have been recieved
    // this function should takes care of displaying them.

    System.out.println("rjf PackageID: " + packageID);
    if (packageID.equals(messageSeqNum) && inProgress) {
      inProgress = false;
      jList1.setListData(appList);
    }
  }
 private void update() {
   Vector<String> data = new Vector<String>();
   Iterator<Template> i = templateMap.values().iterator();
   while (i.hasNext()) {
     Template template = i.next();
     data.add(template.getName());
   }
   templateList.setListData(data);
   repaint();
 }