Beispiel #1
0
  public ShenPiPanel(MainFrame par) {
    this.parent = par;

    initUI();
    setHotKey();

    initBL();

    approvebt.addActionListener(this);
    disappbt.addActionListener(this);
    refreshbt.addActionListener(this);
    refreshList();
  }
Beispiel #2
0
 private void initSetBtn(PanelConfig cfg) {
   this.setBtn = new MyButton(cfg.getButtons().element("setting"));
   setBtn.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           loginSettingDialog =
               new LoginSettingDialog(ERPConfig.getLOGINSETTING_DIALOG_CONFIG(), frame);
           loginSettingDialog.setVisible(true);
         }
       });
 }
Beispiel #3
0
  public BankAccountPanel(MainFrame par) {
    this.parent = par;
    this.setOpaque(false);
    this.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createBevelBorder(ALLBITS),
            "银行账户",
            TitledBorder.LEFT,
            TitledBorder.TOP,
            new Font("", Font.BOLD, 25)));

    initUI();
    setHotKey();

    addbt.addActionListener(this);
    deletebt.addActionListener(this);
    refreshbt.addActionListener(this);

    initBL();
    refresh();
  }
Beispiel #4
0
  /** Creating buttons with coordinates and action listeners */
  private MyButton createButton() {
    // The new buttons counters -
    // will be translates to coordinates
    if (counterX >= size) {
      counterX = 0;
      counterY++;
    }

    MyButton button = new MyButton();

    // set buttons coordinates
    button.x = counterX++;
    button.y = counterY;

    // The buttons properties adjustment
    button.setPreferredSize(new Dimension(50, 50));
    button.setFont(new Font("Dialog", Font.PLAIN, 72));

    // Action listener
    button.addActionListener(
        e -> {
          game.move(new Move(button.x, button.y));
          game.isGameOver();
          button.setText(game.getField()[button.x][button.y] > 0 ? "X" : "O");
          button.setEnabled(false);
          statusStr.setText(game.getState().toString());

          // If the game is over
          // disable all unselected buttons
          if (game.getState().equals(GameState.X_WINS)
              || game.getState().equals(GameState.O_WINS)) {

            for (Component b : gameField.getComponents()) {
              b.setEnabled(false);
            }
          }
        });

    // System.out.println("button " + button.x + " " + button.y);

    return button;
  }
