コード例 #1
2
ファイル: ClauseOrder.java プロジェクト: jdhuayta/libertya
  public void actionPerformed(ActionEvent ae) {
    if (ae.getActionCommand().equals(PUT)) {
      while (availableExpressions.getSelectedIndex() != -1) {
        String exp = (String) availableExpressions.getSelectedValue();
        setAsSelected(exp, true);
      }
    } else if (ae.getActionCommand().equals(PUSH)) {
      while (selectedExpressions.getSelectedRow() != -1) {
        String exp =
            (String) selectedExpressions.getValueAt(selectedExpressions.getSelectedRow(), 1);
        ((DefaultTableModel) selectedExpressions.getModel())
            .removeRow(selectedExpressions.getSelectedRow());
        ((DefaultListModel) availableExpressions.getModel()).addElement(exp);
      }
    } else if (ae.getActionCommand().equals(UP)) {
      int row = selectedExpressions.getSelectedRow();
      if (row < 1) return;
      ((DefaultTableModel) selectedExpressions.getModel()).moveRow(row, row, --row);
      selectedExpressions.setRowSelectionInterval(row, row);
      scrollToRow(row);
    } else if (ae.getActionCommand().equals(DOWN)) {
      int row = selectedExpressions.getSelectedRow();
      if (row == selectedExpressions.getRowCount() - 1) return;
      ((DefaultTableModel) selectedExpressions.getModel()).moveRow(row, row, ++row);
      selectedExpressions.setRowSelectionInterval(row, row);
      scrollToRow(row);
    }

    clauses.builder.syntax.refresh();
  }
コード例 #2
0
 @Override
 public void valueChanged(ListSelectionEvent event) {
   System.out.println(event.toString());
   JList list = (JList) event.getSource();
   if (list.getSelectedValue() != null) {
     // check
     String buttonText = list.getSelectedValue().toString();
     item = model.getCatalog().getItem(buttonText);
     if (item instanceof PizzaSize) {
       setView(
           "Size",
           ((PizzaSize) item).getFullName(),
           ((PizzaSize) item).getShortName(),
           ((PizzaSize) item).getPrice());
     } else if (item instanceof Sauce) {
       setView("Sauce", ((Sauce) item).getFullName(), ((Sauce) item).getShortName(), -1.0);
     } else if (item instanceof Topping) {
       setView("Topping", ((Topping) item).getFullName(), ((Topping) item).getShortName(), -1.0);
     } else if (item instanceof Side) {
       setView("Side", ((SideItem) item).getName(), null, ((SideItem) item).getPrice());
     } else if (item instanceof Drink) {
       setView("Drink", ((SideItem) item).getName(), null, ((SideItem) item).getPrice());
     }
     components.get("typeComboBox").setEnabled(false);
   }
 }
コード例 #3
0
  protected void listMouseClicked(EventObject e) {
    for (ListLevel listLevelTuple : depthLists) {
      listLevelTuple.list.setCellRenderer(new SceneDepthListCellRender());
    }

    JList list = (JList) e.getSource();
    selectedScene = (Scene) list.getSelectedValue();
    jumpToBt.setEnabled(true);
    jumpToBt.setText("Jump to [" + selectedScene.getName() + "]");

    int idx = depthLists.indexOf(new ListLevel(-1, list));
    assert idx != -1 : "Should have found a scenesList";

    if (idx == 0) {
      JList startList = depthLists.get(1).list;
      startList.setCellRenderer(new ToCellRenderer(selectedScene));
      Util.showComponent(startList);
    } else if (idx > 0) {
      JList fromList = depthLists.get(idx - 1).list;
      logger.debug("Before: " + fromList.getSelectedValue());

      fromList.setCellRenderer(new FromCellRenderer(selectedScene));
      Util.showComponent(fromList);

      if (idx + 1 < depthLists.size()) {
        JList afterList = depthLists.get(idx + 1).list;
        logger.debug("After: " + afterList.getSelectedValue());

        afterList.setCellRenderer(new ToCellRenderer(selectedScene));
        Util.showComponent(afterList);
      }
    }

    Util.showComponent(panel);
  }
コード例 #4
0
ファイル: DataView.java プロジェクト: Embraser01/IUT-POO-TP4
 @Override
 public void valueChanged(ListSelectionEvent e) {
   if (e.getSource() == listData && listData.getSelectedValue() != null) {
     Data tmp = rssFeed.searchByTitle((String) listData.getSelectedValue());
     if (tmp != null) this.desc.setText(tmp.getDesc());
   }
 }
