public void showPopupMenu(java.awt.event.MouseEvent evt) {
   int r = m_table.rowAtPoint(new Point(evt.getX(), evt.getY()));
   if (r != -1) {
     m_table.setRowSelectionInterval(r, r);
   }
   m_popupMenu.show(this, evt.getX(), evt.getY());
 }
    public void mousePressed(java.awt.event.MouseEvent e) {
      isClick = true;
      JButton b = (JButton) e.getSource();
      // check to see if the target button can be moved
      if (!solved && check(buttons.indexOf(b))) {
        // hide the target button
        b.setVisible(false);

        // Figure out the bounds of the areas where source
        // and target buttons are located
        int menuOffset = getJMenuBar().getHeight();
        dragSourceArea = b.getBounds();
        dragTargetArea = ((JButton) buttons.get(hiddenIndex)).getBounds();
        dragSourceArea.translate(0, menuOffset);
        dragTargetArea.translate(0, menuOffset);

        // setup the bounds of the panel to limit the locations on the drag
        // layer
        panelArea = new Rectangle(0, menuOffset, getJPanel().getWidth(), getJPanel().getHeight());

        // Setup and show the drag button on the upper layer
        getDragButton().setText(b.getText());
        getDragButton().setBounds(dragSourceArea);
        getDragButton().setVisible(true);

        // Offset when repositioning the drag button later
        cursorOffset = new Point(e.getX(), e.getY());
      }
    }
示例#3
0
  /**
   * Spusti se pri zmacknuti tlacitka. Pokud je pod mysi obraz figury, zjisti, zda se muze pohnout
   * (pokud ano, upravi ho pro tahnuti, nastavi ho do figLabel) a zobrazi kontextovou napovedu.
   */
  private void eCatcherMousePressed(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_eCatcherMousePressed
    if (figLabel != null || finished) {
      return;
    }
    BoardSquare bsquare = (BoardSquare) eCatcher.getComponentAt(evt.getPoint());

    JPanel fsquare = (JPanel) figurePan.getComponent(bsquare.getIndex());
    sourceBSquare = bsquare;
    Point defLocation = fsquare.getLocation();
    xAdjustment = (int) defLocation.getX() - evt.getX();
    yAdjustment = (int) defLocation.getY() - evt.getY();
    if (fsquare.getComponentCount() == 0) {
      return;
    }
    figLabel = (JLabel) fsquare.getComponent(0);

    setFocus(gui.getFocus(bsquare.getColumn(), bsquare.getRow()));
    if (!gui.canMove(bsquare.getColumn(), bsquare.getRow())) {
      figLabel = null;
      return;
    }
    fsquare.remove(figLabel);
    boardPane.add(figLabel, 0);
    figLabel.setLocation(evt.getX() + xAdjustment, evt.getY() + yAdjustment);
    figLabel.setSize(figLabel.getWidth(), figLabel.getHeight());
  } // GEN-LAST:event_eCatcherMousePressed
示例#4
0
 /** Spousti se pri tazeni mysi. Pokud je figLabel neprazdne, tahne drzenou figurou. */
 private void eCatcherMouseDragged(
     java.awt.event.MouseEvent evt) { // GEN-FIRST:event_eCatcherMouseDragged
   if (figLabel == null) {
     return;
   }
   figLabel.setLocation(evt.getX() + xAdjustment, evt.getY() + yAdjustment);
 } // GEN-LAST:event_eCatcherMouseDragged
  // ======================================================
  private void treeMouseClicked(java.awt.event.MouseEvent evt) {
    //	Set selection at mouse position
    TreePath selectedPath = getPathForLocation(evt.getX(), evt.getY());
    if (selectedPath == null) return;
    int mask = evt.getModifiers();

    //  Check button clicked
    if (evt.getClickCount() == 2 && (mask & MouseEvent.BUTTON1_MASK) != 0) {
    } else if ((mask & MouseEvent.BUTTON3_MASK) != 0) {
    }
  }
    public void mouseDragged(java.awt.event.MouseEvent e) {
      if (dragTargetArea != null) {
        // Since we're dragging, this is no longer considered a click
        isClick = false;

        // Draw the target feedback and position the drag button based
        // on the mouse's new location
        e.translatePoint(dragSourceArea.x, dragSourceArea.y);
        Point p = makeSafePoint(e.getX(), e.getY());
        paintTargetFeedback(p.x, p.y);
        getDragButton().setLocation(p.x - cursorOffset.x, p.y - cursorOffset.y);
      }
    }
 /**
  * DOCUMENT ME!
  *
  * @param evt DOCUMENT ME!
  */
 private void lstKassenzeichenMouseClicked(final java.awt.event.MouseEvent evt) {
   if (evt.getClickCount() == 2) {
     if (lstKassenzeichen.getSelectedValue() != null) {
       gotoSelectedKassenzeichen();
     }
   }
 }
 private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {
   // TODO add your handling code here:
   if (evt.getClickCount() == 2) {
     selected = jTable1.getValueAt(jTable1.getSelectedRow(), 0).toString();
     this.dispose();
   }
 }
 // ======================================================
 // ======================================================
 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 tableMousePressed(java.awt.event.MouseEvent evt) // GEN-FIRST:event_tableMousePressed
     { // GEN-HEADEREND:event_tableMousePressed
   System.out.println("pressed !");
   // Add your handling code here:
   if (evt.isPopupTrigger()) {
     System.out.println("trigger !");
     showPopupMenu(evt);
   }
 } // GEN-LAST:event_tableMousePressed