Beispiel #5
0
  private void setupPanels()
  {
    Border   border1, border2;
    int      row, col;
    MyButton btn;


    border2 = BorderFactory.createLoweredBevelBorder();
    
    JPanel mainPanel = new JPanel( new GridBagLayout() );
    
    GridBagConstraints con = new GridBagConstraints();
    con.fill = GridBagConstraints.HORIZONTAL; 
    con.weightx = 1; con.anchor = GridBagConstraints.NORTHWEST;
    
    // Setup States Panels
    JPanel statesP = new JPanel( new GridBagLayout() );
    border1 = BorderFactory.createEmptyBorder (4, 4, 2, 4);
    statesP.setBorder( BorderFactory.createCompoundBorder(border1, border2) );
    
    JPanel statesP_in = new JPanel(new GridBagLayout() );
    
    row = 0; col = 0;
    Enumeration enum = parent.stateDefs.elements();
    
    while ( enum.hasMoreElements() ) {
        RecDef def = ( RecDef ) enum.nextElement();
      
        if ( def.stateVector.size() > 0 ) {
            con.gridx = col; con.gridy = row;

            btn = new MyButton( def.description,
                                "Press for " + def.description
                              + " histogram", this );
            statesP_in.add( btn, con);
            btn.setIcon( new ColoredRect( def.color ) );
            btn.setHorizontalAlignment( btn.LEFT );
		   
            con.gridx = col + 1;
            def.checkbox = new JCheckBox( "", true );
            statesP_in.add( def.checkbox, con ); 
	    def.checkbox.addItemListener( this ); 
            def.checkbox.setToolTipText( "Enable or disable "
                                       + def.description );
	
            if ( (col / 2) == numCols ) {
                col = 0; row ++; 
            }
            else
                col += 2;
        }
    }
    
    con.gridx = 0; con.gridy = 0;
    con.fill = GridBagConstraints.NONE;
    con.weightx = 0;
    statesP.add( statesP_in, con );
    
    // State Buttons Controls
    JPanel states_cntl = new JPanel( new GridLayout(2, 1) );
    states_cntl.add( new MyButton( "All States On",
                                   "Enable all states", this) ); 
    states_cntl.add( new MyButton( "All States Off",
                                   "Disable all states", this) );
    
    con.gridx = 1;
    statesP.add( states_cntl, con );
    
    con.gridx = 0; con.gridy = 0;
    mainPanel.add( statesP, con );
    
    // Setup Arrows Panels
    if ( parent.arrowDefs.size() > 0 ) {
        row = 0; col = 0;
        JPanel arrowsP = new JPanel( new GridBagLayout() );
        border1 = BorderFactory.createEmptyBorder (2, 4, 4, 4);
        arrowsP.setBorder( BorderFactory.createCompoundBorder( border1,
                                                               border2 ) );

        JPanel arrowsP_in = new JPanel( new GridBagLayout() );

        enum = parent.arrowDefs.elements();
        while ( enum.hasMoreElements() ) {
            RecDef def = ( RecDef ) enum.nextElement();
            if ( def.stateVector.size() > 0 ) {
                con.gridx = col; con.gridy = row;
                btn = new MyButton( def.description,
                                    "Press for " + def.description
                                  + " histogram", this );
                arrowsP_in.add( btn, con );
                btn.setIcon( new ColoredRect( def.color ) );
                btn.setHorizontalAlignment( btn.LEFT );

                con.gridx = col + 1;
                def.checkbox = new JCheckBox( "", true );
                arrowsP_in.add( def.checkbox, con ); 
                def.checkbox.addItemListener( this ); 
                def.checkbox.setToolTipText( "Enable or disable "
                                           + def.description );
                if ( (col / 2) == numCols ) {
                    col = 0; row ++; 
                }
                else
                    col += 2;
            }   //  Endof if ( def.stateVector.size() > 0 )
        }

        con.gridx = 0; con.gridy = 0;
        con.fill = GridBagConstraints.NONE;
        con.weightx = 0;
        arrowsP.add( arrowsP_in, con );
    
        // Arrow Buttons Controls
        JPanel arrows_cntl = new JPanel( new GridLayout(2, 1) );
        arrows_cntl.add( new MyButton( "All Arrows On",
                                       "Enable all arrows", this) ); 
        arrows_cntl.add( new MyButton( "All Arrows Off",
                                       "Disable all arrows", this) );
    
        con.gridx = 1;
        arrowsP.add( arrows_cntl, con );

        con.gridy = 2; con.gridx = 0;
        mainPanel.add( arrowsP, con );
    }   //  Endof  if ( parent.arrowDefs.size() > 0 )
      
    //Add mainPanel to JScrollPane
    JScrollPane sP = new JScrollPane (mainPanel);
    sP.setPreferredSize (new Dimension (100, 100));
    sP.setMinimumSize (new Dimension (100, 100));
    add (sP);
  }
Beispiel #6
0
 private void setHotKey() {
   addbt.setMnemonic('N');
   deletebt.setMnemonic('D');
   refreshbt.setMnemonic('R');
 }
Beispiel #7
0
 private void setHotKey() {
   approvebt.setMnemonic('A');
   disappbt.setMnemonic('D');
   refreshbt.setMnemonic('R');
 }