コード例 #5
0
ファイル: CopyWindow.java プロジェクト: schneehund/synchros
  @Override
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == btnQAuswahl) {
      addQListBoxEintrag(dateiAuswählen());
    }
    if (e.getSource() == btnQEntfernen) {
      subQListBoxEintrag();
    }
    if (e.getSource() == btnZAuswahl) {
      addZListBoxEintrag(dateiAuswählen());
    }
    if (e.getSource() == btnZEntfernen) {
      subZListBoxEintrag();
    }
    if (e.getSource() == btnSync) {

      startCopy(
          (Path) quellJList.getSelectedValue().getValueMember(),
          (Path) zielJList.getSelectedValue().getValueMember());
    }
    if (e.getSource() == btnAbbruch) {
      setAbbruch();
    }
    if (e.getSource() == btnBackup) {
      MainNtray.bwvisible();
      this.invisible();
    }
  }
コード例 #6
0
ファイル: MPMenuPanel.java プロジェクト: gruzilla/mzsSnake
  /**
   * 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();
  }
コード例 #7
0
  @Override
  public void actionPerformed(ActionEvent e) {
    if (e.getSource().equals(decoyStrategy_pattern)
        || e.getSource().equals(decoyStrategy_searchengine)) {
      // decoy pattern can only be edited, if decoy strategy is pattern
      decoyPattern_pattern.setEnabled(decoyStrategy_pattern.isSelected());
    } else if (e.getSource().equals(addToPreferred_button)
        && (availableScoresList.getSelectedIndex() > -1)) {
      preferredScoresModel.addElement(availableScoresList.getSelectedValue());
      availableScoresModel.remove(availableScoresList.getSelectedIndex());
    } else if (e.getSource().equals(removeFromPreferred_button)
        && (preferredScoresList.getSelectedIndex() > -1)) {
      availableScoresModel.addElement(preferredScoresList.getSelectedValue());
      preferredScoresModel.remove(preferredScoresList.getSelectedIndex());
    } else if (e.getSource().equals(calculatePSMFDR)) {
      // execute PSM level operations
      if (piaViewModel != null) {
        for (Map.Entry<String, Object> setIt : getSettings().entrySet()) {
          piaViewModel.addSetting(setIt.getKey(), setIt.getValue());
        }
        piaViewModel.executePSMOperations();
      }

      updateFDRPanel();
    }
  }
コード例 #8
0
ファイル: EditFavorite.java プロジェクト: ENGYS/HELYX-OS
  @Override
  public void actionPerformed(ActionEvent actionEvent) {
    if (favoriteList.getSelectedValue() != null) {
      Favorite favorite = favoriteList.getSelectedValue();
      JPanel panel = new JPanel(new GridLayout(4, 1));

      JTextField nameField = new JTextField(favorite.getName());
      addNameListeners(nameField);
      nameField.setName("favorite.name");
      panel.add(new JLabel(EDITFAVORITES_NAME));
      panel.add(nameField);

      JTextField urlField = new JTextField(decodedURL(favorite), 20);
      urlField.setName("favorite.url");
      panel.add(new JLabel(EDITFAVORITES_URL));
      panel.add(urlField);

      int response =
          JOptionPane.showConfirmDialog(
              SwingUtilities.getRoot(favoriteList),
              panel,
              EDITFAVORITES_TITLE,
              JOptionPane.YES_NO_OPTION);
      if (response == JOptionPane.YES_OPTION) {
        favorite.setName(nameField.getText());
        favorite.setUrl(encodedURL(urlField));
        listModel.change(favoriteList.getSelectedIndex(), favorite);
      }
    }
  }
コード例 #9
0
 /**
  * Método para atender el evento cuando un usuario selecciona una receta de la lista
  *
  * @param evento El evento de selección de un elemento de la lista de recetas. evento != null
  */
 public void valueChanged(ListSelectionEvent evento) {
   if (listaRecetas.getSelectedValue() != null) {
     int posRecetaSeleccionada = (int) listaRecetas.getSelectedIndex();
     seleccionar(posRecetaSeleccionada);
     Receta recetaSeleccionada = (Receta) listaRecetas.getSelectedValue();
     interfaz.actualizarInfoReceta(recetaSeleccionada);
   }
 }
