當前位置: 首頁>>代碼示例>>Java>>正文


Java MouseEvent.getSource方法代碼示例

本文整理匯總了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();
}
 
開發者ID:lttng,項目名稱:lttng-scope,代碼行數:26,代碼來源:ExampleMouseDrag2.java

示例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();
    }
}
 
開發者ID:gokcan,項目名稱:Mafia-TCoS-CS319-Group2A,代碼行數:11,代碼來源:SettingsController.java

示例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();
    }
}
 
開發者ID:gokcan,項目名稱:Mafia-TCoS-CS319-Group2A,代碼行數:14,代碼來源:CreditsController.java

示例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));
    }
}
 
開發者ID:wartab,項目名稱:gen7-iv-calculator,代碼行數:18,代碼來源:StatSelectorPresenter.java

示例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());
    }
}
 
開發者ID:kaanburaksener,項目名稱:octoBubbles,代碼行數:19,代碼來源:CreateNodeController.java

示例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));
            }
        }
    }
}
 
開發者ID:gokcan,項目名稱:Mafia-TCoS-CS319-Group2A,代碼行數:15,代碼來源:LaunderingController.java

示例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);
    }
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:39,代碼來源:WSRecorder.java

示例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);
    }
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:32,代碼來源:WSRecorder.java

示例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()));
    }
}
 
開發者ID:kaanburaksener,項目名稱:octoBubbles,代碼行數:15,代碼來源:CreateNodeController.java

示例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());
    }
}
 
開發者ID:kaanburaksener,項目名稱:octoBubbles,代碼行數:13,代碼來源:EdgeController.java

示例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();
    }
}
 
開發者ID:rmfisher,項目名稱:fx-animation-editor,代碼行數:16,代碼來源:ResizeBehavior.java

示例12: optionClicked

import javafx.scene.input.MouseEvent; //導入方法依賴的package包/類
public void optionClicked(MouseEvent mouseEvent) {
    JFXRadioButton button = (JFXRadioButton) mouseEvent.getSource();
    text = (button).getText();
}
 
開發者ID:gokcan,項目名稱:Mafia-TCoS-CS319-Group2A,代碼行數:5,代碼來源:CarController.java

示例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();

       }

    }
 
開發者ID:tillind,項目名稱:pandemie,代碼行數:18,代碼來源:BoardController.java

示例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);

        }
    }
 
開發者ID:tillind,項目名稱:pandemie,代碼行數:25,代碼來源:BoardController.java

示例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();

        }
 
開發者ID:INAETICS,項目名稱:Drones-Simulator,代碼行數:17,代碼來源:NodeGestures.java


注:本文中的javafx.scene.input.MouseEvent.getSource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。