List of usage examples for javafx.scene.input MouseEvent MOUSE_CLICKED
EventType MOUSE_CLICKED
To view the source code for javafx.scene.input MouseEvent MOUSE_CLICKED.
Click Source Link
From source file:Main.java
public static java.awt.event.MouseEvent toAwt(final MouseEvent event) { final EventType type = event.getEventType(); if (null == type) { return null; }/*from w w w. j a va 2s . co m*/ final int id; if (MouseEvent.MOUSE_MOVED.equals(type)) { id = java.awt.event.MouseEvent.MOUSE_MOVED; } else if (MouseEvent.MOUSE_DRAGGED.equals(type)) { id = java.awt.event.MouseEvent.MOUSE_DRAGGED; } else if (MouseEvent.MOUSE_CLICKED.equals(type)) { id = java.awt.event.MouseEvent.MOUSE_CLICKED; } else if (MouseEvent.MOUSE_PRESSED.equals(type)) { id = java.awt.event.MouseEvent.MOUSE_PRESSED; } else if (MouseEvent.MOUSE_RELEASED.equals(type)) { id = java.awt.event.MouseEvent.MOUSE_RELEASED; } else if (MouseEvent.MOUSE_ENTERED.equals(type)) { id = java.awt.event.MouseEvent.MOUSE_ENTERED; } else if (MouseEvent.MOUSE_EXITED.equals(type)) { id = java.awt.event.MouseEvent.MOUSE_EXITED; } else { return null; } final int button; if (event.isPrimaryButtonDown()) { button = java.awt.event.MouseEvent.BUTTON1; } else if (event.isMiddleButtonDown()) { button = java.awt.event.MouseEvent.BUTTON2; } else if (event.isSecondaryButtonDown()) { button = java.awt.event.MouseEvent.BUTTON3; } else { button = java.awt.event.MouseEvent.NOBUTTON; } final long when = -1; final int modifiers = modifiers(event); final int x = (int) event.getX(); final int y = (int) event.getY(); final int xAbs = Integer.MAX_VALUE; final int yAbs = Integer.MAX_VALUE; final int count = event.getClickCount(); boolean popup = event.isPopupTrigger(); if (MouseEvent.MOUSE_CLICKED.equals(type) && event.isMetaDown()) { // mack books use meta flag for right-clicks popup = true; } return new java.awt.event.MouseEvent(empty, id, when, modifiers, x, y, xAbs, yAbs, count, popup, button); }
From source file:Main.java
@Override public void start(Stage primaryStage) { Group root = new Group(); Scene scene = new Scene(root, 300, 250); TextField textBox = new TextField(); textBox.setPromptText("Write here"); // Register an event filter for a single node and a specific event type scene.addEventFilter(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { public void handle(MouseEvent e) { System.out.println("mouse clicked"); };//from www. ja va 2 s . c o m }); root.getChildren().add(textBox); primaryStage.setScene(scene); primaryStage.show(); }
From source file:net.gazeplay.commons.utils.License.java
public License(double X, double Y, double width, double height, GazePlay gazePlay, Scene scene, Group root) { super(X, Y, width, height); this.setFill(new ImagePattern(new Image("data/common/images/license.png"), 0, 0, 1, 1, true)); EventHandler<Event> homeEvent = new EventHandler<javafx.event.Event>() { @Override/*from ww w. j a va 2 s. c o m*/ public void handle(javafx.event.Event e) { if (e.getEventType() == MouseEvent.MOUSE_CLICKED) { root.getChildren().add(licence(width, height)); gazePlay.getHomeMenuScreen(); } } }; this.addEventHandler(MouseEvent.MOUSE_CLICKED, homeEvent); }
From source file:Main.java
@Override public void start(Stage primaryStage) { BorderPane root = new BorderPane(); Scene scene = new Scene(root, 300, 250, Color.WHITE); MenuBar menuBar = new MenuBar(); menuBar.getMenus().addAll(fileMenu(), cameraMenu(), alarmMenu()); root.setTop(menuBar);//www . j a v a 2 s. c o m ContextMenu contextFileMenu = new ContextMenu(exitMenuItem()); primaryStage.addEventHandler(MouseEvent.MOUSE_CLICKED, (MouseEvent me) -> { if (me.getButton() == MouseButton.SECONDARY || me.isControlDown()) { contextFileMenu.show(root, me.getScreenX(), me.getScreenY()); } else { contextFileMenu.hide(); } }); primaryStage.setScene(scene); primaryStage.show(); }
From source file:ijfx.ui.widgets.PluginInfoPane.java
private void installWebView(WebView view) { this.webView = view; view.prefWidthProperty().bind(widthProperty()); view.prefHeightProperty().bind(heightProperty()); setCenter(view);//from ww w . j a va 2 s . co m webView.addEventHandler(MouseEvent.MOUSE_CLICKED, this::onMouseClicked); messageDispayer = new RichMessageDisplayer(webView); updateWebView(); }
From source file:com.getqube.store.BrowseCategoryController.java
public void initialize() { new Thread(new Runnable() { @Override// w w w .jav a2 s . c o m public void run() { Category c = ApplicationContext.getInstance().getRegisteredObject(Category.class); try { App[] apps = AppService.allForCategory(String.valueOf(c.getId())); // Show the app detail page now that the data has been loaded from the Web. Platform.runLater(new Runnable() { @Override public void run() { for (App app : apps) { CategoryButtonControl button = new CategoryButtonControl(); button.setLink(app.getName()); button.setImage(new Image(app.getThumbnail())); button.addEventFilter(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { public void handle(final MouseEvent mouseEvent) { ApplicationContext.getInstance().register(app); TreeItem<String> appItem = new TreeItem<String>(app.getName()); CategoriesController.BREADCRUMBS.getSelectedCrumb().getChildren() .add(appItem); CategoriesController.BREADCRUMBS.setSelectedCrumb(appItem); Navigator.loadVista(Navigator.APP_DETAIL); } }); paneApps.getChildren().add(button); } paneLoading.setVisible(false); paneEverything.setVisible(true); } }); } catch (ProcessingException processingException) { logger.log(Level.WARNING, processingException.getMessage(), processingException); reportConnectionProblem(); } catch (IOException ioException) { logger.log(Level.WARNING, ioException.getMessage(), ioException); reportConnectionProblem(); } } }).start(); }
From source file:ijfx.ui.plugin.panel.OverlayPanel.java
public OverlayPanel() throws IOException { super();//from w w w.j a v a 2 s. c o m FXUtilities.injectFXML(this); keyColumn.setCellValueFactory(new PropertyValueFactory("name")); valueColumn.setCellValueFactory(new PropertyValueFactory("value")); tableView.setItems(entries); entries.add(new MyEntry("nothing", 0d)); overlayNameField.setPromptText(EMPTY_FIELD); overlayNameField.textProperty().addListener(this::onOverlayNameChanged); overlayProperty.addListener(this::onOverlaySelectionChanged); chartVBox.getChildren().removeAll(areaChart, lineChart); overlayOptions = new OverlayOptions(); optionsPane = new PopOver(overlayOptions); optionsPane.setArrowLocation(PopOver.ArrowLocation.RIGHT_TOP); optionsPane.setDetachable(true); optionsPane.setAutoHide(false); optionsPane.titleProperty().setValue("Overlay settings"); optionsPane.setConsumeAutoHidingEvents(false); gearIcon = GlyphsDude.createIcon(FontAwesomeIcon.GEAR, "15"); gearIcon.setOpacity(BASAL_OPACITY); gearIcon.setOnMouseEntered(e -> gearIcon.setOpacity(1.0)); gearIcon.setOnMouseExited(e -> gearIcon.setOpacity(BASAL_OPACITY)); gearIcon.addEventHandler(MouseEvent.MOUSE_CLICKED, this::onGearClicked); gearIcon.addEventHandler(MouseEvent.MOUSE_PRESSED, e -> { e.consume(); }); gearIcon.addEventHandler(MouseEvent.MOUSE_RELEASED, e -> { e.consume(); }); chartTitledPane.setGraphic(gearIcon); chartTitledPane.setContentDisplay(ContentDisplay.RIGHT); chartTitledPane.graphicTextGapProperty().setValue(TEXT_GAP); }
From source file:ijfx.ui.plugin.overlay.OverlayPanel.java
public OverlayPanel() throws IOException { super();/*ww w . j av a2 s. c o m*/ FXUtilities.injectFXML(this); keyColumn.setCellValueFactory(new PropertyValueFactory("name")); valueColumn.setCellValueFactory(new PropertyValueFactory("value")); tableView.setItems(entries); entries.add(new MyEntry("nothing", 0d)); overlayNameField.setPromptText(EMPTY_FIELD); overlayNameField.textProperty().addListener(this::onOverlayNameChanged); overlayProperty.addListener(this::onOverlaySelectionChanged); chartVBox.getChildren().removeAll(areaChart, lineChart); overlayOptions = new OverlayOptions(); optionsPane = new PopOver(overlayOptions); optionsPane.setArrowLocation(PopOver.ArrowLocation.RIGHT_TOP); optionsPane.setDetachable(true); optionsPane.setAutoHide(false); optionsPane.titleProperty().setValue("Overlay settings"); optionsPane.setConsumeAutoHidingEvents(false); gearIcon = GlyphsDude.createIcon(FontAwesomeIcon.GEAR, "15"); gearIcon.setOpacity(BASAL_OPACITY); gearIcon.setOnMouseEntered(e -> gearIcon.setOpacity(1.0)); gearIcon.setOnMouseExited(e -> gearIcon.setOpacity(BASAL_OPACITY)); gearIcon.addEventHandler(MouseEvent.MOUSE_CLICKED, this::onGearClicked); gearIcon.addEventHandler(MouseEvent.MOUSE_PRESSED, e -> { e.consume(); }); gearIcon.addEventHandler(MouseEvent.MOUSE_RELEASED, e -> { e.consume(); }); chartTitledPane.setGraphic(gearIcon); chartTitledPane.setContentDisplay(ContentDisplay.RIGHT); chartTitledPane.graphicTextGapProperty().setValue(TEXT_GAP); // channeling all the DataViewUpdatedEvent so it updates the // current selected overlay eventBus.getStream(OverlayUpdatedEvent.class) .filter(event -> event.getObject().equals(overlayProperty.getValue())) .subscribe(event -> Platform.runLater(this::updateStats)); eventBus.getStream(DataViewUpdatedEvent.class).map(event -> event.getView()) .filter(view -> view instanceof OverlayView).cast(OverlayView.class) .filter(view -> view.isSelected()).throttleWithTimeout(1000, TimeUnit.MILLISECONDS) .subscribe(overlay -> { overlayProperty.setValue(overlay.getData()); }); eventBus.getStream(DataViewUpdatedEvent.class).filter(event -> event.getView() instanceof DatasetView) .map(event -> event.getView()).cast(DatasetView.class).map(view -> { return view; }).filter(view -> currentDisplay().contains(view)).throttleWithTimeout(100, TimeUnit.MILLISECONDS) .subscribe(event -> Platform.runLater(this::updateStats)); eventBus.getStream(DisplayUpdatedEvent.class).filter(event -> event.getDisplay() instanceof ImageDisplay) .subscribe(this::checkCurrentOverlay); }
From source file:com.panemu.tiwulfx.control.skin.LookupFieldSkin.java
private void createPopup() { popup = new PopupControl() { {// w w w . j ava 2 s .c om setSkin(new Skin() { @Override public Skinnable getSkinnable() { return LookupFieldSkin.this.lookupField; } @Override public Node getNode() { return listView; } @Override public void dispose() { } }); } }; popup.setAutoHide(true); popup.setAutoFix(true); popup.setHideOnEscape(true); popup.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent t) { popup.hide(); } }); listView.setCellFactory(new Callback() { @Override public Object call(Object p) { return new PropertyListCell(lookupField.getPropertyName()); } }); /** * Taken from * {@link com.sun.javafx.scene.control.skin.ComboBoxListViewSkin} */ listView.addEventFilter(MouseEvent.MOUSE_RELEASED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent t) { // RT-18672: Without checking if the user is clicking in the // scrollbar area of the ListView, the comboBox will hide. Therefore, // we add the check below to prevent this from happening. EventTarget target = t.getTarget(); if (target instanceof Parent) { List<String> s = ((Parent) target).getStyleClass(); if (s.contains("thumb") || s.contains("track") || s.contains("decrement-arrow") || s.contains("increment-arrow")) { return; } } needValidation = false; lookupField.setValue(listView.getSelectionModel().getSelectedItem()); popup.hide(); } }); listView.setOnKeyPressed(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent t) { if (t.getCode() == KeyCode.ENTER) { needValidation = false; lookupField.setValue(listView.getSelectionModel().getSelectedItem()); popup.hide(); } else if (t.getCode() == KeyCode.ESCAPE) { popup.hide(); } } }); }
From source file:com.github.technosf.posterer.controllers.impl.RequestController.java
/** * {@inheritDoc}//from w w w .jav a 2s.c om * * @see com.github.technosf.posterer.controllers.Controller#initialize() */ @Override public void initialize() { logger.debug("Initialization starts"); statusController = StatusController.loadController(statusWindow.textProperty()); certificateFileChooser.setRoot(getRoot()); certificateFileChooser.getChosenFileProperty().addListener(new ChangeListener<File>() { @Override public void changed(ObservableValue<? extends File> arg0, File oldValue, File newValue) { setCertificateFile(newValue); } }); propertiesTable.addEventFilter(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.getClickCount() > 1 && event.getButton().ordinal() == 1) { loadRequest(propertiesTable.getSelectionModel().getSelectedItem()); } } }); propertiesTable.setItems(properties); endpointColumn.setCellValueFactory(new PropertyValueFactory<RequestData, String>("endpoint")); payloadColumn.setCellValueFactory(new PropertyValueFactory<RequestData, String>("payload")); methodColumn.setCellValueFactory(new PropertyValueFactory<RequestData, String>("method")); contentTypeColumn.setCellValueFactory(new PropertyValueFactory<RequestData, String>("contentType")); base64Column.setCellValueFactory(new PropertyValueFactory<RequestData, Boolean>("base64")); httpUserColumn.setCellValueFactory(new PropertyValueFactory<RequestData, String>("httpUser")); httpPasswordColumn.setCellValueFactory(new PropertyValueFactory<RequestData, String>("httpPassword")); processProperties(); /* * Bindings */ timeoutText.textProperty().bind(timeout.asString("%d")); timeout.bind(timeoutSlider.valueProperty()); useProxy.bindBidirectional(proxyToggle1.selectedProperty()); useProxy.bindBidirectional(proxyToggle2.selectedProperty()); useProxy.bindBidirectional(proxyToggle3.selectedProperty()); useProxy.bindBidirectional(proxyToggle4.selectedProperty()); useProxy.bindBidirectional(proxyToggle5.selectedProperty()); proxyToggle1.textProperty().bind(useProxyText); proxyToggle2.textProperty().bind(useProxyText); proxyToggle3.textProperty().bind(useProxyText); proxyToggle4.textProperty().bind(useProxyText); proxyToggle5.textProperty().bind(useProxyText); proxyportlabel.textFillProperty().bind(proxyhostlabel.textFillProperty()); proxyuserlabel.textFillProperty().bind(proxyhostlabel.textFillProperty()); proxypasswordlabel.textFillProperty().bind(proxyhostlabel.textFillProperty()); proxyhost.disableProperty().bind(useProxy.not()); proxyport.disableProperty().bind(useProxy.not()); proxyuser.disableProperty().bind(useProxy.not()); proxypassword.disableProperty().bind(useProxy.not()); /* * Preferences */ proxyhost.textProperty().set(requestModel.getProxyHost()); proxyport.textProperty().set(requestModel.getProxyPort()); proxyuser.textProperty().set(requestModel.getProxyUser()); proxypassword.textProperty().set(requestModel.getProxyPass()); try { homedir.textProperty().set(propertiesModel.getPropertiesDir()); } catch (IOException e) { store.setDisable(true); statusController.setStatus(INFO_PROPERTIES, e.getMessage()); } logger.debug("Initialization complete"); }