Beispiel #1
0
  public void actionPerformed(ActionEvent e) {
    text.setBackground(Color.WHITE);

    // if (e.getSource() == butParent) {
    // ParentAction parentAction = new ParentAction();
    // parentAction.actionPerformed(new ActionEvent(e, 0, ""));
    // return;
    // }

    // if (e.getSource() == butNF) {
    // NewFolderAction nfAction = new NewFolderAction();
    // newFolderAction.actionPerformed(new ActionEvent(e, 0, ""));
    // return;
    // }

    if (e.getSource() == cBox) {

      int i = cBox.getSelectedIndex();
      driver.allFiles = (i == 1);
      // fullNodeName = (new File(fullNodeName)).getParent();
      // driver.properties
      // .put("allFiles", Boolean.toString(driver.allFiles));
      // driver.propertiesChanged = true;
      // panel.remove(listView);
      showList();
      // selComp = cBox;
      cBox.requestFocusInWindow();
      cBox.setBackground(vLightBlue);
      // Component c = cBox.getComponent(1);
      // c.setBackground(vLightBlue);
      selComp.setFocusable(true);
      cBox.setEnabled(true);
    }

    // repaint();
  }
Beispiel #2
0
  public void mouseClicked(MouseEvent e) {

    list.setSelectedIndex(-1);
    list.setRequestFocusEnabled(false);
    // changedField = null;

    if (selComp == text || selComp == text2) {
      selComp.setBackground(Color.WHITE);
      ((JTextField) selComp).setEditable(false);
      ((JTextField) selComp).getCaret().setVisible(false);
    }

    text2.setBackground(Color.WHITE);
    // cBox.repaint();

    if (selComp instanceof MyButton) {
      ((MyButton) selComp).setSelected(false);
      ((MyButton) selComp).setFocusable(false);
    }

    selComp = (Component) e.getSource();

    if (selComp == text || selComp == text2) {

      ((JTextField) selComp).setRequestFocusEnabled(true);

      selComp.setBackground(vLightBlue);
      ((JTextField) selComp).getCaret().setVisible(true);
      ((JTextField) selComp).setEditable(true);
      // ((JTextField) selComp).requestFocusInWindow();

    }

    if (e.getSource() instanceof JList) {
      selComp = list;
      int rowNo = list.locationToIndex(e.getPoint());
      if (rowNo == -1) return;

      list.setRequestFocusEnabled(true);

      list.setSelectedIndex(rowNo);
      text.setBackground(Color.WHITE);
      // text2.setBackground(textBackground);

      // http://stackoverflow.com/questions/16392212/unable-to-type-or-delete-text-in-jtextfield
      // http://stackoverflow.com/questions/13415150/java-swing-form-and-cannot-type-text-in-newly-added-jtextfield
      // (this says don't use keylistener!)
      //		http://stackoverflow.com/questions/22642401/jtextfield-and-keylistener-java-swing?rq=1
      //		textField.getDocument().addDocumentListener(...);
      // new code

      // text2.requestFocusInWindow();
      // text2.setBackground(vLightBlue);
      // text2.getCaret().setVisible(true);

      // String fn = listHead + File.separator + nodeNames[rowNo];

      if (e.getClickCount() == 1) {
        mLoc = e.getLocationOnScreen();

        if (nodeNames[rowNo].equals("(empty folder")) return;

      } else if (e.getClickCount() == 2) {

        Point p = e.getLocationOnScreen();

        if (mLoc != null && Math.abs(p.x - mLoc.x) < 6 && Math.abs(p.y - mLoc.y) < 6) {

          enterAction.actionPerformed(new ActionEvent(e, 0, ""));
        }
      }
    }

    if (selComp == cBox) {
      selComp.setFocusable(true);
      cBox.requestFocusInWindow();
      cBox.setEnabled(true);
      cBox.setBackground(vLightBlue);
    }

    if (selComp instanceof MyButton) {
      ((MyButton) selComp).setSelected(false);
    }
    paintList();
    list.repaint();
  }