コード例 #10
0
 void removeGroupExhibit() {
   peer.makeChange();
   peer.getLoader()
       .removeGroupExhibit(
           groupExhibitsList.getSelectedValue().toString(),
           groupNameList.getSelectedValue().toString());
   groupExhibitsModel.notifyChange();
   groupExhibitsList.setSelectionInterval(0, 0);
 }
コード例 #11
0
 @Override
 public void stateChanged(ChangeEvent arg0) {
   ExhibitInfo e = getCurrentExhibit();
   if (arg0.getSource().equals(exhibitXCoordField.getModel())) {
     int val = Integer.parseInt(exhibitXCoordField.getModel().getValue().toString());
     e.setCoords(val, e.getY());
     if (e.origXCoord != e.getX()) {
       peer.makeChange();
     }
   } else if (arg0.getSource().equals(exhibitYCoordField.getModel())) {
     int val = Integer.parseInt(exhibitYCoordField.getModel().getValue().toString());
     e.setCoords(e.getX(), val);
     if (e.origYCoord != e.getY()) {
       peer.makeChange();
     }
   } else if (arg0.getSource().equals(aliasXCoordField.getModel())) {
     int val = Integer.parseInt(aliasXCoordField.getModel().getValue().toString());
     int index = exhibitAliasesList.getSelectedIndex();
     Alias alias = e.getAliases()[index];
     if (alias.xPos != val) {
       e.addAlias(alias.name, val, alias.yPos, alias.tag);
       peer.makeChange();
     }
   } else if (arg0.getSource().equals(aliasYCoordField.getModel())) {
     int val = Integer.parseInt(aliasYCoordField.getModel().getValue().toString());
     int index = exhibitAliasesList.getSelectedIndex();
     Alias alias = e.getAliases()[index];
     if (alias.yPos != val) {
       e.addAlias(alias.name, alias.xPos, val, alias.tag);
       peer.makeChange();
     }
   } else if (arg0.getSource().equals(groupXCoordField.getModel())) {
     int val = Integer.parseInt(groupXCoordField.getModel().getValue().toString());
     String name = groupNameList.getSelectedValue().toString();
     ExhibitGroup group = peer.getLoader().getGroup(name);
     if (val != group.xPos) {
       peer.getLoader().addGroup(name, group.exhibits, val, group.yPos);
       peer.makeChange();
     }
   } else if (arg0.getSource().equals(groupYCoordField.getModel())) {
     int val = Integer.parseInt(groupYCoordField.getModel().getValue().toString());
     String name = groupNameList.getSelectedValue().toString();
     ExhibitGroup group = peer.getLoader().getGroup(name);
     if (val != group.yPos) {
       peer.getLoader().addGroup(name, group.exhibits, group.xPos, val);
       peer.makeChange();
     }
   } else if (arg0.getSource().equals(eventStart.getModel())) {
     Event event = peer.getLoader().getEvents().get(eventsList.getSelectedIndex());
     event.setStartDay((Date) eventStart.getModel().getValue());
     peer.makeChange();
   } else if (arg0.getSource().equals(eventEnd.getModel())) {
     Event event = peer.getLoader().getEvents().get(eventsList.getSelectedIndex());
     event.setEndDay((Date) eventEnd.getModel().getValue());
     peer.makeChange();
   }
 }
コード例 #12
0
 void removeTag() {
   if (contentList.getModel().getSize() > 1) {
     for (ExhibitInfo e : peer.getLoader().getExhibits()) {
       if (e.getName().equals((String) exhibitNameList.getSelectedValue())) {
         e.setContent((String) contentList.getSelectedValue(), null);
       }
     }
   }
   contentListModel.notifyChange();
   contentList.setSelectionInterval(0, 0);
 }
コード例 #13
0
 @Override
 public void valueChanged(ListSelectionEvent e) {
   if (e.getSource() instanceof JList) {
     @SuppressWarnings("unchecked")
     JList<String> list = (JList<String>) e.getSource();
     if (list.getName().equals("List_Sudokus_Modificar")) {
       selItemSudModificar = list.getSelectedValue();
     } else if (list.getName().equals("List_Sudokus_Borrar")) {
       selItemSudBorrar = list.getSelectedValue();
     }
   }
 }
