javafx.scene.input.MouseEvent.getTarget()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(157)

本文整理了Java中javafx.scene.input.MouseEvent.getTarget()方法的一些代码示例,展示了MouseEvent.getTarget()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MouseEvent.getTarget()方法的具体详情如下:
包路径:javafx.scene.input.MouseEvent
类名称:MouseEvent
方法名:getTarget

MouseEvent.getTarget介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

@FXML
private void dragDetected(MouseEvent event) {
  ImageView target = (ImageView) event.getTarget();
  // do something ...
}

代码示例来源:origin: stackoverflow.com

treeTableView.addEventHandler( MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>(){
  @Override
  public void handle( MouseEvent e )
  {
    TreeTableCell<Item, String> cell = (TreeTableCell<Item, String>) e.getTarget();
    TreeItem<Item> item = cell.getTreeTableView().getTreeItem( cell.getTreeTableRow().getIndex() );
    item.setExpanded( !item.isExpanded() );
  }
});

代码示例来源:origin: stackoverflow.com

hBox.setOnMouseClicked(new EventHandler<MouseEvent>() {
  @Override
  public void handle(MouseEvent mouseEvent) {
    if (mouseEvent.getTarget() == hBox) {
      System.out.println("hBox! " + mouseEvent.getTarget());
    } else {
      System.out.println("hBox Ignored! " + mouseEvent.getTarget());
    }
  }
});

image2.setOnMouseClicked(new EventHandler<MouseEvent>() {
  @Override
  public void handle(MouseEvent mouseEvent) {
    System.out.println("Image! " + mouseEvent.getTarget());
  }
});

代码示例来源:origin: stackoverflow.com

@FXML
private void tile1MouseClicked(MouseEvent event) {
  System.out.println("result : " + event.getTarget()); 
}

代码示例来源:origin: stackoverflow.com

@FXML
private void tile1MouseClicked(MouseEvent event) {
  System.out.println("result : " + event.getTarget()); 
}

代码示例来源:origin: stackoverflow.com

private int emptyTileX = 4;
private int emptyTileY = 4;

private boolean move(MouseEvent event) {
  Object target = event.getTarget();

  if (target instanceof ImageView) {
    ImageView iv = (ImageView) target;
    int row = GridPane.getRowIndex(iv);
    int column = GridPane.getColumnIndex(iv);

    int dx = Math.abs(column - emptyTileX);
    int dy = Math.abs(row - emptyTileY);

    if ((dx == 0 && dy == 1) || (dx == 1 && dy == 0)) {
      // swap image and empty tile, if they are next to each other
      GridPane.setConstraints(iv, emptyTileX, emptyTileY);
      emptyTileX = column;
      emptyTileY = row;
      return true;
    }
  }
  return false;
}

代码示例来源:origin: stackoverflow.com

tabPane.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent> () {
  @Override
  public void handle(MouseEvent mouseEvent) {
    EventTarget eventTarget = mouseEvent.getTarget();
    if (eventTarget instanceof StackPane) {
      StackPane stackPane = (StackPane) eventTarget;
      ObservableList<String> styleClasses = stackPane.getStyleClass();
      for (String styleClass : styleClasses) {
        if ("arrow".equals(styleClass) == true) {
          //TODO
          System.out.println("arrowEvent");
        }
      }
    }
  }
});

代码示例来源:origin: stackoverflow.com

@FXML
private void mouseEntered(MouseEvent e) {
  Node target = (Node) e.getTarget();
  // traverse towards root until userSelectionGrid is the parent node
  if (target != userSelectionGrid) {
    Node parent;
    while ((parent = target.getParent()) != userSelectionGrid) {
      target = parent;
    }
  }
  Integer colIndex = userSelectionGrid.getColumnIndex(target);
  Integer rowIndex = userSelectionGrid.getRowIndex(target);
  if (colIndex == null || rowIndex == null) {
    System.out.println("BOO");
  } else {
    System.out.printf("Mouse entered cell [%d, %d]%n", colIndex.intValue(), rowIndex.intValue());
  }
}

代码示例来源:origin: us.ihmc/ihmc-path-planning-visualizers

private static boolean hasListViewCellBeenDoubleClicked(MouseEvent event)
  {
   return event.getButton() == MouseButton.PRIMARY && event.getClickCount() == 2 && event.getTarget() instanceof LabeledText;
  }
}

代码示例来源:origin: stackoverflow.com

@Override
public void handle(MouseEvent event) {
  final ImageView iv = (ImageView) (event.getTarget());
  iv.setImage(new Image("popped.png"));
}

代码示例来源:origin: us.ihmc/ihmc-path-planning-test

private void handleDatasetSelection(MouseEvent event)
{
 if (event.getButton() == MouseButton.PRIMARY && event.getClickCount() == 2 && event.getTarget() instanceof LabeledText)
 {
   PrintTools.info("Submitting new dataset request");
   messager.submitMessage(CurrentDatasetPath, datasetsListView.getSelectionModel().getSelectedItem());
 }
}

代码示例来源:origin: stackoverflow.com

if (mouseEvent.getTarget() != this || textField.getParent() != null ) {
  return;

代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.ui.controls

EFXDragEvent evt = new EFXDragEvent(event.getSource(), event.getTarget(), EFXDragEvent.DRAG_START, event.getScreenX(), event.getScreenY(), false);
evt.setDraggedContent(data);
evt.updateFeedback(p -> {
Event.fireEvent(event.getTarget(),evt);
event.consume();

代码示例来源:origin: org.controlsfx/controlsfx

if (mouseEvent.getTarget().equals(getScene().getRoot())) {
  if (!isDetached()) {
    hide();

代码示例来源:origin: org.controlsfx/controlsfx

group.setTranslateY(0);
} else if (evt.getButton().equals(MouseButton.PRIMARY)) {
  EventTarget target = evt.getTarget();
  if (target instanceof WorldMapView.CountryView) {
    WorldMapView.CountryView path = (WorldMapView.CountryView) target;

相关文章