Beispiel #8
0
  int showOpenDialog(final boolean sa) {

    dialog = new JDialog(frame, JDialog.ModalityType.APPLICATION_MODAL);
    // dialog.setUndecorated(false);

    saveAs = sa;

    dialog.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            dialog.dispose();
          }
        });

    panel = new JPanel();
    panel.setLayout(new BorderLayout());

    driver.curDiag.filterOptions[0] = fCParms.title;
    cBox = new MyComboBox(driver.curDiag.filterOptions);
    cBox.setMaximumRowCount(2);
    cBox.addMouseListener(this);
    cBox.setSelectedIndex(driver.allFiles ? 1 : 0);

    order = new Vector<Component>(9);
    order.add(text);
    order.add(butParent);
    order.add(butNF);
    order.add(panel); // just a place-holder - will be filled in by
    // buildList
    order.add(text2);
    order.add(butCopy);
    order.add(butOK);
    order.add(cBox);
    order.add(butDel);
    order.add(butCancel);

    text.setEditable(true);
    text.setEnabled(true);

    // text.getDocument().addDocumentListener(this);

    text2.setEditable(true);
    text2.setEnabled(true);
    text2.setRequestFocusEnabled(true);
    // text2.addKeyListener(this);
    // text2.getDocument().addDocumentListener(this);
    text2.setPreferredSize(new Dimension(100, driver.fontHeight + 2));

    text3.setEditable(false);
    text3.setEnabled(true);
    // text3.setRequestFocusEnabled(true);
    text3.setFont(driver.fontg.deriveFont(Font.ITALIC));
    // text3.setPreferredSize(new Dimension(100, driver.fontHeight + 2));

    String s = (saveAs) ? "Save or Save As" : "Open File";
    comp = new MyFileCompare();
    renderer = new ListRenderer(driver);

    if (fCParms == driver.curDiag.fCPArr[DrawFBP.DIAGRAM]) dialog.setTitle(s);
    else {
      if (fCParms == driver.curDiag.fCPArr[DrawFBP.GENCODE])
        fCParms.prompt =
            "Specify file name for generated code - for diagram: " + driver.curDiag.title + ".drw";

      dialog.setTitle(fCParms.prompt);
      if (fCParms == driver.curDiag.fCPArr[DrawFBP.CLASS]) listShowingJarFile = listHead;
    }

    enterAction = new EnterAction();
    copyAction = new CopyAction();
    cancelAction = new CancelAction();
    deleteAction = new DeleteAction();

    parentAction = new ParentAction();
    newFolderAction = new NewFolderAction();

    butParent.setAction(parentAction);
    butParent.setText("Parent Folder");
    butParent.setMnemonic(KeyEvent.VK_P);

    butNF.setAction(newFolderAction);
    butNF.setMnemonic(KeyEvent.VK_N);
    butNF.setText("New Folder");

    // butOK.setAction(okAction);
    butOK.setAction(enterAction);
    butCopy.setAction(copyAction);
    butCancel.setAction(cancelAction);
    butDel.setAction(deleteAction);

    butParent.setRequestFocusEnabled(true);
    butNF.setRequestFocusEnabled(true);
    butCopy.setRequestFocusEnabled(true);

    text.addMouseListener(this);
    text2.addMouseListener(this);

    panel.setPreferredSize(new Dimension(600, 600));

    text.setFocusTraversalKeysEnabled(false);
    butParent.setFocusTraversalKeysEnabled(false);
    butNF.setFocusTraversalKeysEnabled(false);
    text2.setFocusTraversalKeysEnabled(false);
    butOK.setFocusTraversalKeysEnabled(false);
    butDel.setFocusTraversalKeysEnabled(false);
    butCancel.setFocusTraversalKeysEnabled(false);
    butCopy.setFocusTraversalKeysEnabled(false);

    butParent.setEnabled(true);
    butNF.setEnabled(true);
    butOK.setEnabled(true);
    // butCopy.setEnabled(saveAs);
    butCopy.setEnabled(true);
    butCancel.setEnabled(true);
    butDel.setEnabled(true);

    KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
    panel.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(escape, "CLOSE");

    panel.getActionMap().put("CLOSE", cancelAction);

    JLabel label = new JLabel("Current folder: ");
    label.setFont(driver.fontg);

    Box box0 = new Box(BoxLayout.Y_AXIS);
    Box box1 = new Box(BoxLayout.X_AXIS);

    box1.add(label);

    box1.add(Box.createRigidArea(new Dimension(12, 0)));
    box1.add(text);
    box1.add(Box.createRigidArea(new Dimension(6, 0)));

    box1.add(butParent);
    // butParent.addActionListener(this);
    box1.add(Box.createRigidArea(new Dimension(6, 0)));

    // butNF.addActionListener(this);
    box1.add(butNF);

    box0.add(Box.createRigidArea(new Dimension(0, 20)));
    box0.add(box1);

    box0.add(Box.createRigidArea(new Dimension(0, 20)));
    panel.add(box0, BorderLayout.NORTH);

    text.setFont(label.getFont());
    text.addActionListener(this);
    text2.addActionListener(this);

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;

    JPanel pan2 = new JPanel();

    pan2.setLayout(gridbag);
    // c.fill = GridBagConstraints.BOTH;

    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0.0;

    JLabel lab1 = new JLabel("File name: ");
    gridbag.setConstraints(lab1, c);
    pan2.add(lab1);

    c.gridx = 1;
    c.weightx = 0.0;
    JLabel lab5 = new JLabel("  ");
    gridbag.setConstraints(lab5, c);
    pan2.add(lab5);

    c.gridx = 2;

    c.weightx = saveAs ? 0.1 : 1.0;
    c.gridwidth = saveAs ? 1 : 3;
    // c.ipadx  = saveAs ? -20: 0;
    gridbag.setConstraints(text2, c);
    pan2.add(text2);

    if (saveAs) {
      c.gridx = 3;
      c.weightx = 0.0;
      c.gridwidth = 1;
      JLabel lab6 = new JLabel("   Suggestion: ");
      gridbag.setConstraints(lab6, c);
      pan2.add(lab6);

      c.gridx = 4;
      c.weightx = 0.9;
      // c.ipadx = 20;
      gridbag.setConstraints(text3, c);
      pan2.add(text3);
      text3.setBackground(Color.WHITE);
      Dimension dim = text3.getPreferredSize();
      text3.setPreferredSize(new Dimension(driver.fontWidth * 25, dim.height));
    }

    c.gridx = 5;
    c.weightx = 0.0;
    JLabel lab7 = new JLabel("  ");
    gridbag.setConstraints(lab7, c);
    pan2.add(lab7);

    c.gridx = 6;
    c.weightx = 0.0;

    if (saveAs) {
      c.gridwidth = 1;
      gridbag.setConstraints(butCopy, c);
      pan2.add(butCopy);

      c.gridx = 7;
      c.weightx = 0.0;

      c.gridwidth = 1;
    } else c.gridwidth = 2;
    gridbag.setConstraints(butOK, c);
    pan2.add(butOK);

    c.weightx = 0.0;
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;

    JLabel lab2 = new JLabel("Files of type:");
    gridbag.setConstraints(lab2, c);
    pan2.add(lab2);

    c.gridx = 1;
    c.weightx = 0.0;
    JLabel lab8 = new JLabel("  ");
    gridbag.setConstraints(lab8, c);
    pan2.add(lab8);

    c.gridx = 2;
    c.weightx = 1.0;
    c.gridwidth = 3;
    gridbag.setConstraints(cBox, c);
    pan2.add(cBox);
    cBox.addActionListener(this);

    c.gridx = 5;
    c.weightx = 0.0;
    c.gridwidth = 1;
    JLabel lab9 = new JLabel("  ");
    gridbag.setConstraints(lab9, c);
    pan2.add(lab9);

    c.gridx = 6;
    c.weightx = 0.0;
    gridbag.setConstraints(butDel, c);
    pan2.add(butDel);

    c.gridx = 7;
    c.weightx = 0.0;
    gridbag.setConstraints(butCancel, c);
    pan2.add(butCancel);

    butOK.setText("OK");
    butOK.setFont(driver.fontg.deriveFont(Font.BOLD));
    butCancel.setText("Cancel");
    butDel.setText("Delete");
    butCopy.setText(saveAs ? "Use suggested name" : "");

    JLabel lab3 = new JLabel();
    lab3.setPreferredSize(new Dimension(500, 30));
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 4;
    c.weightx = 1.0;
    gridbag.setConstraints(lab3, c);
    pan2.add(lab3);

    cBox.addActionListener(this);

    // cBox.setUI(new BasicComboBoxUI());
    cBox.setRenderer(new ComboBoxRenderer());

    Dimension dim = new Dimension(1000, 800);
    dialog.setPreferredSize(dim);

    dialog.setFocusTraversalKeysEnabled(false);
    text.addKeyListener(this);
    text2.addKeyListener(this);
    butParent.addKeyListener(this); // needed to service tab keys
    butNF.addKeyListener(this); // needed to service tab keys
    butOK.addKeyListener(this); // needed to service tab keys
    cBox.addKeyListener(this); // needed to service tab keys
    butDel.addKeyListener(this); // needed to service tab keys
    butCancel.addKeyListener(this); // needed to service tab keys
    butCopy.addKeyListener(this); // needed to service tab keys
    cBox.setFocusTraversalKeysEnabled(false);
    mtp = new MyTraversalPolicy();
    setFocusTraversalPolicy(mtp);
    setFocusCycleRoot(false);

    showList();
    if (saveAs) {

      if (suggestedName != null && !(suggestedName.equals(""))) {
        File h = new File(suggestedName);
        listHead = h.getParent();
        text.setText(listHead);
        text2.setText(h.getName());
        text3.setText(h.getName());

        /*
        SwingUtilities.invokeLater(new Runnable() {
        	public void run() {
        		text2.requestFocusInWindow();
        		selComp = text2;
        		text2.setBackground(vLightBlue);
        	}
        });

        */

        text2.addAncestorListener(new RequestFocusListener(false));
        selComp = text2;
        // text2.setBackground(vLightBlue);
        // text2.setEditable(true);
      }

      if (driver.curDiag.title != null && driver.curDiag.diagFile != null) {
        s += " (current file: " + driver.curDiag.diagFile.getAbsolutePath() + ")";
      }
    } else {
      text.setText(listHead);
      /*
      SwingUtilities.invokeLater(new Runnable() {
      	public void run() {
      		list.requestFocusInWindow();
      		selComp = list;
      		// list.setBackground(vLightBlue);
      	}
      });
      */
      // list.addAncestorListener( new RequestFocusListener() );
      selComp = list;
    }

    panel.add(pan2, BorderLayout.SOUTH);
    dialog.add(panel);

    dialog.pack();
    dialog.setLocation(200, 100);
    frame.pack();

    dialog.setVisible(true);

    // if (!saveAs)
    // textBackground = Color.WHITE;

    frame.repaint();

    return result;
  }