コード例 #14
0
  @Override
  public void valueChanged(ListSelectionEvent e) {
    Random random = new Random();
    if (!e.getValueIsAdjusting()) {
      textoDescripcion.setText(listaEjercicios.getSelectedValue().getDescripcion());

      textoResultadoInSitu.setText(String.valueOf(random.nextInt(50)));

      ImageIcon icono = new ImageIcon(listaEjercicios.getSelectedValue().getDirectorioGIF());
      pantallaImagen.setIcon(icono); // Las imagenes son GIF de 450x450
    }
  }
コード例 #15
0
  private void borrarUsuario() {
    BD.getInstance()
        .actualizar("DELETE FROM usuarios WHERE dni=" + list.getSelectedValue().getDni());
    usuarios.remove(list.getSelectedValue());

    /*
     * Se vuelve a cargar el vector, por lo que se indica aquí:
     * http://docs.oracle.com/javase/7/docs/api/javax/swing/JList.html#JList(java.util.Vector)
     * Si se cambia el vector sin crear un nuevo ListModel, el funcionamiento es impredecible.
     * Aunque he hecho pruebas y parece funcionar como debe, esta es la manera correcta de hacerlo.
     */
    list.setListData(usuarios);
  }
コード例 #16
0
ファイル: MoveATub.java プロジェクト: wwake/dpij
  public void valueChanged(ListSelectionEvent e) {
    @SuppressWarnings("unchecked")
    JList<String> sender = (JList<String>) e.getSource();

    if (!sender.isSelectionEmpty()) {
      if (sender.equals(boxList())) updateTubList(sender.getSelectedValue());

      if (sender.equals(machineList())) selectedMachine = sender.getSelectedValue();

      if (sender.equals(tubList())) selectedTub = sender.getSelectedValue();
    }

    assignButton().setEnabled(!tubList().isSelectionEmpty() && !machineList().isSelectionEmpty());
  }
コード例 #17
0
ファイル: Test.java プロジェクト: milekicnikola/JSD
 public boolean insertSelection() {
   if (list.getSelectedValue() != null) {
     try {
       final String selectedSuggestion =
           ((String) list.getSelectedValue()).substring(subWord.length());
       textarea.getDocument().insertString(insertionPosition, selectedSuggestion, null);
       return true;
     } catch (BadLocationException e1) {
       e1.printStackTrace();
     }
     hideSuggestion();
   }
   return false;
 }
コード例 #18
0
ファイル: GraphViewer.java プロジェクト: sormaz/labimp.graph
 protected void addDirectedArc() {
   Node fromNode = (Node) fromList.getSelectedValue();
   Node toNode = (Node) toList.getSelectedValue();
   if (!fromNode.isChild(toNode)) {
     DirectedArc dArc = new DirectedArc(fromNode, toNode);
     arcListModel.addElement(dArc);
     layouter.arcAdded(dArc);
   } else {
     JOptionPane.showMessageDialog(
         null,
         "Arc from " + fromNode + " to " + toNode + " already exists!",
         "Warning",
         JOptionPane.WARNING_MESSAGE);
   }
 }
コード例 #19
0
ファイル: GraphViewer.java プロジェクト: sormaz/labimp.graph
 protected void addUndirectedArc() {
   Node firstNode = (Node) fromList.getSelectedValue();
   Node secNode = (Node) toList.getSelectedValue();
   if (!firstNode.isConnected(secNode)) {
     UndirectedArc udArc = new UndirectedArc(firstNode, secNode);
     arcListModel.addElement(udArc);
     layouter.arcAdded(udArc);
   } else {
     JOptionPane.showMessageDialog(
         null,
         "Arc from " + firstNode + " to " + secNode + " already exists!",
         "Warning",
         JOptionPane.WARNING_MESSAGE);
   }
 }
コード例 #20
0
ファイル: JFontChooser.java プロジェクト: Jmdebugger/rusefi
  private Font getCurrentFont() {
    try {
      String fontFamily = (String) fontList.getSelectedValue();
      int fontSize = Integer.parseInt((String) sizeList.getSelectedValue());

      int fontType = Font.PLAIN;

      if (cbBold.isSelected()) fontType += Font.BOLD;
      if (cbItalic.isSelected()) fontType += Font.ITALIC;
      return new Font(fontFamily, fontType, fontSize);
    } catch (Exception ex) {
      // if error return current sample font.
      return txtSample.getFont();
    }
  }
