List of usage examples for javafx.event EventHandler EventHandler
EventHandler
From source file:retsys.client.controller.UserController.java
/** * Initializes the controller class./*from w ww. j ava 2 s . c o m*/ */ @Override public void initialize(URL url, ResourceBundle rb) { // TODO AutoCompletionBinding<User> txt_name = TextFields.bindAutoCompletion(name, new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<User>>() { @Override public Collection<User> call(AutoCompletionBinding.ISuggestionRequest param) { List<User> list = null; HttpHelper helper = new HttpHelper(); try { LovHandler lovHandler = new LovHandler("users", "name"); String response = lovHandler.getSuggestions(param.getUserText()); list = (List<User>) new JsonHelper().convertJsonStringToObject(response, new TypeReference<List<User>>() { }); } catch (IOException ex) { Logger.getLogger(UserController.class.getName()).log(Level.SEVERE, null, ex); } return list; } }, new StringConverter<User>() { @Override public String toString(User object) { return object.getName() + " (ID:" + object.getId() + ")"; } @Override public User fromString(String string) { throw new UnsupportedOperationException("Not supported yet."); } }); //event handler for setting other Client fields with values from selected Client object //fires after autocompletion txt_name.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<User>>() { @Override public void handle(AutoCompletionBinding.AutoCompletionEvent<User> event) { User user = event.getCompletion(); //fill other item related fields id.setText(splitId(name.getText()) + ""); name.setText(user.getName()); password.setText(user.getPassword()); if ("N".equals(user.getUsertype())) usertype.getSelectionModel().select(1); else if ("A".equals(user.getUsertype())) usertype.getSelectionModel().select(2); else usertype.getSelectionModel().clearSelection(); populateAuditValues(user); } }); }
From source file:com.getqube.store.BrowseCategoryController.java
public void initialize() { new Thread(new Runnable() { @Override/*from w w w . java 2s .co 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:isbnfilter.ISBNFilter.java
@Override public void start(Stage primaryStage) { Button btn = new Button(); btn.setText("Say 'Hello World'"); btn.setOnAction(new EventHandler<ActionEvent>() { @Override//from www. jav a 2 s .c o m public void handle(ActionEvent event) { System.out.println("Hello World!"); try { List<String[]> isbns = readFile(primaryStage); //Lee y mete todo en un string ISBNConverter classISBN = new ISBNConverter(); classISBN.createNewFile(isbns); } catch (IOException | JSONException ex) { Logger.getLogger(ISBNFilter.class.getName()).log(Level.SEVERE, null, ex); } } }); StackPane root = new StackPane(); root.getChildren().add(btn); Scene scene = new Scene(root, 300, 250); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); }
From source file:account.management.controller.POVoucherController.java
/** * Initializes the controller class./*from w ww. j a v a2s . co m*/ */ @Override public void initialize(URL url, ResourceBundle rb) { // TODO balance.focusedProperty().addListener( (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> { if (newValue) { Platform.runLater(new Runnable() { @Override public void run() { balance.requestFocus(); balance.selectAll(); } }); } }); this.container.getChildren().remove(0); new Thread(() -> { try { Thread.sleep(5000); this.total_price.getScene().setOnKeyPressed(new EventHandler<KeyEvent>() { public void handle(final KeyEvent keyEvent) { if (keyEvent.getCode() == KeyCode.ENTER) { System.out.println("attempting to submit deposit voucher"); //Stop letting it do anything else keyEvent.consume(); try { onSubmitButtonClick(null); } catch (ParseException ex) { Logger.getLogger(SalaryVoucherController.class.getName()).log(Level.SEVERE, null, ex); } } } }); } catch (InterruptedException ex) { Logger.getLogger(NewVoucherController.class.getName()).log(Level.SEVERE, null, ex); } }).start(); }
From source file:retsys.client.controller.VendorController.java
/** * Initializes the controller class./*from ww w .j a va 2s.co m*/ */ @Override public void initialize(URL url, ResourceBundle rb) { AutoCompletionBinding<Vendor> txt_name = TextFields.bindAutoCompletion(name, new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Vendor>>() { @Override public Collection<Vendor> call(AutoCompletionBinding.ISuggestionRequest param) { List<Vendor> list = null; HttpHelper helper = new HttpHelper(); try { LovHandler lovHandler = new LovHandler("vendors", "name"); String response = lovHandler.getSuggestions(param.getUserText()); list = (List<Vendor>) new JsonHelper().convertJsonStringToObject(response, new TypeReference<List<Vendor>>() { }); } catch (IOException ex) { Logger.getLogger(VendorController.class.getName()).log(Level.SEVERE, null, ex); } return list; } }, new StringConverter<Vendor>() { @Override public String toString(Vendor object) { return object.getName() + " (ID:" + object.getId() + ")"; } @Override public Vendor fromString(String string) { throw new UnsupportedOperationException("Not supported yet."); } }); //event handler for setting other Client fields with values from selected Client object //fires after autocompletion txt_name.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<Vendor>>() { @Override public void handle(AutoCompletionBinding.AutoCompletionEvent<Vendor> event) { Vendor vendor = event.getCompletion(); //fill other item related fields id.setText(splitId(name.getText()) + ""); name.setText(vendor.getName()); address.setText(vendor.getAddress()); phone.setText(vendor.getPhone()); mobile.setText(vendor.getMobile()); remarks.setText(vendor.getRemarks()); email.setText(vendor.getEmail()); populateAuditValues(vendor); } }); }
From source file:retsys.client.controller.ProductController.java
/** * Initializes the controller class./*from w w w. j a v a2 s .co m*/ */ @Override public void initialize(URL url, ResourceBundle rb) { AutoCompletionBinding<Product> txt_name = TextFields.bindAutoCompletion(name, new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Product>>() { @Override public Collection<Product> call(AutoCompletionBinding.ISuggestionRequest param) { List<Product> list = null; HttpHelper helper = new HttpHelper(); try { LovHandler lovHandler = new LovHandler("products", "name"); String response = lovHandler.getSuggestions(param.getUserText()); list = (List<Product>) new JsonHelper().convertJsonStringToObject(response, new TypeReference<List<Product>>() { }); } catch (IOException ex) { Logger.getLogger(ProductController.class.getName()).log(Level.SEVERE, null, ex); } return list; } }, new StringConverter<Product>() { @Override public String toString(Product object) { return object.getName() + " (ID:" + object.getId() + ")"; } @Override public Product fromString(String string) { throw new UnsupportedOperationException("Not supported yet."); } }); //event handler for setting other Client fields with values from selected Client object //fires after autocompletion txt_name.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<Product>>() { @Override public void handle(AutoCompletionBinding.AutoCompletionEvent<Product> event) { Product product = event.getCompletion(); //fill other item related fields id.setText(String.valueOf(product.getId())); name.setText(product.getName()); productDesc.setText(product.getProdDesc()); remarks.setText(product.getRemarks()); //desc.setText(product.getDesc()); populateAuditValues(product); } }); }
From source file:gmailclientfx.controllers.NedovrseneController.java
public void fetchNedovrsene() { ObservableList<MyMessage> data = FXCollections.observableArrayList(); stupacId.setCellValueFactory(new PropertyValueFactory<MyMessage, Integer>("TblId")); stupacNaslov.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Subject")); stupacTo.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Sender")); stupacDatum.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("DateReceived")); nedovrseneTable.setItems(data);/*from w ww . java2 s. c o m*/ nedovrseneTable.setOnMousePressed(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.isPrimaryButtonDown() && event.getClickCount() == 2) { MyMessage selectedMsg = nedovrseneTable.getSelectionModel().getSelectedItem(); PregledEmailaHelper.setMsg(selectedMsg); try { Parent root; FXMLLoader loader = new FXMLLoader(); loader.setLocation( getClass().getClassLoader().getResource("gmailclientfx/views/pregledEmaila.fxml")); root = loader.load(); Stage stage = new Stage(); stage.setScene(new Scene(root)); stage.setTitle(PregledEmailaHelper.getMsg().getSubject() + " - " + PregledEmailaHelper.getMsg().getSender()); stage.show(); PregledEmailaController pgec = loader.getController(); stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { pgec.bodyWebViewEngine.load(null); System.out.println("Closing form!"); } }); } catch (IOException ex) { Logger.getLogger(InboxController.class.getName()).log(Level.SEVERE, null, ex); } } } }); try { IMAPStore store = OAuth2Authenticator.connectToImap("imap.gmail.com", 993, GmailClient.getEmail(), GmailClient.getAccesToken(), true); Folder nedovrsene = null; Folder[] folders = store.getDefaultFolder().list("*"); for (Folder f : folders) { IMAPFolder imapFolder = (IMAPFolder) f; for (String att : imapFolder.getAttributes()) { if ("\\Drafts".equals(att)) { nedovrsene = f; } } } nedovrsene.open(Folder.READ_WRITE); MimeMessage[] seenMessages = (MimeMessage[]) nedovrsene .search(new FlagTerm(new Flags(Flags.Flag.SEEN), true)); for (int i = 0; i < seenMessages.length; i++) { MyMessage msg = GmailClient.fetchMessage(seenMessages[i], i + 1, "DRAFT"); data.add(msg); } MimeMessage[] unseenMessages = (MimeMessage[]) nedovrsene .search(new FlagTerm(new Flags(Flags.Flag.SEEN), false)); for (int i = 0; i < unseenMessages.length; i++) { MyMessage msg = GmailClient.fetchMessage(unseenMessages[i], i + 1, "DRAFT"); data.add(msg); } nedovrsene.close(false); store.close(); } catch (Exception ex) { Logger.getLogger(NedovrseneController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:retsys.client.controller.INVENTORY_REPORTController.java
/** * Initializes the controller class./* ww w.j ava 2s .c om*/ */ @Override public void initialize(URL url, ResourceBundle rb) { AutoCompletionBinding<Project> txt_name = TextFields.bindAutoCompletion(name, new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Project>>() { @Override public Collection<Project> call(AutoCompletionBinding.ISuggestionRequest param) { List<Project> list = null; HttpHelper helper = new HttpHelper(); try { LovHandler lovHandler = new LovHandler("projects", "PROJECT"); String response = lovHandler.getSuggestions(param.getUserText()); list = (List<Project>) new JsonHelper().convertJsonStringToObject(response, new TypeReference<List<Project>>() { }); } catch (IOException ex) { Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex); } return list; } }, new StringConverter<Project>() { @Override public String toString(Project object) { return object.getName() + " (ID:" + object.getId() + ")"; } @Override public Project fromString(String string) { throw new UnsupportedOperationException("Not supported yet."); } }); //event handler for setting other Client fields with values from selected Client object //fires after autocompletion txt_name.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<Project>>() { @Override public void handle(AutoCompletionBinding.AutoCompletionEvent<Project> event) { Project project = event.getCompletion(); //fill other item related fields PROJECT.setText(splitName(name.getText())); //populateAuditValues(client); } }); // TODO }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("JavaFX Welcome"); GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER);// w w w .jav a 2s . co m grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); Text scenetitle = new Text("Welcome"); scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20)); grid.add(scenetitle, 0, 0, 2, 1); Label userName = new Label("User Name:"); grid.add(userName, 0, 1); TextField userTextField = new TextField(); grid.add(userTextField, 1, 1); Label pw = new Label("Password:"); grid.add(pw, 0, 2); PasswordField pwBox = new PasswordField(); grid.add(pwBox, 1, 2); Button btn = new Button("Sign in"); HBox hbBtn = new HBox(10); hbBtn.setAlignment(Pos.BOTTOM_RIGHT); hbBtn.getChildren().add(btn); grid.add(hbBtn, 1, 4); final Text actiontarget = new Text(); grid.add(actiontarget, 1, 6); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { actiontarget.setFill(Color.FIREBRICK); actiontarget.setText("Sign in button pressed"); } }); Scene scene = new Scene(grid, 300, 275); primaryStage.setScene(scene); primaryStage.show(); }
From source file:com.github.douglasjunior.simpleCSVEditor.FXMLController.java
@Override public void initialize(URL url, ResourceBundle rb) { file = new File(""); csvFormat = CSVFormat.DEFAULT.withIgnoreEmptyLines(false); ContextMenu contextMenu = new ContextMenu(); contextMenu.setAutoHide(true);//from ww w. ja v a 2 s. c o m MenuItem inserirLinha = new MenuItem("Inserir linha"); inserirLinha.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { addNewRow(); setNotSaved(); } }); contextMenu.getItems().add(inserirLinha); MenuItem removerLinha = new MenuItem("Remover linha"); removerLinha.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { deleteRow(); setNotSaved(); } }); contextMenu.getItems().add(removerLinha); contextMenu.getItems().add(new SeparatorMenuItem()); MenuItem inserirColuna = new MenuItem("Inserir coluna"); inserirColuna.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { addNewColumn(); setNotSaved(); } }); contextMenu.getItems().add(inserirColuna); MenuItem removerColuna = new MenuItem("Remover coluna"); removerColuna.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { deleteColumn(); setNotSaved(); } }); contextMenu.getItems().add(removerColuna); tableView.setContextMenu(contextMenu); }