示例#11
0
  // Cette fonction pourrait etre optimisee en calculant le deplacement directement
  // Pas besoin de boucler
  void LightCalendar_MousePress(java.awt.event.MouseEvent event) {
    int x = 1;
    int y = drawMonthName ? 2 * (fm.getHeight() + 2) : (fm.getHeight());
    int w = getSize().width - 2;
    int h = getSize().height - y + 5;

    Rectangle r = new Rectangle(x, y, w, h);

    if (r.contains(event.getPoint())) {
      int caseWidth = w / 7;
      int caseHeight = h / 7;

      Calendar cal = Calendar.getInstance();
      cal.setTime(dateDebutMois);

      int nbJoursVides = cal.get(Calendar.DAY_OF_WEEK) - 1;
      int iJoursVides = 0;
      // int iJour = 1;

      Cases:
      for (int iRow = 0; iRow < 6; iRow++) {
        for (int iCol = 0; iCol < 7; iCol++) {
          // int day = cal.get( Calendar.DATE );
          if (iJoursVides < nbJoursVides) iJoursVides++;
          else if (cal.get(Calendar.MONTH) == mois) {
            int xCase = 1 + (iCol * caseWidth);
            int yCase = y + (iRow * caseHeight);
            Rectangle rCase = new Rectangle(xCase, yCase + 5, caseWidth, caseHeight);

            if (rCase.contains(event.getPoint())) {
              selectedDate = cal.getTime();
              selectedRow = iRow;
              selectedCol = iCol;
              parent.currentDate = selectedDate;
              repaint();
              break Cases;
            }

            cal.add(Calendar.DATE, 1);
          }
        }
      }
    }
  }
示例#12
0
  private void tabelaMouseClicked(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_tabelaMouseClicked

    if (evt.getClickCount() == 2) {
      timer.stop();
      JobLote job = modelo.getJob(tabela.convertRowIndexToModel(tabela.getSelectedRow()));
      ViewDGQPCP tela = new ViewDGQPCP(null, true, job, timer);
      tela.setVisible(true);
    }
  } // GEN-LAST:event_tabelaMouseClicked
 // ======================================================
 // ======================================================
 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);
   }
 }
示例#14
0
文件: Game.java 项目: jollex/Life
  // Used to change cell states manually when game isn't running
  private void manualCell(java.awt.event.MouseEvent e) {
    // Gets coordinates of clicked cell
    JLabel cell = (JLabel) e.getSource();
    int x = cell.getX() / 18;
    int y = cell.getY() / 18;

    // Changes state of the cell
    if (alive[x][y]) {
      alive[x][y] = false;
      cells[x][y].setIcon(white);
    } else {
      alive[x][y] = true;
      cells[x][y].setIcon(black);
    }
  }
