Example usage for javafx.scene.input MouseEvent getClickCount

List of usage examples for javafx.scene.input MouseEvent getClickCount

Introduction

In this page you can find the example usage for javafx.scene.input MouseEvent getClickCount.

Prototype

public final int getClickCount() 

Source Link

Document

Returns number of mouse clicks associated with this event.

Usage

From source file:de.bayern.gdi.gui.Controller.java

/**
 * Handle the service selection.// ww w. ja v  a 2 s  .  com
 *
 * @param event The mouse click event.
 */
@FXML
protected void handleServiceSelect(MouseEvent event) {
    if (event.getEventType().equals(MouseEvent.MOUSE_CLICKED)) {
        if (event.getClickCount() == 1) {
            clearUserNamePassword();
            ServiceModel serviceModel = (ServiceModel) this.serviceList.getSelectionModel().getSelectedItems()
                    .get(0);
            if (serviceModel != null) {
                serviceSelection.setDisable(true);
                serviceURL.getScene().setCursor(Cursor.WAIT);
                setStatusTextUI(I18n.format("status.checking-auth"));
                Task task = new Task() {
                    protected Integer call() {
                        try {
                            selectService(serviceModel.getItem());
                            return 0;
                        } finally {
                            serviceSelection.setDisable(false);
                            serviceURL.getScene().setCursor(Cursor.DEFAULT);
                        }
                    }
                };
                Thread th = new Thread(task);
                th.setDaemon(true);
                th.start();
            }
        } else if (event.getClickCount() > 1) {
            clearUserNamePassword();
            resetGui();
        }
    }
}

From source file:view.EditorView.java

@FXML
void scrollPaneOnMouseClicked(MouseEvent event) {
    /*//  ww  w .  j  a v a2 s  .  c o  m
    event.getTarget() instanceof RoomRectangle is necessary because the event is required twice:
    - once with event.getTarget() instanceof RoomRectangle and
    - once with event.getTarget() instanceof Label (the name label of the room)
    ... and we need to suppress one of the two because we don't want to insert two rooms
     */
    /*
    When the user uses a touch screen and adds a new room by clicking the insertRoom-button and then clicking the
    scrollPane, the event target is an instance of ScrollPaneSkin$4 which is an anonymous inner class in ScrollPane.
    Since we cannot directly check the class type using instanceof against that inner class, we need to use
    event.getTarget().getClass().getName() and do a String comparison for this particular use case.
    Keep in mind that this is an internal api of java and the class name of that class might change at ANY TIME so
    things might break just by upgrading the java version! (But we have no other choice unfortunately :( )
    See https://github.com/vatbub/zorkClone/issues/7 and http://stackoverflow.com/questions/41454202/javafx-instanceof-scrollpaneskin-fails
    for more info
     */
    FOKLogger.finest(EditorView.class.getName(), "scrollPaneOnMouseClicked occurred. event target class is "
            + event.getTarget().getClass().getName());
    if (currentEditMode == EditMode.INSERT_ROOM
            && (event.getTarget() instanceof RoomRectangle || event.getTarget() instanceof ToggleButton
                    || event.getTarget().getClass().getName()
                            .equals("com.sun.javafx.scene.control.skin.ScrollPaneSkin$4"))
            && event.getClickCount() == 1 && tempRoomForRoomInsertion != null) {
        // add tempRoomForRoomInsertion to the game
        FOKLogger.fine(MainWindow.class.getName(),
                "Added room to game: " + tempRoomForRoomInsertion.getRoom().getName());
        tempRoomForRoomInsertion.setTemporary(false);
        tempRoomForRoomInsertion.setSelected(false);
        allRoomsAsList.add(tempRoomForRoomInsertion);
        // this.renderView(false, false, true);
        this.renderView(false, false);

        this.setCurrentEditMode(this.getPreviousEditMode());
    }
}

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @param iLargeur//  w ww  . ja  va 2  s  .c o m
 * @param iHauteur
 * @param bMasqueZones
 * @param strIdZone
 * @param mouseEvent
 */