コード例 #21
0
ファイル: AdminView.java プロジェクト: ferrerj/Photo_Album
  /* (non-Javadoc)
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  public void actionPerformed(ActionEvent e) {
    PopUp popup;
    if ("Add".equals(e.getActionCommand())) {
      popup = new PopUp(1, 0);
      if (popup.text != null && popup.text.length() != 0) {

        try {
          if (!control.create_user(popup.text, popup.secondText)) {
            popup = new PopUp("User Already Exists");
          }
        } catch (IOException e1) {
          // TODO Auto-generated catch block
        }
      }
      populateUsers();
    } else if ("Logout".equals(e.getActionCommand())) {
      try {
        JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this);
        topFrame.setVisible(false);
        popup = new PopUp(4, 0);
        if (popup.response == 0) {
          padre.logout();
        } else {
          topFrame.setVisible(true);
        }
      } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }

    } else {
      popup = new PopUp(3, 0);
      if (popup.response == 0) {
        if (userList.getSelectedValue() == null) // checks to see if the list is empty
        {
        } else // deletes the user
        {
          try {
            System.out.println(control.delete_user(userList.getSelectedValue()));
          } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
          }
        }
      }
      populateUsers();
    }
  }
コード例 #22
0
  private void onSellItemClick() {
    try {
      // Determine which seller auction is selected
      String auctionName = (String) sellList.getSelectedValue();

      if (auctionName != null) {
        // resolve the Object Reference in Naming
        Auction auctionImpl = AuctionHelper.narrow(ncRef.resolve_str(auctionName));

        // Sell item
        auctionImpl.sellItem(userName);
        appletDisplay(auctionName + " has ended");

        // Update the auction lists
        updateAuctionLists(false);
      }
      ;

    } catch (NumberFormatException e1) {
      appletDisplay("Invalid bid price");
    } catch (AuctionFailure e2) {
      appletDisplay(e2.description);
    } catch (Exception e3) {
      appletDisplay("Unable to place bid");
      System.out.println("ERROR : " + e3);
      e3.printStackTrace(System.out);
    }
  }
コード例 #23
0
  private void onBidClicked() {
    try {
      // Determine which bidder auction is selected
      String auctionName = (String) bidList.getSelectedValue();

      // Determine what the bid is
      int bidPrice = Integer.parseInt(txtBidPrice.getText());

      if (auctionName != null) {
        // resolve the Object Reference in Naming
        Auction auctionImpl = AuctionHelper.narrow(ncRef.resolve_str(auctionName));

        // Place bid
        auctionImpl.bid(userName, bidPrice);
        appletDisplay("Placed bid of $" + Integer.toString(bidPrice) + " on " + auctionName);

        // Update the auction lists
        updateAuctionLists(false);
      }
      ;

    } catch (NumberFormatException e1) {
      appletDisplay("Invalid bid price");
    } catch (AuctionFailure e2) {
      appletDisplay(e2.description);
    } catch (Exception e3) {
      appletDisplay("Unable to place bid");
      System.out.println("ERROR : " + e3);
      e3.printStackTrace(System.out);
    }
  }
コード例 #24
0
ファイル: BlockingFrame.java プロジェクト: charapod/SoftEng
  /**
   * Handles a click event. If the blocked user list is updated as a result the proxy will respond
   * with the new list asynchronously.
   *
   * @param actionCommand the action performed by the user
   */
  private void clickHandler(Object actionCommand) {
    System.out.println(
        "Received command: " + actionCommand + "\tText = " + blockTextField.getText());

    if (actionCommand.equals(CMD_BLOCK)) {
      String blocked = blockTextField.getText();
      if (blocked == null || "".equals(blocked)) {
        JOptionPane.showMessageDialog(
            this, "You must provide the username of the user to be blocked.");
        return;
      } else if (!isAlphaNumeric(blocked)) {
        JOptionPane.showMessageDialog(this, "The username must be alphanumeric");
        return;
      }
      try {
        blockingProcessing.processBlock(blocked);
      } catch (CommunicationsException e) {
        JOptionPane.showMessageDialog(this, "Unable to send the block request. (T__T)");
      }
    } else if (actionCommand.equals(CMD_UNBLOCK)) {
      String unblocked = blockedList.getSelectedValue();
      if (unblocked == null || "".equals(unblocked)) {
        JOptionPane.showMessageDialog(this, "Please select the user to be unblocked.");
        return;
      }
      try {
        blockingProcessing.processUnblock(unblocked);
      } catch (CommunicationsException e) {
        JOptionPane.showMessageDialog(this, "Unable to process block request. (T__T)");
      }
    }
  }
