本文整理汇总了Java中javafx.scene.input.MouseEvent.getSource方法的典型用法代码示例。如果您正苦于以下问题:Java MouseEvent.getSource方法的具体用法?Java MouseEvent.getSource怎么用?Java MouseEvent.getSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.input.MouseEvent
的用法示例。
在下文中一共展示了MouseEvent.getSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
@Override
public void handle(MouseEvent event) {
// don't do anything if the user is in the process of adding to the selection model
if( event.isControlDown() || event.isShiftDown()) {
return;
}
Node node = (Node) event.getSource();
dragContext.x = node.getTranslateX() - event.getSceneX();
dragContext.y = node.getTranslateY() - event.getSceneY();
// clear the model if the current node isn't in the selection => new selection
if( !selectionModel.contains(node)) {
selectionModel.clear();
selectionModel.add( node);
}
// flag that the mouse released handler should consume the event, so it won't bubble up to the pane which has a rubberband selection mouse released handler
enabled = true;
// prevent rubberband selection handler
event.consume();
}
示例2: backPressed
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
public void backPressed(MouseEvent mouseEvent) throws IOException {
Button button = (Button) mouseEvent.getSource();
if ((button).getText().equals("BACK")) {
Stage current = (Stage) button.getScene().getWindow();
Parent root = FXMLLoader.load(getClass().getResource("menuSample.fxml"));
current.setScene(new Scene(root, screenSize.getWidth(), screenSize.getHeight()));
current.setMaximized(true);
current.show();
}
}
示例3: buttonPressed
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
@FXML
public void buttonPressed(MouseEvent actionEvent) throws IOException {
Button button = (Button)actionEvent.getSource();
if ((button).getText().equals("BACK"))
{
Stage current = (Stage)button.getScene().getWindow();
Parent root = FXMLLoader.load(getClass().getResource("menuSample.fxml"));
current.setMaximized(true);
current.setScene(new Scene(root, screenSize.getWidth(), screenSize.getHeight()));
//current.setFullScreen(true);
current.show();
}
}
示例4: setStat
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
public void setStat(MouseEvent event) {
Button button = (Button) event.getSource();
if (button.isDisabled()) {
return;
}
int value = Integer.valueOf(button.getText());
int min = pokemon.getMinIndividualValues().get(stat).get();
int max = pokemon.getMaxIndividualValues().get(stat).get();
history.addStat(stat, min, max);
if (!event.isShiftDown()) {
pokemon.setKnownStat(stat, value);
} else {
pokemon.setKnownIv(stat, statButtons.indexOf(button));
}
}
示例5: onMousePressed
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
public void onMousePressed(MouseEvent event){
mouseDragRectangle = new Rectangle();
mouseDragRectangle.setFill(null);
mouseDragRectangle.setStroke(Color.BLACK);
aDrawPane.getChildren().add(mouseDragRectangle);
mouseDragStartX = event.getX();
mouseDragStartY = event.getY();
if(event.getSource() instanceof AbstractNodeView){
mouseDragRectangle.setX(((AbstractNodeView)event.getSource()).getX() + mouseDragStartX);
mouseDragRectangle.setY(((AbstractNodeView)event.getSource()).getY() + mouseDragStartY);
} else {
mouseDragRectangle.setX(event.getX());
mouseDragRectangle.setY(event.getY());
}
}
示例6: buyClicked
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
public void buyClicked(MouseEvent mouseEvent) {
JFXButton button = (JFXButton) mouseEvent.getSource();
JFXRadioButton selectedRadio = (JFXRadioButton)group.getSelectedToggle();
String launderingTool = selectedRadio.getText();
if ((button).getText().equals("Buy!")){
for(int i = 0; i < crimeSize; i++)
{
if(selectedRadio.getText().equals(GameEngine.getCrimes.get(i).getDescription()))
{
GameEngine.purchaseAsset(GameEngine.getCrimes.get(i));
}
}
}
}
示例7: recordClick2
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
@Override public void recordClick2(final RFXComponent r, MouseEvent e, boolean withCellInfo) {
final JSONObject event = new JSONObject();
event.put("type", "click");
int button = e.getButton() == MouseButton.PRIMARY ? java.awt.event.MouseEvent.BUTTON1 : java.awt.event.MouseEvent.BUTTON3;
event.put("button", button);
event.put("clickCount", e.getClickCount());
event.put("modifiersEx", buildModifiersText(e));
double x = e.getX();
double y = e.getY();
Node source = (Node) e.getSource();
Node target = r.getComponent();
Point2D sts = source.localToScreen(new Point2D(0, 0));
Point2D tts = target.localToScreen(new Point2D(0, 0));
x = e.getX() - tts.getX() + sts.getX();
y = e.getY() - tts.getY() + sts.getY();
event.put("x", x);
event.put("y", y);
if (withCellInfo) {
event.put("cellinfo", r.getCellInfo());
}
final JSONObject o = new JSONObject();
o.put("event", event);
fill(r, o);
if (e.getClickCount() == 1) {
clickTimer = new Timer();
clickTimer.schedule(new TimerTask() {
@Override public void run() {
sendRecordMessage(o);
}
}, timerinterval.intValue());
} else if (e.getClickCount() == 2) {
if (clickTimer != null) {
clickTimer.cancel();
clickTimer = null;
}
sendRecordMessage(o);
}
}
示例8: recordRawMouseEvent
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
@Override public void recordRawMouseEvent(final RFXComponent r, MouseEvent e) {
final JSONObject event = new JSONObject();
event.put("type", "click_raw");
int button = e.getButton() == MouseButton.PRIMARY ? java.awt.event.MouseEvent.BUTTON1 : java.awt.event.MouseEvent.BUTTON3;
event.put("button", button);
event.put("clickCount", e.getClickCount());
event.put("modifiersEx", buildModifiersText(e));
Node source = (Node) e.getSource();
Node target = r.getComponent();
Point2D sts = source.localToScene(new Point2D(e.getX(), e.getY()));
Point2D tts = target.sceneToLocal(sts);
event.put("x", tts.getX());
event.put("y", tts.getY());
final JSONObject o = new JSONObject();
o.put("event", event);
fill(r, o);
if (e.getClickCount() == 1) {
clickTimer = new Timer();
clickTimer.schedule(new TimerTask() {
@Override public void run() {
sendRecordMessage(o);
}
}, timerinterval.intValue());
} else if (e.getClickCount() == 2) {
if (clickTimer != null) {
clickTimer.cancel();
clickTimer = null;
}
sendRecordMessage(o);
}
}
示例9: onMouseDragged
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
public void onMouseDragged(MouseEvent event){
if(event.getSource() instanceof AbstractNodeView){
mouseDragRectangle.setWidth(Math.abs(((AbstractNodeView)event.getSource()).getX() + event.getX() - mouseDragStartX));
mouseDragRectangle.setHeight(Math.abs(((AbstractNodeView)event.getSource()).getY() + event.getY() - mouseDragStartY));
mouseDragRectangle.setX(Math.min(mouseDragStartX, ((AbstractNodeView)event.getSource()).getX() + event.getX()));
mouseDragRectangle.setY(Math.min(mouseDragStartY, ((AbstractNodeView)event.getSource()).getY() + event.getY()));
} else {
mouseDragRectangle.setWidth(Math.abs(mouseDragStartX - event.getX()));
mouseDragRectangle.setHeight(Math.abs(mouseDragStartY - event.getY()));
mouseDragRectangle.setX(Math.min(mouseDragStartX, event.getX()));
mouseDragRectangle.setY(Math.min(mouseDragStartY, event.getY()));
}
}
示例10: onMouseDragged
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
public void onMouseDragged(MouseEvent event){
dragLine.setStartX(dragStartX);
dragLine.setStartY(dragStartY);
if(event.getSource() instanceof AbstractNodeView) {
dragLine.setEndX(event.getX() + ((AbstractNodeView) event.getSource()).getTranslateX());
dragLine.setEndY(event.getY() + ((AbstractNodeView) event.getSource()).getTranslateY());
} else {
dragLine.setEndX(event.getX());
dragLine.setEndY(event.getY());
}
}
示例11: onDragged
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
private void onDragged(MouseEvent event) {
if (event.getButton() == MouseButton.PRIMARY) {
if (dragActive) {
lastScreenX = event.getScreenX();
lastScreenY = event.getScreenY();
if (onResized != null && event.getSource() instanceof Region) {
Rectangle2D result = calculateNewSize((Region) event.getSource());
if (result != null) {
onResized.accept(result);
}
}
}
event.consume();
}
}
示例12: optionClicked
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
public void optionClicked(MouseEvent mouseEvent) {
JFXRadioButton button = (JFXRadioButton) mouseEvent.getSource();
text = (button).getText();
}
示例13: clickVille
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
@FXML
public void clickVille(MouseEvent event){
System.out.println("com.miage.pandemie.controller.BoardController.clickVille()");
Object obj = event.getSource();
if(obj instanceof Label){
tmpVilleClick = ((Label)obj).getText();
}
}
示例14: overVille
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
@FXML
public void overVille(MouseEvent event){
Object obj = event.getSource();
if(obj instanceof Label){
tmpVilleClick= ((Label)obj).getText();
}
try {
this.cdGame.getInfoVille(this.param.getName(),tmpVilleClick);
}
catch (RemoteException ex) {
Logger.getLogger(BoardController.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例15: handle
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
public void handle(MouseEvent event) {
// left mouse button => dragging
if (!event.isPrimaryButtonDown())
return;
nodeDragContext.mouseAnchorX = event.getSceneX();
nodeDragContext.mouseAnchorY = event.getSceneY();
Node node = (Node) event.getSource();
System.out.format("%10f,%10f%n", node.getTranslateX(), node.getTranslateY());
nodeDragContext.translateAnchorX = node.getTranslateX();
nodeDragContext.translateAnchorY = node.getTranslateY();
}