void onDelete() {
    TreePath path = m_tree.getSelectionPath();
    if (path != null) {
      DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();

      Object[] options = {"Yes", "No"};
      int choise =
          JOptionPane.showOptionDialog(
              pohaci.gumunda.cgui.GumundaMainFrame.getMainFrame(),
              "Are you sure deleting this " + node + " ?",
              "Confirm",
              JOptionPane.YES_NO_OPTION,
              JOptionPane.QUESTION_MESSAGE,
              null,
              options,
              options[1]);

      if (choise == JOptionPane.YES_OPTION) {
        try {
          deleteNodeParent(node);
        } catch (Exception ex) {
          JOptionPane.showMessageDialog(
              this, ex.getMessage(), "Warning", JOptionPane.WARNING_MESSAGE);
        }
      }
    }
  }
Example #2
0
 public void actionPerformed(ActionEvent e) {
   JTextField fqnTextField = new JTextField();
   if (selected_node != null) fqnTextField.setText(selected_node);
   Object[] information = {"Enter fully qualified name", fqnTextField};
   final String btnString1 = "OK";
   final String btnString2 = "Cancel";
   Object[] options = {btnString1, btnString2};
   int userChoice =
       JOptionPane.showOptionDialog(
           null,
           information,
           "Add Node",
           JOptionPane.YES_NO_OPTION,
           JOptionPane.PLAIN_MESSAGE,
           null,
           options,
           options[0]);
   if (userChoice == 0) {
     String userInput = fqnTextField.getText();
     tree.put(userInput, null);
   }
 }