コード例 #25
0
ファイル: SeleccionarClubFrm.java プロジェクト: orte/FifaTMS
 /**
  * Simplemente activa el botón aceptar, desactivado por defecto, cuando se selecciona un elemento
  * de la lista
  *
  * @author jon.orte
  */
 @Override
 public void valueChanged(ListSelectionEvent e) {
   // TODO Auto-generated method stub
   if ((list.getSelectedValue() == null) == false) {
     btnAceptar.setEnabled(true);
   }
 }
コード例 #26
0
ファイル: NewFileThree.java プロジェクト: peteclarkez/jgnash
 private void addAction() {
   CurrencyNode obj = aJList.getSelectedValue();
   if (obj != null) {
     aList.removeElement(obj);
     cList.addElement(obj);
   }
 }
コード例 #27
0
 public void valueChanged(ListSelectionEvent e) {
   if (!e.getValueIsAdjusting()) {
     if (userInputListener.isModified()) {
       // the user has modified the config, but not stored it
       int decision =
           JOptionPane.showConfirmDialog(
               this,
               "The configuration for project '"
                   + selectedProjectName
                   + "' has unsaved changes. Do you wish to save them?",
               "Save Changes?",
               JOptionPane.YES_NO_CANCEL_OPTION);
       if (decision == JOptionPane.YES_OPTION) { // store
         try {
           storeConfig(false);
         } catch (Exception ex) {
           Main.fatalError(ex);
         }
       }
       if (decision == JOptionPane.CANCEL_OPTION) {
         selection.removeListSelectionListener(this);
         selection.setSelectedValue(selectedProjectName, true);
         selection.addListSelectionListener(this);
         return;
       }
     }
     selectedProjectName = (String) selection.getSelectedValue();
     generateGUIGonfiguration(selectedProjectName);
     generateGUIDescription(selectedProjectName);
   }
 }
コード例 #28
0
  private void doSave() {
    ContactProps contact = new ContactProps();
    for (AccessInterface infoField : infoFields)
      contact.setProperty(infoField.getContactKey(), infoField.getContent());
    String newname = contact.getProperty(ContactProps.NAME);
    if (newname == null || newname.trim().equals("")) {
      AddrBookProps.save(addrbook);
      return;
    }
    if (contactList.getSelectedIndex() != -1) {
      String oldname = (String) contactList.getSelectedValue();
      if (oldname.equals(newname)) { // 同名
        addrbook.put(contact.getProperty(ContactProps.NAME), contact);
      } else { // 改变名字
        if (addrbook.containsKey(newname)) { // 名字冲突
        } else { // 名字不冲突
          addrbook.remove(oldname);
          addrbook.put(newname, contact);
        }
      }
    } else {

      if (addrbook.containsKey(newname)) { // 名字冲突
      } else { // 名字不冲突
        addrbook.put(newname, contact);
      }
    }
    refreshContactList();
    contactList.setSelectedValue(newname, true);
    AddrBookProps.save(addrbook);
  }
コード例 #29
0
  /**
   * Called when user selects a component in the list of configuration forms.
   *
   * @param e the <tt>ListSelectionEvent</tt>
   */
  public void valueChanged(ListSelectionEvent e) {
    if (!e.getValueIsAdjusting()) {
      ConfigurationForm configForm = (ConfigurationForm) configList.getSelectedValue();

      if (configForm != null) showFormContent(configForm);
    }
  }
コード例 #30
0
  // Listener method for list selection changes.
  public void valueChanged(ListSelectionEvent e) {
    if (e.getValueIsAdjusting() == false) {

      if (list.getSelectedIndex() == -1) {
        // No selection: disable delete, up, and down buttons.
        deleteButton.setEnabled(false);
        upButton.setEnabled(false);
        downButton.setEnabled(false);
        nameField.setText("");

      } else if (list.getSelectedIndices().length > 1) {
        // Multiple selection: disable up and down buttons.
        deleteButton.setEnabled(true);
        upButton.setEnabled(false);
        downButton.setEnabled(false);

      } else {
        // Single selection: permit all operations.
        deleteButton.setEnabled(true);
        upButton.setEnabled(true);
        downButton.setEnabled(true);
        nameField.setText(list.getSelectedValue().toString());
      }
    }
  }