Beispiel #9
0
    public void actionPerformed(ActionEvent e) {

      if (selComp instanceof MyButton) {
        // ((MyButton) selComp).getAction().actionPerformed(new
        // ActionEvent(e, 0, ""));
        if (selComp == butOK) return;
        ((MyButton) selComp).doClick();
        return;
      }

      if (selComp == text) {
        String u = text.getText();
        File h = new File(u);
        if (!h.exists() || !h.isDirectory()) {
          MyOptionPane.showMessageDialog(
              driver.frame, "File " + u + " either doesn't exist or is not a directory");

          return;
        }
        listHead = u;
        // panel.remove(listView);
        text.setBackground(vLightBlue);
        showList();
        return;
      }
      if (selComp == text2) {
        // fullNodeName = text.getText() + File.separator
        // + text2.getText();
        // if (!saveAs)
        processOK();
      }

      if (!(selComp instanceof JList)) return;

      butNF.setEnabled(!inJarTree);
      butDel.setEnabled(!inJarTree);

      String s = "";

      int rowNo = list.getSelectedIndex();
      if (nodeNames.length == 0) return;
      if (rowNo == -1) return;
      s = nodeNames[rowNo];

      File f = null;

      if (
      /*s.startsWith("JavaFBP") &&*/ s.toLowerCase().endsWith(".jar")) {
        butNF.setEnabled(false);
        butDel.setEnabled(false);
        // if (filter instanceof DrawFBP.JarFileFilter)
        if (fCParms == driver.curDiag.fCPArr[DrawFBP.JARFILE]
            || fCParms == driver.curDiag.fCPArr[DrawFBP.JHALL]) {
          processOK();
          return;
        }

        // jarTree = buildJarFileTree(driver.javaFBPJarFile);
        jarTree = buildJarFileTree(s);
        inJarTree = true;
        butNF.setEnabled(!inJarTree);
        butDel.setEnabled(!inJarTree);
        currentNode = jarTree;
        text2.setText("");

        if (0 >= currentNode.getChildCount()) {
          MyOptionPane.showMessageDialog(driver.frame, "Error in jar file");
          return;
        }

        // listHead = driver.javaFBPJarFile + "!";
        listHead = s + "!";
        text.setText(listHead);
        // panel.remove(listView);
        showList();

      } else if (!inJarTree) {

        if (s.equals("")) f = new File(listHead);
        else {
          // int i = listHead.lastIndexOf("package.json");
          // if (i > -1)
          // listHead = listHead.substring(0, i - 1);
          f = new File(DrawFBP.makeAbsFileName(s, listHead));
        }

        if (!f.exists()) {

          if (!saveAs /* || selComp == text2 && !(text2.equals("")) */) processOK();
          else
            MyOptionPane.showMessageDialog(
                driver.frame, "File/folder does not exist: " + f.getAbsolutePath());
          return;
        }
        if (f.isDirectory() || f.getName().toLowerCase().endsWith("package.json")) {

          listHead = f.getAbsolutePath();
          // showFileNames();

          // panel.remove(listView);
          showList();

        } else
          // if (!saveAs)
          processOK();
      } else { // inJarTree

        currentNode = findChild(currentNode, s);
        if (currentNode == null) return;
        if (currentNode.getChildCount() > 0) listHead = listHead + File.separator + s;
        if (0 < currentNode.getChildCount()) {

          // panel.remove(listView);
          showList();

        } else
          // if (!saveAs)
          processOK();
      }

      // }
      dialog.repaint();
      frame.repaint();
    }
