Java Code Examples for javafx.scene.layout.VBox#setOnMouseClicked()

The following examples show how to use javafx.scene.layout.VBox#setOnMouseClicked() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RequestCollectionComponent.java    From milkman with MIT License 6 votes vote down vote up
private Node createRequestEntry(Collection collection, RequestContainer request) {
		Label requestType = new Label(request.getType());
		requestType.getStyleClass().add("request-type");
		Label button = new Label(request.getName());

		VBox vBox = new VBox(new HBox(requestType,button));
		vBox.getStyleClass().add("request-entry");
		vBox.setOnMouseClicked(e -> {
//			if (e.getButton() == MouseButton.PRIMARY)
//				onCommand.invoke(new UiCommand.LoadRequest(request.getId()));
//			else
			if (e.getButton() == MouseButton.PRIMARY) {
				onCommand.invoke(new UiCommand.LoadRequest(request.getId()));
				e.consume();
			}
			if (e.getButton() == MouseButton.SECONDARY) {
				reqCtxMenu.show(request, collection, vBox, e.getScreenX(), e.getScreenY());
				e.consume();
			}
				
		});
		return vBox;
	}
 
Example 2
Source File: TopBar.java    From Maus with GNU General Public License v3.0 6 votes vote down vote up
public VBox getTopBar(Stage stage) {
    Image image = new Image(getClass().getResourceAsStream("/Images/logo.png"));
    ImageView imageView = new ImageView(image);

    VBox vBox = new VBox();
    vBox.setAlignment(Pos.CENTER);
    Label label = (Label) Styler.styleAdd(new Label("Dashboard"), "label-light");
    vBox.getChildren().addAll(new ImageView(new Image(getClass().getResourceAsStream("/Images/Icons/icon.png"))), label);
    vBox.setPadding(new Insets(5, 10, 0, 5));
    vBox.setId("homeButton");


    VBox vBox1 = new VBox();
    vBox1.setAlignment(Pos.CENTER);
    vBox1.getChildren().add(new ImageView(new Image(getClass().getResourceAsStream("/Images/logo.png"))));
    vBox1.setPadding(new Insets(5, 10, 5, 5));

    HBox hBox = Styler.hContainer(new HBox(), vBox, vBox1);
    vBox.setOnMouseClicked(event -> Controller.changePrimaryStage(new MainView().getMainView()));
    imageView.setFitWidth(100);
    imageView.setFitHeight(50);
    return Styler.vContainer(new VBox(), new TitleBar().getMenuBar(stage), hBox);
}
 
Example 3
Source File: GameElimniationController.java    From MyBox with Apache License 2.0 4 votes vote down vote up
protected void makeChessBoard() {
    if (isSettingValues) {
        return;
    }
    try {
        chessBoard.clear();
        chessboardPane.getChildren().clear();
        chessboardPane.setPrefWidth((chessSize + 20) * boardSize);
        chessboardPane.setPrefHeight((chessSize + 20) * boardSize);
        DropShadow effect = new DropShadow();
        boolean shadow = shadowCheck.isSelected();
        boolean arc = arcCheck.isSelected();
        currentStyle = defaultStyle;
        if (arc) {
            currentStyle = arcStyle;
        } else if (shadow) {
            currentStyle = shadowStyle;
        }
        for (int i = 1; i <= boardSize; ++i) {
            HBox line = new HBox();
            line.setAlignment(Pos.CENTER);
            line.setSpacing(10);
            chessboardPane.getChildren().add(line);
            VBox.setVgrow(line, Priority.NEVER);
            HBox.setHgrow(line, Priority.NEVER);
            for (int j = 1; j <= boardSize; ++j) {
                VBox vbox = new VBox();
                vbox.setAlignment(Pos.CENTER);
                VBox.setVgrow(vbox, Priority.NEVER);
                HBox.setHgrow(vbox, Priority.NEVER);
                vbox.setSpacing(6);
                if (shadow) {
                    vbox.setEffect(effect);
                }
                vbox.setStyle(currentStyle);
                final int x = i, y = j;
                vbox.setOnMouseClicked(new EventHandler<MouseEvent>() {
                    @Override
                    public void handle(MouseEvent event) {
                        chessClicked(x, y);
                    }
                });
                line.getChildren().add(vbox);
                chessBoard.put(i + "-" + j, vbox);
            }
        }
    } catch (Exception e) {
        logger.debug(e.toString());
    }
}
 
