List of usage examples for javafx.scene.input MouseEvent getSource
public Object getSource()
From source file:calendarioSeries.vistas.NewSerieController.java
@FXML public void handleOk() { String tituloAux = titulo.getText().replaceAll(" ", "+").toLowerCase(); String toJson = readUrl(BASE + tituloAux + "&type=series" + "&r=json"); resultados.getChildren().clear();/* w w w . j a va 2s. c o m*/ try { JSONObject busqueda = new JSONObject(toJson); if (busqueda.getString("Response").equals("True")) { JSONArray res = busqueda.getJSONArray("Search"); resultados.setPrefRows(res.length()); for (int i = 0; i < res.length(); i++) { JSONObject resActual = new JSONObject(res.get(i).toString()); HBox resultadoActual = new HBox(50); resultadoActual.setMaxWidth(Double.MAX_VALUE); resultadoActual.setAlignment(Pos.CENTER_LEFT); ImageView posterActual = new ImageView(); try { Image image = new Image(resActual.getString("Poster")); posterActual.setImage(image); posterActual.setFitHeight(240); posterActual.setFitWidth(180); posterActual.setPreserveRatio(false); resultadoActual.getChildren().add(posterActual); } catch (IllegalArgumentException e) { // System.out.println("Bad url"); Image image = new Image( MainApp.class.getResource("resources/no-image.png").toExternalForm()); posterActual.setImage(image); posterActual.setFitHeight(240); posterActual.setFitWidth(180); posterActual.setPreserveRatio(false); resultadoActual.getChildren().add(posterActual); } String details; String nomSerie = new String(resActual.getString("Title").getBytes(), "UTF-8"); String anoSerie = new String(resActual.getString("Year").getBytes(), "UTF-8"); if (nomSerie.length() > 15) { details = "%-12.12s...\t\t Ao: %-10s"; } else { details = "%-12s\t\t Ao: %-10s"; } details = String.format(details, nomSerie, anoSerie); Label elemento = new Label(details); elemento.setMaxWidth(Double.MAX_VALUE); elemento.setMaxHeight(Double.MAX_VALUE); resultadoActual.getChildren().add(elemento); posterActual.setId(resActual.getString("imdbID")); posterActual.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { ImageView clickedButton = (ImageView) event.getSource(); Stage stage = (Stage) clickedButton.getScene().getWindow(); Task task = new Task() { @Override protected Object call() throws Exception { mainController.mainApp.scene.setCursor(Cursor.WAIT); Serie toAdd = new Serie(clickedButton.getId()); boolean possible = true; for (Serie serie : mainController.getSeries()) { if (serie.equals(toAdd)) possible = false; } if (possible) mainController.getSeries().add(toAdd); try { mainController.populateImagenes(); mainController.showDetallesMes(mainController.getMesActual()); } catch (Exception e) { e.printStackTrace(); } finally { mainController.mainApp.scene.setCursor(Cursor.DEFAULT); return mainController.getSeries(); } } }; Thread th = new Thread(task); th.setDaemon(true); th.start(); stage.close(); } }); resultados.getChildren().add(resultadoActual); } } else { resultados.getChildren().add(new Label("La busqueda no obtuvo resultados")); } } catch (JSONException e) { e.printStackTrace(); } catch (UnsupportedEncodingException ex) { Logger.getLogger(NewSerieController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.shiftedit.gui.preview.html.RemoteHTMLPreviewController.java
private void setupConnectionTable() { // Cell click handler tableCellMouseEventHandler = (MouseEvent t) -> { TableCell c = (TableCell) t.getSource(); int index = c.getIndex(); // Send ping request on double click if (t.getClickCount() == 2) { tableModel.get(index).ping(); }/*from w w w . j av a2 s.c om*/ }; // Cell factory Callback<TableColumn, TableCell> cellFactory = (TableColumn p) -> { TextFieldTableCell cell = new TextFieldTableCell(); cell.addEventFilter(MouseEvent.MOUSE_CLICKED, new WeakEventHandler<>(tableCellMouseEventHandler)); return cell; }; // Remote address TableColumn remoteAddressCol = new TableColumn( getResourceBundle().getString("builtin.plugin.preview.remote_html.remote_address")); remoteAddressCol.setMinWidth(100); remoteAddressCol.setCellValueFactory(new PropertyValueFactory<>("remoteAddress")); remoteAddressCol.setCellFactory(cellFactory); connectionTable.getColumns().add(remoteAddressCol); // User agent TableColumn userAgentCol = new TableColumn( getResourceBundle().getString("builtin.plugin.preview.remote_html.user_agent")); userAgentCol.setMinWidth(200); userAgentCol.setCellValueFactory(new PropertyValueFactory<>("userAgent")); userAgentCol.setCellFactory(cellFactory); connectionTable.getColumns().add(userAgentCol); // Rendering time TableColumn renderingTimeCol = new TableColumn( getResourceBundle().getString("builtin.plugin.preview.remote_html.rendering_time")); renderingTimeCol.setMinWidth(200); renderingTimeCol.setCellValueFactory(new PropertyValueFactory<>("renderingTime")); renderingTimeCol.setCellFactory(cellFactory); connectionTable.getColumns().add(renderingTimeCol); connectionTable.setPlaceholder( new Label(getResourceBundle().getString("builtin.plugin.preview.remote_html.no_connection"))); connectionTable.setItems(tableModel); }
From source file:com.exalttech.trex.ui.controllers.PacketBuilderHomeController.java
/** * Close button click handler//ww w. java 2 s . co m * * @param event */ @FXML public void handleCloseDialog(final MouseEvent event) { Node node = (Node) event.getSource(); Stage stage = (Stage) node.getScene().getWindow(); stage.hide(); }
From source file:org.ado.biblio.desktop.AppPresenter.java
private void loadBookDetails(MouseEvent event) { bookFocusedIndex = ((TableView) event.getSource()).getFocusModel().getFocusedIndex(); BookDetails bookDetails = (BookDetails) ((TableView) event.getSource()).getFocusModel().getFocusedItem(); if (bookDetails != null) { bookId = bookDetails.getId();/*from w w w .j av a 2 s . co m*/ textFieldTitle.setText(bookDetails.getTitle()); textFieldAuthor.setText(bookDetails.getAuthor()); textFieldIsbn.setText(bookDetails.getIsbn()); textFieldTags.setText(bookDetails.getTags()); if (bookDetails.isLent()) { setButtonsToReturn(); } else { setButtonsToLend(); } if (StringUtils.isNotBlank(bookDetails.getIsbn())) { imageViewCover.setImage(ImageUtils.readCoverOrDefault(bookDetails.getIsbn())); } else { imageViewCover.setImage(null); } } }
From source file:jp.ac.tohoku.ecei.sb.metabolome.lims.gui.MainWindowController.java
@FXML void onTableClicked(MouseEvent event) { if (event.getClickCount() != 2) return;//from w w w . j a v a 2 s . c om TableView tableView = ((TableView) event.getSource()); TableView.TableViewFocusModel focusModel = (TableView.TableViewFocusModel) tableView.focusModelProperty() .getValue(); TablePosition position = focusModel.getFocusedCell(); if (position.getTableColumn() == null) return; ObservableValue value = position.getTableColumn().getCellObservableValue(position.getRow()); String valueStr = value.getValue().toString(); Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setHeaderText(String.format("Value at ID:%d %s", ((LIMSData) tableView.getItems().get(position.getRow())).getId(), position.getTableColumn().getText())); if (valueStr.length() > 300) alert.setContentText(valueStr.substring(0, 300) + "..."); else alert.setContentText(valueStr); TextArea textArea = new TextArea(valueStr); textArea.setEditable(false); alert.getDialogPane().setExpandableContent(textArea); event.consume(); alert.show(); }
From source file:com.bekwam.mavenpomupdater.MainViewController.java
@FXML public void toolBarMouseReleased(MouseEvent evt) { TextField tf = (TextField) evt.getSource(); String selectedText = tf.getSelectedText(); IndexRange selectedRange = tf.getSelection(); toolBarDelegate.updateToolBarForClipboard(tf, selectedText, selectedRange); }
From source file:open.dolphin.client.MainWindowController.java
/** * Initializes the controller class.// w ww . j a va 2 s .c o m * * @param url * @param rb */ @Override public void initialize(URL url, ResourceBundle rb) { //- Init TableView ReceptView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); PatientSearchView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); PatientFutureView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); LabRecieverView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); // mainTab.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { // @Override // public void changed(ObservableValue<? extends Number> ov, Number oldValue, Number newValue) { // SingleSelectionModel<Tab> selectionModel = mainTab.getSelectionModel(); // if(mainTab.getTabs() != null){ // if(selectionModel.isSelected(0)){ // karteTabPane.getTabs().clear(); // } // } // } // }); // ????? TableColumn colId = new TableColumn("ID"); recept.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("recept")); visitTime.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("visitTime")); tableCellAlignRight(visitTime); clientId.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("clientId")); name.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("name")); sex.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("sex")); tableCellAlignCenter(sex); insurance.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("insurance")); birthDay.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("birthDay")); physicianInCharge.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("physicianInCharge")); clinicalDepartments .setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("clinicalDepartments")); reservation.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("reservation")); memo.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("memo")); status.setCellValueFactory(new PropertyValueFactory<ReceptInfo, String>("status")); tableCellImageAlignCenter(status); // ???? ReceptView.getItems().setAll(fetchDataFromServer()); // ???(?) ReceptView.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { if (mouseEvent.getClickCount() == 2) { System.out.println("Double clicked"); ReceptInfo selectedUser = ((TableView<ReceptInfo>) mouseEvent.getSource()) .getSelectionModel().getSelectedItem(); // ?????????? for (ReceptInfo info : receptList) { if (info.getName().equals(selectedUser.getName())) { return; } } System.out.println(selectedUser.getClientId()); receptList.add(selectedUser); // ?? final ContextMenu contextMenu = new ContextMenu(); MenuItem item1 = new MenuItem("?"); item1.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Reserve Karte?"); // ?? // e.getSource(); } }); MenuItem item2 = new MenuItem("???"); item2.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Close Tab and Preservation???"); karteTabPane.getTabs().remove(karteTabPane.getSelectionModel().getSelectedItem()); // ?? // e.getSource(); } }); MenuItem item3 = new MenuItem("?"); item3.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Close Tab?"); karteTabPane.getTabs().remove(karteTabPane.getSelectionModel().getSelectedItem()); // ?? // e.getSource(); } }); contextMenu.getItems().addAll(item1, item2, item3); Tab tab = new Tab(selectedUser.getName()); tab.setOnClosed(new EventHandler<Event>() { @Override public void handle(Event t) { Tab tab = (Tab) t.getSource(); for (int i = 0; i < receptList.size(); i++) { if (tab.getText().equals(receptList.get(i).getName())) { receptList.remove(i); } } System.out.println("Closed!"); } }); tab.setContextMenu(contextMenu); // Right-click mouse button menu try { // Loading content on demand Parent root = (Parent) new FXMLLoader() .load(this.getClass().getResource("/resources/fxml/Karte.fxml").openStream()); tab.setContent(root); karteTabPane.getSelectionModel().select(tab); karteTabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.ALL_TABS); karteTabPane.getTabs().add(tab); karteTabPane.setPrefSize(kartePane.getPrefWidth(), kartePane.getPrefHeight()); kartePane.getChildren().retainAll(); kartePane.getChildren().add(karteTabPane); } catch (IOException ex) { Logger.getLogger(MainWindowController.class.getName()).log(Level.SEVERE, null, ex); } } } } }); // ???? clientId1.setCellValueFactory(new PropertyValueFactory<PatientSearchInfo, String>("clientId1")); name1.setCellValueFactory(new PropertyValueFactory<PatientSearchInfo, String>("name1")); kana1.setCellValueFactory(new PropertyValueFactory<PatientSearchInfo, String>("kana1")); sex1.setCellValueFactory(new PropertyValueFactory<PatientSearchInfo, String>("sex1")); birthDay1.setCellValueFactory(new PropertyValueFactory<PatientSearchInfo, String>("birthDay1")); receiveDay1.setCellValueFactory(new PropertyValueFactory<PatientSearchInfo, String>("receiveDay1")); status1.setCellValueFactory(new PropertyValueFactory<PatientSearchInfo, String>("status1")); // dummy? PatientSearchView.getItems().setAll(fetchDataFromPatientInfo()); // ??(?) PatientSearchView.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { if (mouseEvent.getClickCount() == 2) { System.out.println("Double clicked"); PatientSearchInfo selectedUser = ((TableView<PatientSearchInfo>) mouseEvent.getSource()) .getSelectionModel().getSelectedItem(); // ?????????? for (PatientSearchInfo info : patientSearchList) { if (info.getName1().equals(selectedUser.getName1())) { return; } } System.out.println(selectedUser.getKana1()); patientSearchList.add(selectedUser); // ?? final ContextMenu contextMenu = new ContextMenu(); MenuItem item1 = new MenuItem("?"); item1.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Reserve Karte?"); // ?? // e.getSource(); } }); MenuItem item2 = new MenuItem("???"); item2.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Close Tab and Preservation???"); karteTabPane1.getTabs().remove(karteTabPane1.getSelectionModel().getSelectedItem()); // ?? // e.getSource(); } }); MenuItem item3 = new MenuItem("?"); item3.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Close Tab?"); karteTabPane1.getTabs().remove(karteTabPane1.getSelectionModel().getSelectedItem()); // ?? // e.getSource(); } }); contextMenu.getItems().addAll(item1, item2, item3); Tab tab = new Tab(selectedUser.getName1()); tab.setOnClosed(new EventHandler<Event>() { @Override public void handle(Event t) { Tab tab = (Tab) t.getSource(); for (int i = 0; i < patientSearchList.size(); i++) { if (tab.getText().equals(patientSearchList.get(i).getName1())) { patientSearchList.remove(i); } } System.out.println("Closed!"); } }); tab.setContextMenu(contextMenu); // Right-click mouse button menu try { // Loading content on demand Parent root = (Parent) new FXMLLoader() .load(this.getClass().getResource("/resources/fxml/Karte.fxml").openStream()); tab.setContent(root); karteTabPane1.getSelectionModel().select(tab); karteTabPane1.setTabClosingPolicy(TabPane.TabClosingPolicy.ALL_TABS); karteTabPane1.getTabs().add(tab); karteTabPane1.setPrefSize(kartePane1.getPrefWidth(), kartePane1.getPrefHeight()); kartePane1.getChildren().retainAll(); kartePane1.getChildren().add(karteTabPane1); } catch (IOException ex) { Logger.getLogger(MainWindowController.class.getName()).log(Level.SEVERE, null, ex); } } } } }); // ???? clientId2.setCellValueFactory(new PropertyValueFactory<PatientFutureInfo, String>("clientId2")); name2.setCellValueFactory(new PropertyValueFactory<PatientFutureInfo, String>("name2")); kana2.setCellValueFactory(new PropertyValueFactory<PatientFutureInfo, String>("kana2")); insurance2.setCellValueFactory(new PropertyValueFactory<PatientFutureInfo, String>("insurance2")); sex2.setCellValueFactory(new PropertyValueFactory<PatientFutureInfo, String>("sex2")); birthDay2.setCellValueFactory(new PropertyValueFactory<PatientFutureInfo, String>("birthDay2")); physicianInCharge2 .setCellValueFactory(new PropertyValueFactory<PatientFutureInfo, String>("physicianInCharge2")); clinicalDepartments2 .setCellValueFactory(new PropertyValueFactory<PatientFutureInfo, String>("clinicalDepartments2")); karte2.setCellValueFactory(new PropertyValueFactory<PatientFutureInfo, String>("karte2")); // dummy? PatientFutureView.getItems().setAll(fetchDataFromPatientFutureInfo()); // ??(?) PatientFutureView.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { if (mouseEvent.getClickCount() == 2) { System.out.println("Double clicked"); PatientFutureInfo selectedUser = ((TableView<PatientFutureInfo>) mouseEvent.getSource()) .getSelectionModel().getSelectedItem(); System.out.println(selectedUser.getName2()); // ?? final ContextMenu contextMenu = new ContextMenu(); MenuItem item1 = new MenuItem("?"); item1.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Reserve Karte?"); // ?? // e.getSource(); } }); MenuItem item2 = new MenuItem("???"); item2.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Close Tab and Preservation???"); karteTabPane2.getTabs().remove(karteTabPane2.getSelectionModel().getSelectedItem()); // ?? // e.getSource(); } }); MenuItem item3 = new MenuItem("?"); item3.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Close Tab?"); karteTabPane2.getTabs().remove(karteTabPane2.getSelectionModel().getSelectedItem()); // ?? // e.getSource(); } }); contextMenu.getItems().addAll(item1, item2, item3); Tab tab = new Tab(selectedUser.getName2()); tab.setContextMenu(contextMenu); // Right-click mouse button menu try { // Loading content on demand Parent root = (Parent) new FXMLLoader() .load(this.getClass().getResource("/resources/fxml/Karte.fxml").openStream()); tab.setContent(root); karteTabPane2.getSelectionModel().select(tab); karteTabPane2.setTabClosingPolicy(TabPane.TabClosingPolicy.ALL_TABS); karteTabPane2.getTabs().add(tab); karteTabPane2.setPrefSize(kartePane2.getPrefWidth(), kartePane2.getPrefHeight()); kartePane2.getChildren().retainAll(); kartePane2.getChildren().add(karteTabPane2); } catch (IOException ex) { Logger.getLogger(MainWindowController.class.getName()).log(Level.SEVERE, null, ex); } } } } }); // ????? lab3.setCellValueFactory(new PropertyValueFactory<LabReceiverInfo, String>("lab3")); clientId3.setCellValueFactory(new PropertyValueFactory<LabReceiverInfo, String>("clientId3")); kana3.setCellValueFactory(new PropertyValueFactory<LabReceiverInfo, String>("kana3")); karteKana3.setCellValueFactory(new PropertyValueFactory<LabReceiverInfo, String>("karteKana3")); sex3.setCellValueFactory(new PropertyValueFactory<LabReceiverInfo, String>("sex3")); karteSex3.setCellValueFactory(new PropertyValueFactory<LabReceiverInfo, String>("karteSex3")); sampleGetDay3.setCellValueFactory(new PropertyValueFactory<LabReceiverInfo, String>("sampleGetDay3")); register3.setCellValueFactory(new PropertyValueFactory<LabReceiverInfo, String>("register3")); status3.setCellValueFactory(new PropertyValueFactory<LabReceiverInfo, String>("status3")); // dummy? LabRecieverView.getItems().setAll(fetchDataFromLabRecieverInfo()); // ???(?) LabRecieverView.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { if (mouseEvent.getClickCount() == 2) { System.out.println("Double clicked"); LabReceiverInfo selectedUser = ((TableView<LabReceiverInfo>) mouseEvent.getSource()) .getSelectionModel().getSelectedItem(); System.out.println(selectedUser.getKana3()); // ?? final ContextMenu contextMenu = new ContextMenu(); MenuItem item1 = new MenuItem("?"); item1.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Reserve Karte?"); // ?? // e.getSource(); } }); MenuItem item2 = new MenuItem("???"); item2.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Close Tab and Preservation???"); karteTabPane3.getTabs().remove(karteTabPane3.getSelectionModel().getSelectedItem()); // ?? // e.getSource(); } }); MenuItem item3 = new MenuItem("?"); item3.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { System.out.println("Close Tab?"); karteTabPane3.getTabs().remove(karteTabPane3.getSelectionModel().getSelectedItem()); // ?? // e.getSource(); } }); contextMenu.getItems().addAll(item1, item2, item3); Tab tab = new Tab(selectedUser.getKana3()); tab.setContextMenu(contextMenu); // Right-click mouse button menu try { // Loading content on demand Parent root = (Parent) new FXMLLoader() .load(this.getClass().getResource("/resources/fxml/Karte.fxml").openStream()); tab.setContent(root); karteTabPane3.getSelectionModel().select(tab); karteTabPane3.setTabClosingPolicy(TabPane.TabClosingPolicy.ALL_TABS); karteTabPane3.getTabs().add(tab); karteTabPane3.setPrefSize(kartePane3.getPrefWidth(), kartePane3.getPrefHeight()); kartePane3.getChildren().retainAll(); kartePane3.getChildren().add(karteTabPane3); } catch (IOException ex) { Logger.getLogger(MainWindowController.class.getName()).log(Level.SEVERE, null, ex); } } } } }); // ??5?????? Timer exeTimer = new Timer(); Calendar cal = Calendar.getInstance(); final int sec = cal.get(Calendar.SECOND); int delay = (60 - sec) * 1000; int interval = 5 * 1000; TimerTask task = new TimerTask() { @Override public void run() { if (!stopFlag) { System.out.println("this is called every 5 seconds on UI thread"); receptUpdate(); } else { this.cancel(); } } }; exeTimer.schedule(task, delay, interval); }