示例#15
0
    public void mouseReleased(java.awt.event.MouseEvent e) {
      if (dragTargetArea != null) {

        // Turn off the drag button and feedback
        getDragButton().setVisible(false);
        paintTargetFeedback(-1, -1);

        e.translatePoint(dragSourceArea.x, dragSourceArea.y);
        Point p = makeSafePoint(e.getX(), e.getY());

        JButton b = (JButton) e.getSource();
        if (isClick || dragTargetArea.contains(p.x, p.y)) {
          // if we're considered a simple click, or the dragging ended
          // within the target area, perform the move.
          slide(buttons.indexOf(b));
        } else {
          // The drag finished outside the target, so just show the
          // hidden button and don't move anything.
          b.setVisible(true);
        }
        dragTargetArea = null;
        dragSourceArea = null;
      }
    }
示例#16
0
    protected void handleSelection(java.awt.event.MouseEvent evt) {
      if (tree != null && tree.isEnabled()) {
        if (isEditing(tree) && tree.getInvokesStopCellEditing() && !stopEditing(tree)) {
          return;
        }

        if (tree.isRequestFocusEnabled()) {
          tree.requestFocus();
        }
        TreePath path = getClosestPathForLocation(tree, evt.getX(), evt.getY());

        if (path != null) {
          Rectangle bounds = getPathBounds(tree, path);
          if (evt.getY() > (bounds.y + bounds.height)) {
            return;
          }
          if (SwingUtilities.isLeftMouseButton(evt))
            checkForClickInExpandControl(path, evt.getX(), evt.getY());
          if (!startEditing(path, evt)) {
            selectPathForEvent(path, evt);
          }
        }
      }
    }
示例#17
0
  private void tabelaMouseClicked(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_tabelaMouseClicked

    ajustaTabelaParaMobile();

    if (evt.getClickCount() == 2 && tabela.getSelectedRow() != -1) {

      int indice = tabela.getSelectedRow();
      if (indice != -1) {

        JobLote dados = modelo.getJob(tabela.convertRowIndexToModel(tabela.getSelectedRow()));
        timerTelaExclusao.stop();
        ExclusaoLoteView tela =
            new ExclusaoLoteView(null, true, dados, timerTelaExclusao, jBAtualizar);
        tela.setVisible(true);
      }
    }
  } // GEN-LAST:event_tabelaMouseClicked
示例#18
0
 /**
  * Spousti se pri uvolneni tlacitka mysi. Pokud byl tazen obraz figury, vyhodnoti tah a bud jej
  * potvrdi a ukonci tah hrace nebo zamitne a vrati obraz figury na puvodni pozici.
  */
 private void eCatcherMouseReleased(
     java.awt.event.MouseEvent evt) { // GEN-FIRST:event_eCatcherMouseReleased
   removeFocus();
   if (figLabel == null) {
     return;
   }
   figLabel.setVisible(false);
   boardPane.remove(figLabel);
   BoardSquare bsquare = (BoardSquare) eCatcher.getComponentAt(evt.getPoint());
   if (bsquare == null
       || !gui.move(
           sourceBSquare.getColumn(),
           sourceBSquare.getRow(),
           bsquare.getColumn(),
           bsquare.getRow())) {
     ((JPanel) figurePan.getComponent(sourceBSquare.getIndex())).add(figLabel);
     figLabel.setVisible(true);
   }
   figLabel = null;
 } // GEN-LAST:event_eCatcherMouseReleased
示例#19
0
 private void objectTableMouseClicked(java.awt.event.MouseEvent evt) {
   if (evt.getClickCount() == 2) {
     editCurrent();
   }
 }
示例#20
0
 public void mousePressed(java.awt.event.MouseEvent event) {
   Object object = event.getSource();
   if (object == LightCalendar.this) LightCalendar_MousePress(event);
 }
示例#21
0
 private void bookmarksListMouseClicked(
     java.awt.event.MouseEvent evt) { // GEN-FIRST:event_bookmarksListMouseClicked
   if (evt.getClickCount() == 2) {
     gotoButtonActionPerformed(null);
   }
 } // GEN-LAST:event_bookmarksListMouseClicked
 /**
  * DOCUMENT ME!
  *
  * @param evt DOCUMENT ME!
  */
 public void iconContainerMouseClicked(final java.awt.event.MouseEvent evt) {
   if ((evt.getClickCount() > 1) && (evt.getButton() == evt.BUTTON1) && (vali != null)) {
     vali.showAssistent(comp);
   }
 }