Example 4
Source File: ArtistsController.java    From MusicPlayer with MIT License 4 votes vote down vote up
private VBox createCell(Artist artist) {

        VBox cell = new VBox();
        Label title = new Label(artist.getTitle());
        ImageView image = new ImageView(artist.getArtistImage());
        image.imageProperty().bind(artist.artistImageProperty());
        VBox imageBox = new VBox();

        title.setTextOverrun(OverrunStyle.CLIP);
        title.setWrapText(true);
        title.setPadding(new Insets(10, 0, 10, 0));
        title.setAlignment(Pos.TOP_LEFT);
        title.setPrefHeight(66);
        title.prefWidthProperty().bind(grid.widthProperty().subtract(100).divide(5).subtract(1));

        image.fitWidthProperty().bind(grid.widthProperty().subtract(100).divide(5).subtract(1));
        image.fitHeightProperty().bind(grid.widthProperty().subtract(100).divide(5).subtract(1));
        image.setPreserveRatio(true);
        image.setSmooth(true);

        imageBox.prefWidthProperty().bind(grid.widthProperty().subtract(100).divide(5).subtract(1));
        imageBox.prefHeightProperty().bind(grid.widthProperty().subtract(100).divide(5).subtract(1));
        imageBox.setAlignment(Pos.CENTER);
        imageBox.getChildren().add(image);

        cell.getChildren().addAll(imageBox, title);
        cell.setPadding(new Insets(10, 10, 0, 10));
        cell.getStyleClass().add("artist-cell");
        cell.setAlignment(Pos.CENTER);
        cell.setOnMouseClicked(event -> {

            MainController mainController = MusicPlayer.getMainController();
            ArtistsMainController artistsMainController = (ArtistsMainController) mainController.loadView("ArtistsMain");

            VBox artistCell = (VBox) event.getSource();
            String artistTitle = ((Label) artistCell.getChildren().get(1)).getText();
            Artist a = Library.getArtist(artistTitle);
            artistsMainController.selectArtist(a);
        });
        
        cell.setOnDragDetected(event -> {
        	PseudoClass pressed = PseudoClass.getPseudoClass("pressed");
        	cell.pseudoClassStateChanged(pressed, false);
        	Dragboard db = cell.startDragAndDrop(TransferMode.ANY);
        	ClipboardContent content = new ClipboardContent();
            content.putString("Artist");
            db.setContent(content);
        	MusicPlayer.setDraggedItem(artist);
        	db.setDragView(cell.snapshot(null, null), cell.widthProperty().divide(2).get(), cell.heightProperty().divide(2).get());
            event.consume();
        });

        return cell;
    }
 
Example 5
Source File: StepRepresentationBrowse.java    From phoenicis with GNU Lesser General Public License v3.0 4 votes vote down vote up
private Node dragPane() {
    final Text textLabel = new Text(textToShow);
    final Text dragLabel = new Text(tr("Click or drag-and-drop file here"));
    textLabel.getStyleClass().add("boldLabel");
    dragLabel.getStyleClass().addAll("normalLabel");

    final VBox dragTarget = new VBox();
    dragTarget.getChildren().addAll(textLabel, dragLabel);
    dragTarget.setOnDragOver(event -> {
        if (event.getGestureSource() != dragTarget && event.getDragboard().hasFiles()) {
            event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
        }
        event.consume();
    });

    dragTarget.setOnDragDropped(event -> {
        Dragboard db = event.getDragboard();
        boolean success = false;
        if (db.hasFiles()) {
            this.selectFile(db.getFiles().get(0));
            success = true;
        }

        event.setDropCompleted(success);

        event.consume();
    });

    dragTarget.setPrefSize(660, 308);
    dragTarget.getStyleClass().addAll("dragAndDropBox");

    dragTarget.setOnMouseClicked(event -> {
        final FileChooser fileChooser = new FileChooser();
        if (extensions != null) {
            fileChooser
                    .setSelectedExtensionFilter(
                            new FileChooser.ExtensionFilter(tr("Allowed file types"), extensions));
        }
        fileChooser.setInitialDirectory(browseDirectory);

        File dialogResult = fileChooser.showOpenDialog(null);
        if (dialogResult != null) {
            selectFile(dialogResult);
        }
    });

    return dragTarget;
}