private static void choixZone(int iLargeur, int iHauteur, boolean bMasqueZones, String strIdZone,
        MouseEvent mouseEvent) {
    ComboBox cbTouchesBarre = new ComboBox();
    cbTouchesBarre.getItems().clear();
    for (int i = 0; i < strTouchesBarre.length; i++) {
        cbTouchesBarre.getItems().add(i, strTouchesBarre[i]);
    }
    cbTouchesBarre.setLayoutX(200);
    cbTouchesBarre.setLayoutX(40);

    final int iNumeroZone = Integer.parseInt(strIdZone.split("-")[1]);
    if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) {
        if (mouseEvent.getClickCount() == 2) {
            for (int ij = iNumeroZone; ij < iNombreZones - 1; ij++) {
                zones[ij] = zones[ij + 1];
            }
            iNombreZones--;
            afficheBarrePersonnalisee(iLargeur, iHauteur, bMasqueZones);
        } else {
            afficheBarrePersonnalisee(iLargeur, iHauteur, bMasqueZones);
            apZoneBarrePersonnalisee.getChildren().clear();
            apZoneBarrePersonnalisee.getChildren().add(cbTouchesBarre);
            ZoneTelecommande zone = zones[iNumeroZone];
            int index = -1;
            for (int ij = 0; ij < strCodeBarre.length; ij++) {
                if (strCodeBarre[ij].equals(zone.getStrIdZone())) {
                    index = ij;
                }
            }
            if (index != -1) {
                cbTouchesBarre.getSelectionModel().select(index);
            }

            cbTouchesBarre.valueProperty().addListener((ov, ancienneValeur, nouvelleValeur) -> {
                if (nouvelleValeur != null) {
                    String strId = strCodeBarre[cbTouchesBarre.getSelectionModel().getSelectedIndex()];
                    zones[iNumeroZone].setStrIdZone(strId);
                }
            });

            Label lblTypeBarre = new Label(zone.getStrTypeZone());
            lblTypeBarre.setLayoutX(20);
            lblTypeBarre.setLayoutY(40);
            Label lblCoordsBarre = new Label(zone.getStrCoordonneesZone());
            lblCoordsBarre.setLayoutX(20);
            lblCoordsBarre.setLayoutY(70);
            lblCoordsBarre.setPrefWidth(260);
            lblCoordsBarre.setMaxWidth(260);
            lblCoordsBarre.setWrapText(true);
            apZoneBarrePersonnalisee.getChildren().addAll(lblTypeBarre, lblCoordsBarre);
            switch (zone.getStrTypeZone()) {
            case "poly":
                Polygon poly = (Polygon) apImgBarrePersonnalisee.lookup("#" + strIdZone);
                poly.setFill(Color.rgb(255, 0, 0, 0.5));
                poly.setStroke(Color.YELLOW);
                apImgBarrePersonnalisee.getChildren()
                        .addAll(olCreeAncresPourPolygone(iNumeroZone, poly.getPoints()));
                break;
            case "rect":
                Rectangle rect = (Rectangle) apImgBarrePersonnalisee.lookup("#" + strIdZone);
                rect.setFill(Color.rgb(255, 0, 0, 0.5));
                rect.setStroke(Color.YELLOW);
                apImgBarrePersonnalisee.getChildren().addAll(olCreeAncresPourRectangle(iNumeroZone, rect));
                break;
            case "circle":
                Circle cercle = (Circle) apImgBarrePersonnalisee.lookup("#" + strIdZone);
                cercle.setFill(Color.rgb(255, 0, 0, 0.5));
                cercle.setStroke(Color.YELLOW);
                apImgBarrePersonnalisee.getChildren().addAll(olCreeAncresPourCercle(iNumeroZone, cercle));
                break;
            }

        }
    }

}