Beispiel #10
0
  public void keyPressed(KeyEvent e) {

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

      text2.setBackground(Color.WHITE);
      // list.setSelectedIndex(-1);
      cBox.repaint();
      // if (saveAs)
      // text2.setBackground(Color.WHITE);

      if (selComp == cBox) cBox.setRequestFocusEnabled(false);
      if (selComp instanceof MyButton) {
        ((MyButton) selComp).setSelected(false);
      }
      // selComp.setRequestFocusEnabled(false);
      selComp.setFocusable(false);

      // list.setSelectedIndex(-1);

      if (!shift) selComp = (JComponent) mtp.getComponentAfter(dialog, selComp);
      else selComp = (JComponent) mtp.getComponentBefore(dialog, selComp);

      if (selComp == butCopy && !saveAs)
        if (!shift) selComp = (JComponent) mtp.getComponentAfter(dialog, selComp);
        else selComp = (JComponent) mtp.getComponentBefore(dialog, selComp);

      if (selComp == text || selComp == text2) {
        selComp.setBackground(vLightBlue);
        ((JTextField) selComp).getCaret().setVisible(true);
        ((JTextField) selComp).setEditable(true);
      }

      if (selComp == null) {
        selComp = list;
      } else if (selComp instanceof MyButton) ((MyButton) selComp).setSelected(true);

      if (selComp instanceof MyComboBox) {

        cBox.setBackground(vLightBlue);
      }

      selComp.setFocusable(true);
      selComp.requestFocusInWindow();

    } else if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
      shift = true;
    } else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
      // if (selComp instanceof JList || selComp == text || selComp ==
      // text2) {

      enterAction.actionPerformed(new ActionEvent(e, 0, ""));
      // }
    } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
      // if (selComp instanceof JList) {

      cancelAction.actionPerformed(new ActionEvent(e, 0, ""));
      // }
    } else if (e.getKeyCode() == KeyEvent.VK_DELETE) {
      if (selComp instanceof JList) {

        deleteAction.actionPerformed(new ActionEvent(e, 0, ""));
      }
    } else if (selComp == cBox
        && ((e.getKeyCode() == KeyEvent.VK_UP) && driver.allFiles
            || (e.getKeyCode() == KeyEvent.VK_DOWN) && !driver.allFiles)) {

      driver.allFiles = !driver.allFiles;
      cBox.setSelectedIndex(driver.allFiles ? 1 : 0);

      return;
    }
    // else if (selComp == text || selComp == text2) {
    //	selComp = (Component) e.getSource();
    // }

    // repaint();
    // String u = list.getSelectedValue(); // force selection
    // list.setSelectedValue(u, false);
    paintList();
    list.repaint();
    repaint();
  }
Beispiel #11
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();
  }