// ======================================================
 // ======================================================
 private void treeMousePressed(java.awt.event.MouseEvent evt) {
   int mask = evt.getModifiers();
   if ((mask & MouseEvent.BUTTON1_MASK) != 0) {
     TreePath selectedPath = getPathForLocation(evt.getX(), evt.getY());
     if (selectedPath == null) return;
     DefaultMutableTreeNode node =
         (DefaultMutableTreeNode) selectedPath.getPathComponent(selectedPath.getPathCount() - 1);
     Object o = node.getUserObject();
     if (o instanceof String) {
       TransferHandler transfer = this.getTransferHandler();
       transfer.exportAsDrag(this, evt, TransferHandler.COPY);
       dragged_node = node;
       parent.setCursor(renderer.getNodeCursor(node));
     }
   }
 }
 // ======================================================
 // ======================================================
 private void treeMouseReleased(java.awt.event.MouseEvent evt) {
   int mask = evt.getModifiers();
   if ((mask & MouseEvent.BUTTON1_MASK) != 0) {
     if (dragged_node == null) return;
     TreePath selectedPath = getPathForLocation(evt.getX(), evt.getY());
     if (selectedPath == null)
       if ((selectedPath = getUpperPath(evt.getX(), evt.getY())) == null) return;
     DefaultMutableTreeNode node =
         (DefaultMutableTreeNode) selectedPath.getPathComponent(selectedPath.getPathCount() - 1);
     Object o = node.getUserObject();
     int pos = 0;
     if (o instanceof String) {
       DefaultMutableTreeNode p_node = (DefaultMutableTreeNode) node.getParent();
       pos = p_node.getIndex(node);
       node = p_node;
     }
     moveLeaf(node, dragged_node, pos);
     dragged_node = null;
     Cursor cursor = new Cursor(Cursor.DEFAULT_CURSOR);
     parent.setCursor(cursor);
   }
 }
  @Override
  public boolean onStart() {
    window = new JFrame("Interface Explorer");
    treeModel = new InterfaceTreeModel();
    treeModel.update("");
    tree = new JTree(treeModel);
    tree.setRootVisible(false);
    tree.setEditable(false);
    renderer = new HighlightTreeCellRenderer(tree.getCellRenderer());
    tree.setCellRenderer(renderer);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.addTreeSelectionListener(
        new TreeSelectionListener() {
          private void addInfo(final String key, final String value, final boolean highlight) {
            final JPanel row = new JPanel();
            row.setAlignmentX(Component.LEFT_ALIGNMENT);
            row.setLayout(new BoxLayout(row, BoxLayout.X_AXIS));
            for (final String data : new String[] {key, value}) {
              final JLabel label = new JLabel(data);
              label.setAlignmentY(Component.TOP_ALIGNMENT);
              if (highlight) {
                label.setForeground(Color.magenta);
              }
              row.add(label);
            }
            infoArea.add(row);
          }

          public void valueChanged(final TreeSelectionEvent e) {
            final Object node = tree.getLastSelectedPathComponent();
            if (node == null || node instanceof RSInterfaceWrap) {
              return;
            }
            infoArea.removeAll();
            RSComponent iface = null;
            if (node instanceof RSComponentWrap) {
              iface = ((RSComponentWrap) node).wrapped;
            }
            if (iface == null) {
              return;
            }
            List<Integer> changes = new ArrayList<Integer>();
            for (int i = 0; i < HighLightWraps.size(); i++) {
              if (iface.getParent() == null) {
                if (HighLightWraps.get(i).getChild().getIndex() == iface.getIndex()
                    && HighLightWraps.get(i).getParent().getIndex()
                        == iface.getInterface().getIndex()) {
                  changes.add(HighLightWraps.get(i).getChange());
                }
              } else {
                if (HighLightWraps.get(i).getChild().getIndex() == iface.getParent().getIndex()
                    && HighLightWraps.get(i).getParent().getIndex()
                        == iface.getParent().getInterface().getIndex()) {
                  changes.add(HighLightWraps.get(i).getChange());
                }
              }
            }
            addInfo("Type: ", "" + iface.getType(), changes.contains(1));
            addInfo("SpecialType: ", "" + iface.getSpecialType(), changes.contains(2));
            addInfo("Bounds Index: ", "" + iface.getBoundsArrayIndex(), changes.contains(3));
            if (iface.getArea() != null) {
              Rectangle size = iface.getArea();
              addInfo("Size: ", size.width + "," + size.height, changes.contains(15));
            }
            addInfo("Model ID: ", "" + iface.getModelID(), changes.contains(4));
            addInfo("Texture ID: ", "" + iface.getBackgroundColor(), changes.contains(5));
            addInfo("Parent ID: ", "" + iface.getParentID(), changes.contains(6));
            addInfo("Text: ", "" + iface.getText(), changes.contains(7));
            addInfo("Tooltip: ", "" + iface.getTooltip(), changes.contains(8));
            addInfo("SelActionName: ", "" + iface.getSelectedActionName(), changes.contains(9));
            if (iface.getActions() != null) {
              String actions = "";
              for (final String action : iface.getActions()) {
                if (!actions.equals("")) {
                  actions += "\n";
                }
                actions += action;
              }
              addInfo("Actions: ", actions, changes.contains(10));
            }
            addInfo("Component ID: ", "" + iface.getComponentID(), changes.contains(11));
            addInfo(
                "Component Stack Size: ", "" + iface.getComponentStackSize(), changes.contains(12));
            addInfo(
                "Relative Location: ",
                "(" + iface.getRelativeX() + "," + iface.getRelativeY() + ")",
                changes.contains(13));
            addInfo(
                "Absolute Location: ",
                "(" + iface.getAbsoluteX() + "," + iface.getAbsoluteY() + ")",
                changes.contains(14));
            addInfo(
                "Rotation: ",
                "x: "
                    + iface.getXRotation()
                    + "  y: "
                    + iface.getYRotation()
                    + "  z: "
                    + iface.getZRotation(),
                changes.contains(16));
            setHighlightArea(iface.getArea());
            infoArea.validate();
            infoArea.repaint();
          }
        });
    final JDialog Help = new JDialog();
    JScrollPane jScrollPane1;
    JTextArea jTextArea1;
    jScrollPane1 = new JScrollPane();
    jTextArea1 = new JTextArea();
    Help.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    Help.setTitle("Help");
    Help.setResizable(false);
    jTextArea1.setColumns(20);
    jTextArea1.setEditable(false);
    jTextArea1.setFont(new java.awt.Font("MS UI Gothic", 0, 12));
    jTextArea1.setLineWrap(true);
    jTextArea1.setRows(5);
    jTextArea1.setText(
        "Once toggled the listener feature of the interface explorer will detect any changes made to Runescapes interfaces in realtime. If a change is found that interface and data will then be highlighted within the explorers tree model. To use the listener feature you would :\n\n1) Toggle the listener button as active\n2) Wait or commit changes in Runescape\n3) Repaint tree using repaint button or reclick interface folders in GUI\n\n\nTips : While listening for changes the tree model in the GUI will not update itself, changing colors. To refresh the GUI either use the repaint button or close and open Interface folder already within the tree model.");
    jTextArea1.setWrapStyleWord(true);
    jScrollPane1.setViewportView(jTextArea1);
    final GroupLayout layout = new GroupLayout(Help.getContentPane());
    Help.getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 348, Short.MAX_VALUE)
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        jScrollPane1, GroupLayout.PREFERRED_SIZE, 220, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    Help.pack();
    JScrollPane scrollPane = new JScrollPane(tree);
    scrollPane.setPreferredSize(new Dimension(250, 500));
    window.add(scrollPane, BorderLayout.WEST);
    infoArea = new JPanel();
    infoArea.setLayout(new BoxLayout(infoArea, BoxLayout.Y_AXIS));
    scrollPane = new JScrollPane(infoArea);
    scrollPane.setPreferredSize(new Dimension(250, 500));
    window.add(scrollPane, BorderLayout.CENTER);
    final ActionListener actionListener =
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            treeModel.update(searchBox.getText());
            infoArea.removeAll();
            infoArea.validate();
            infoArea.repaint();
          }
        };
    final ActionListener toggleListener =
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            if (listenerButton.isSelected()) {
              log("Cleared");
              HighLightWraps.clear();
            }
            check();
          }
        };
    final ActionListener repaintListener =
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            log("Refreshed Tree");
            treeModel.fireTreeStructureChanged(treeModel.getRoot());
            infoArea.removeAll();
            infoArea.validate();
            infoArea.repaint();
          }
        };
    final ActionListener helpListener =
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            Help.setVisible(true);
          }
        };
    final JPanel toolArea = new JPanel();
    toolArea.setLayout(new FlowLayout(FlowLayout.LEFT));
    toolArea.add(new JLabel("Filter:"));
    searchBox = new JTextField(20);
    searchBox.addActionListener(actionListener);
    toolArea.add(searchBox);
    final JButton updateButton = new JButton("Update");
    final JButton repaintButton = new JButton("Repaint");
    final JButton helpButton = new JButton("Help");
    helpButton.addActionListener(helpListener);
    listenerButton.addActionListener(toggleListener);
    updateButton.addActionListener(actionListener);
    repaintButton.addActionListener(repaintListener);
    toolArea.add(updateButton);
    toolArea.add(listenerButton);
    toolArea.add(repaintButton);
    toolArea.add(helpButton);
    window.add(toolArea, BorderLayout.NORTH);
    window.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
    window.pack();
    window.setVisible(true);
    return true;
  }