Example usage for javafx.scene.input MouseButton PRIMARY

List of usage examples for javafx.scene.input MouseButton PRIMARY

Introduction

In this page you can find the example usage for javafx.scene.input MouseButton PRIMARY.

Prototype

MouseButton PRIMARY

To view the source code for javafx.scene.input MouseButton PRIMARY.

Click Source Link

Document

Represents primary (button 1, usually the left) mouse button.

Usage

From source file:account.management.controller.ViewPOVoucherController.java

/**
 * Initializes the controller class./*  w  ww  . j  a v a  2 s  .  com*/
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    this.no.setCellValueFactory(new PropertyValueFactory("id"));
    this.date.setCellValueFactory(new PropertyValueFactory("date"));
    this.name.setCellValueFactory(new PropertyValueFactory("name"));
    this.address.setCellValueFactory(new PropertyValueFactory("address"));
    this.total_amount.setCellValueFactory(new PropertyValueFactory("total_amount"));
    this.opening.setCellValueFactory(new PropertyValueFactory("opening"));
    this.total.setCellValueFactory(new PropertyValueFactory("total"));
    this.cash.setCellValueFactory(new PropertyValueFactory("cash"));
    this.balance.setCellValueFactory(new PropertyValueFactory("balance"));

    this.table.setOnMouseClicked((MouseEvent mouseEvent) -> {
        if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) {
            if (mouseEvent.getClickCount() == 2) {
                POVoucher po = this.table.getSelectionModel().getSelectedItem();
                try {
                    showReport(po.getId(), po.getName(), po.getAddress(), po.getDate(), po.getContent(),
                            po.getTotal_amount(), po.getOpening(), po.getTotal(), po.getCash(),
                            po.getBalance());
                } catch (ParseException ex) {
                    Logger.getLogger(ViewPOVoucherController.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    });

}

From source file:account.management.controller.ViewVouchersController.java

@Override
public void initialize(URL url, ResourceBundle rb) {

    new AutoCompleteComboBoxListener<>(select_location);
    select_location.setOnHiding((e) -> {
        Location a = select_location.getSelectionModel().getSelectedItem();
        select_location.setEditable(false);
        select_location.getSelectionModel().select(a);
    });/*from   www .  j a  v a2 s.c o m*/
    select_location.setOnShowing((e) -> {
        select_location.setEditable(true);
    });

    new AutoCompleteComboBoxListener<>(select_voucher_type);
    select_voucher_type.setOnHiding((e) -> {
        VoucherType a = select_voucher_type.getSelectionModel().getSelectedItem();
        select_voucher_type.setEditable(false);
        select_voucher_type.getSelectionModel().select(a);
    });
    select_voucher_type.setOnShowing((e) -> {
        select_voucher_type.setEditable(true);
    });

    account_list = FXCollections.observableArrayList();
    this.account_list = this.getAccounts();
    c_id.setCellValueFactory(new PropertyValueFactory("id"));
    c_date.setCellValueFactory(new PropertyValueFactory("date"));
    c_location.setCellValueFactory(new PropertyValueFactory("location"));
    c_narration.setCellValueFactory(new PropertyValueFactory("narration"));
    c_voucher_type.setCellValueFactory(new PropertyValueFactory("voucher_type"));

    table.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent mouseEvent) {
            if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) {
                if (mouseEvent.getClickCount() == 2) {
                    try {
                        JSONArray res = Unirest.get(MetaData.baseUrl + "get/voucher/with/date")
                                .queryString("start_date", start_date.getValue().toString())
                                .queryString("end_date", end_date.getValue().toString())
                                .queryString("id", table.getSelectionModel().getSelectedItem().getId()).asJson()
                                .getBody().getArray();
                        Voucher v = table.getSelectionModel().getSelectedItem();
                        gerReport("VN" + String.format("%03d", Integer.parseInt(v.getId())), v.getDate(),
                                v.getNarration(), v.getVoucher_type(), v.getLocation(), res.toString());
                        System.out.println(res);
                    } catch (UnirestException ex) {
                        Logger.getLogger(ViewVouchersController.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        }
    });

    locations = FXCollections.observableArrayList();
    new Thread(() -> {
        try {
            HttpResponse<JsonNode> response = Unirest.get(MetaData.baseUrl + "get/locations").asJson();
            JSONArray location_array = response.getBody().getArray();
            locations.add(new Location(0, "All", ""));
            for (int i = 0; i < location_array.length() - 1; i++) {
                String name = location_array.getJSONObject(i).getString("name");
                String details = location_array.getJSONObject(i).getString("details");
                int id = location_array.getJSONObject(i).getInt("id");
                locations.add(new Location(id, name, details));
            }
            select_location.getItems().addAll(locations);

        } catch (UnirestException ex) {
            System.out.println("exception in UNIREST");
        }
    }).start();

    new Thread(() -> {
        try {
            HttpResponse<JsonNode> res = Unirest.get(MetaData.baseUrl + "get/voucher/type").asJson();
            JSONArray type = res.getBody().getArray();
            this.select_voucher_type.getItems().add(new VoucherType(0, "All", ""));
            for (int i = 0; i < type.length(); i++) {
                JSONObject obj = type.getJSONObject(i);
                int id = Integer.parseInt(obj.get("id").toString());
                String name = obj.get("type_name").toString();
                String note = obj.get("details").toString();
                this.select_voucher_type.getItems().add(new VoucherType(id, name, note));
            }
        } catch (UnirestException ex) {
            Logger.getLogger(NewVoucherController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }).start();
}

From source file:com.ggvaidya.scinames.complexquery.ComplexQueryViewController.java

private void initDataTable() {
    dataTableView.setOnMouseClicked(evt -> {
        if (evt.getButton().equals(MouseButton.PRIMARY) && evt.getClickCount() >= 2) {
            // Double-click on row!
            Object row = dataTableView.getSelectionModel().getSelectedItem();

            // What is this?
            if (Change.class.isAssignableFrom(row.getClass())) {
                // Be the change you want to see in the world.
                Change ch = (Change) row;

                DatasetChangesView view = new DatasetChangesView(projectView, ch);
                view.getStage().show();//from   w  w  w . j a  v  a  2 s .  c o  m
            } else {
                LOGGER.warning("Could not find handler for double-clicking on " + row);
            }
        }
    });
}

From source file:com.ggvaidya.scinames.ui.BulkChangeEditorController.java

/**
 * Initializes the controller class.//from w  w w.  j av  a2s. c o  m
 */
public void initialize() {
    comboBoxMethods.setEditable(false);
    comboBoxMethods.setConverter(new StringConverter<ChangeGenerator>() {

        @Override
        public String toString(ChangeGenerator generator) {
            return generator.getName();
        }

        @Override
        public ChangeGenerator fromString(String string) {
            return null;
        }

    });
    comboBoxMethods.setItems(availableMethods);
    comboBoxMethods.getSelectionModel().clearAndSelect(0);
    changesTableView.setOnMouseClicked(ms -> {
        if (ms.getClickCount() == 2 && ms.getButton().equals(MouseButton.PRIMARY)) {
            selectChange(changesTableView.getSelectionModel().getSelectedItem());
        }
    });

    foundChanges.addListener((ListChangeListener) evt -> {
        statusTextField.setText(foundChanges.size() + " changes generated from "
                + foundChanges.stream().map(ch -> ch.getDataset()).distinct().count() + " datasets");
    });
}

From source file:ca.wumbo.doommanager.client.controller.file.entry.PlaypalController.java

@FXML
private void initialize() {
    // We want the canvas resizing with the stack pane.
    overlayCanvas.widthProperty().bind(rootStackPane.widthProperty());
    overlayCanvas.heightProperty().bind(rootStackPane.heightProperty());

    // Any time the dimensions change, we want to draw the canvas again.
    rootStackPane.widthProperty().addListener((event) -> repaintPlaypalCanvas());
    rootStackPane.heightProperty().addListener((event) -> repaintPlaypalCanvas());

    // The canvas in the middle should resize to it's container.
    borderPane.widthProperty().addListener((event) -> resizeAndRepaintCanvas());
    borderPane.heightProperty().addListener((event) -> resizeAndRepaintCanvas());

    // We want to get mouse events when the user clicks.
    paletteCanvas.setOnMouseClicked(event -> {
        // Left mouse click should select if we can.
        if (event.getButton() == MouseButton.PRIMARY) {
            handlePaletteCanvasLeftClick((int) event.getX(), (int) event.getY());
        }/*from   ww  w  .  ja v a2 s.  c  o  m*/
    });

    // Default to the label values.
    redSelectionLabel.setText(RED_TEXT);
    greenSelectionLabel.setText(GREEN_TEXT);
    blueSelectionLabel.setText(BLUE_TEXT);
}

From source file:eu.ggnet.dwoss.redtape.document.DocumentUpdateView.java

private void initFxComponents() {
    final JFXPanel jfxp = new JFXPanel();
    positionPanelFx.add(jfxp, BorderLayout.CENTER);

    Platform.runLater(() -> {//from  w  ww .  ja  va 2s.  co m
        BorderPane pane = new BorderPane();
        Scene scene = new Scene(pane, Color.ALICEBLUE);

        positionsFxList = new ListView<>();
        positionsFxList.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
        positionsFxList.setCellFactory(new PositionListCell.Factory());
        positionsFxList.setItems(positions);
        positionsFxList.setOnMouseClicked((mouseEvent) -> {
            if (mouseEvent.getButton().equals(MouseButton.PRIMARY) && mouseEvent.getClickCount() == 2) {
                if (isChangeAllowed()) {
                    controller.editPosition(positionsFxList.getSelectionModel().getSelectedItem());
                    positionsFxList.refresh();
                } else {
                    Alert.show("nderung an Positionen ist nicht erlaubt.");
                }
            }
        });

        pane.setCenter(positionsFxList);
        jfxp.setScene(scene);
    });
}

From source file:eu.mihosoft.vrl.fxscad.MainController.java

private void compile(String code) {

    csgObject = null;/*from w w w .j a va  2  s.  c  o  m*/

    clearLog();

    viewGroup.getChildren().clear();

    try {

        CompilerConfiguration cc = new CompilerConfiguration();

        cc.addCompilationCustomizers(
                new ImportCustomizer().addStarImports("eu.mihosoft.vrl.v3d", "eu.mihosoft.vrl.v3d.samples")
                        .addStaticStars("eu.mihosoft.vrl.v3d.Transform"));

        GroovyShell shell = new GroovyShell(getClass().getClassLoader(), new Binding(), cc);

        Script script = shell.parse(code);

        Object obj = script.run();

        if (obj instanceof CSG) {

            CSG csg = (CSG) obj;

            csgObject = csg;

            MeshContainer meshContainer = csg.toJavaFXMesh();

            final MeshView meshView = meshContainer.getAsMeshViews().get(0);

            setMeshScale(meshContainer, viewContainer.getBoundsInLocal(), meshView);

            PhongMaterial m = new PhongMaterial(Color.RED);

            meshView.setCullFace(CullFace.NONE);

            meshView.setMaterial(m);

            viewGroup.layoutXProperty().bind(viewContainer.widthProperty().divide(2));
            viewGroup.layoutYProperty().bind(viewContainer.heightProperty().divide(2));

            viewContainer.boundsInLocalProperty().addListener((ov, oldV, newV) -> {
                setMeshScale(meshContainer, newV, meshView);
            });

            VFX3DUtil.addMouseBehavior(meshView, viewContainer, MouseButton.PRIMARY);

            viewGroup.getChildren().add(meshView);

        } else {
            System.out.println(">> no CSG object returned :(");
        }

    } catch (Throwable ex) {
        ex.printStackTrace(System.err);
    }
}

From source file:de.pixida.logtest.designer.automaton.Graph.java

public void onMouseClicked(final BaseObject baseObject, final MouseEvent event) {
    Validate.notNull(baseObject);/*w ww  . j  av a2s .c om*/

    this.contextMenu.hide();

    if (event.getButton() == MouseButton.PRIMARY) {
        if (this.connectorSourceNode != null) {
            Validate.notNull(this.connector);
            if (baseObject == this.currentConnectorTargetNode) {
                this.connector.attach(this.connectorSourceNode, this.currentConnectorTargetNode);

                this.connector = null;
                this.connectorSourceNode = null;
                this.currentConnectorTargetNode = null;

                this.handleChange();
            }
        }
        event.consume();
    } else if (event.getButton() == MouseButton.SECONDARY) {
        final ContextMenu objectContextMenu = baseObject.createContextMenu();
        if (objectContextMenu != null) {
            Node contextMenuOwner = baseObject.getActionHandler();
            if (contextMenuOwner == null) {
                contextMenuOwner = this.pane;
            }
            objectContextMenu.show(contextMenuOwner, event.getScreenX(), event.getScreenY());
            event.consume();
        }
    }
}

From source file:photobooth.views.ExplorerPane.java

private BorderPane createImageView(final File imageFile) {
    // DEFAULT_THUMBNAIL_WIDTH is a constant you need to define
    // The last two arguments are: preserveRatio, and use smooth (slower)
    // resizing//from   w  w w  . ja v  a2s. c  om
    ExplorerPane explorerPane = this;
    ImageView imageView = null;
    BorderPane borderPane = new BorderPane();
    try {
        borderPane.setMaxSize(100, 100);
        borderPane.setMinSize(100, 100);
        FileInputStream fileInputStream = new FileInputStream(imageFile);
        final Image image = new Image(fileInputStream, 100, 100, true, true);
        imageView = new ImageView(image);
        fileInputStream.close();
        imageView.getStyleClass().add("image-view");
        borderPane.setCenter(imageView);
        //imageView.setFitWidth(80);
        imageView.setOnMouseClicked(new EventHandler<MouseEvent>() {

            @Override
            public void handle(MouseEvent mouseEvent) {

                if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) {

                    if (mouseEvent.getClickCount() == 1) {
                        Global.getInstance().setSceneRoot(LoadingPane.getInstance());

                        Platform.runLater(() -> {
                            new Thread(new Runnable() {

                                @Override
                                public void run() {
                                    ImagePane.getInstance().init(explorerPane, imageFile);
                                    Global.getInstance().setSceneRoot(ImagePane.getInstance());
                                }
                            }).start();
                        });

                    }
                }
            }
        });
    } catch (FileNotFoundException ex) {
        ex.printStackTrace();
    } catch (IOException ex) {
        Logger.getLogger(ExplorerPane.class.getName()).log(Level.SEVERE, null, ex);
    }
    return borderPane;
}

From source file:calendarioSeries.vistas.MainViewController.java

public void populateImagenes() {
    Platform.runLater(new Runnable() {
        @Override// w w w .  j a v a  2s. com
        public void run() {
            imagenes.getChildren().clear();
            for (Serie serie : series) {
                //System.out.println(serie.getLastVisto());
                try {
                    Image image = new Image(serie.getUrlImagen());
                    ImageView poster = new ImageView();
                    ContextMenu menu = new ContextMenu();
                    //String css = MainApp.class.getResource("resources/MainTheme.css").toExternalForm();
                    MenuItem delete = new MenuItem("Eliminar");
                    delete.setId(serie.getId());
                    delete.setOnAction(new EventHandler<ActionEvent>() {
                        @Override
                        public void handle(ActionEvent event) {
                            menu.hide();
                            MenuItem clicked = (MenuItem) event.getSource();
                            String toDelete = clicked.getId();
                            for (Serie serie : series) {
                                if (serie.getId().equals(toDelete)) {
                                    series.remove(serie);
                                    populateImagenes();
                                    showDetallesMes(mesActual);
                                }
                            }
                            event.consume();
                        }
                    });

                    menu.getItems().add(delete);

                    poster.setId(serie.getTitulo());
                    poster.setImage(image);
                    poster.setCache(true);
                    // poster.setPreserveRatio(true);
                    poster.setFitWidth(210);
                    poster.setFitHeight(300);
                    poster.setOnContextMenuRequested(new EventHandler<ContextMenuEvent>() {
                        @Override
                        public void handle(ContextMenuEvent event) {
                            menu.show(poster, event.getScreenX(), event.getScreenY());
                            //menu.getScene().getRoot().getStylesheets().add(css);
                            event.consume();
                        }
                    });
                    poster.setOnMouseClicked(new EventHandler<MouseEvent>() {
                        @Override
                        public void handle(MouseEvent event) {
                            if (event.getButton() == MouseButton.PRIMARY) {
                                try {
                                    //serieToPass = serie;
                                    sceneToPass = mainApp.scene;

                                    FXMLLoader loader = new FXMLLoader(
                                            getClass().getResource("DetailsSerieController.fxml"));
                                    Parent root = loader.load();
                                    DetailsSerieController controller = loader.getController();
                                    controller.setData(serie, series);
                                    controller.setMainApp(mainApp);

                                    Scene scene = new Scene(root);
                                    mainApp.primaryStage.setScene(scene);
                                    mainApp.primaryStage.show();
                                } catch (IOException ex) {
                                    ex.printStackTrace();
                                }
                            }
                        }

                    });
                    imagenes.getChildren().add(poster);
                } catch (IllegalArgumentException e) {
                    Image image = new Image("file:src/calendarioSeries/resources/no-image.png");
                    ImageView poster = new ImageView();
                    ContextMenu menu = new ContextMenu();
                    MenuItem delete = new MenuItem("Eliminar");
                    delete.setId(serie.getId());
                    delete.setOnAction(new EventHandler<ActionEvent>() {
                        @Override
                        public void handle(ActionEvent event) {
                            menu.hide();
                            MenuItem clicked = (MenuItem) event.getSource();
                            String toDelete = clicked.getId();
                            for (Serie serie : series) {
                                if (serie.getId().equals(toDelete)) {
                                    series.remove(serie);
                                    populateImagenes();
                                    showDetallesMes(mesActual);
                                }
                            }
                            event.consume();
                        }
                    });

                    menu.getItems().add(delete);

                    poster.setId(serie.getTitulo());
                    poster.setImage(image);
                    poster.setCache(true);
                    //poster.setPreserveRatio(true);
                    poster.setFitWidth(210);
                    poster.setFitHeight(300);
                    poster.setOnContextMenuRequested(new EventHandler<ContextMenuEvent>() {
                        @Override
                        public void handle(ContextMenuEvent event) {
                            menu.show(poster, event.getScreenX(), event.getScreenY());
                            event.consume();
                        }
                    });
                    Text text = new Text(serie.getTitulo());
                    text.getStyleClass().add("label");
                    StackPane pane = new StackPane();
                    pane.getChildren().addAll(poster, text);

                    imagenes.getChildren().add(pane);
                } finally {
                    rellenarArchivo();
                }
            }
        }
    });

}