Пример #1
0
  private void doneButtonMouseClicked(MouseEvent evt) {
    for (int i = 0; i < nodesetModel.size(); i++) {
      try {
        Node node = network.getNode(nodesetModel.get(i).toString());
        network.removeNode(node);
      } catch (CustomException e) {
        JOptionPane.showMessageDialog(
            this,
            "The node " + nodesetModel.get(i).toString() + " doesn't exist",
            "Error",
            JOptionPane.ERROR_MESSAGE);
      }
    }
    nodesetModel.removeAllElements();

    DefaultComboBoxModel nodesetComboBoxModel = new DefaultComboBoxModel();
    String str = "";
    Hashtable<String, Node> nodes = network.getNodes();
    Set<String> set = nodes.keySet();

    Iterator<String> itr = set.iterator();
    while (itr.hasNext()) {
      str = itr.next();
      nodesetComboBoxModel.addElement(nodes.get(str).getIdentifier());
    }
    nodesetComboBox.setModel(nodesetComboBoxModel);

    frame.getNodesTreePanel1().initGUI();
    frame.getNodesTreePanel1().validate();
    frame.getNodesTreePanel1().repaint();

    this.repaint();
    this.validate();
  }
Пример #2
0
  private void initGUI() {
    try {
      setPreferredSize(new Dimension(690, 225));
      this.setLayout(null);
      {
        eraseLabel = new JLabel();
        this.add(eraseLabel);
        eraseLabel.setName("eraseLabel");
        eraseLabel.setBounds(184, 35, 59, 15);
      }
      {
        addButton = new JButton();
        this.add(addButton);
        addButton.setBounds(465, 34, 16, 18);
        addButton.setAction(getAppActionMap().get("add"));
        addButton.setFocusable(false);
        addButton.addMouseListener(
            new MouseAdapter() {
              public void mouseClicked(MouseEvent evt) {
                addButtonMouseClicked(evt);
              }
            });
      }
      {
        doneButton = new JButton();
        this.add(doneButton);
        doneButton.setBounds(315, 181, 77, 29);
        doneButton.setName("doneButton");
        doneButton.addMouseListener(
            new MouseAdapter() {
              public void mouseClicked(MouseEvent evt) {
                doneButtonMouseClicked(evt);
              }
            });
      }
      {
        jScrollPane1 = new JScrollPane();
        this.add(jScrollPane1);
        jScrollPane1.setBounds(255, 66, 192, 103);
        {
          nodesetModel = new DefaultListModel();
          nodesetList = new JList();
          jScrollPane1.setViewportView(nodesetList);
          nodesetList.setModel(nodesetModel);
          nodesetList.setBounds(410, 75, 187, 100);
        }
      }
      {
        infoButton = new JButton();
        this.add(infoButton);
        infoButton.setBounds(668, 196, 16, 18);
        infoButton.setAction(getAppActionMap().get("info"));
        infoButton.setFocusable(false);
        infoButton.setFocusPainted(false);
        infoButton.setBorderPainted(false);
        infoButton.setContentAreaFilled(false);
        infoButton.setMargin(new Insets(0, 0, 0, 0));
        infoButton.setToolTipText("info");
      }
      {
        nodesetLabel = new JLabel();
        this.add(nodesetLabel);
        nodesetLabel.setBounds(255, 12, 80, 15);
        nodesetLabel.setName("nodesetLabel");
      }
      {
        DefaultComboBoxModel nodesetComboBoxModel = new DefaultComboBoxModel();

        String str = "";
        Hashtable<String, Node> nodes = network.getNodes();
        Set<String> set = nodes.keySet();

        Iterator<String> itr = set.iterator();
        while (itr.hasNext()) {
          str = itr.next();
          nodesetComboBoxModel.addElement(nodes.get(str).getIdentifier());
        }
        nodesetComboBox = new JComboBox();
        this.add(nodesetComboBox);
        nodesetComboBox.setModel(nodesetComboBoxModel);
        nodesetComboBox.setBounds(255, 31, 193, 22);
      }
      Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(this);
    } catch (Exception e) {
    }
  }