Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // u glavnom kontroleru nađi funkciju initialize, i unutar nje bi trebalo da imaš ovakav neki kod
- lista.setOnMouseClicked(new EventHandler<MouseEvent>() {
- @Override
- public void handle(MouseEvent event) {
- //System.out.println("clicked on " + lista.getSelectionModel().getSelectedItem());
- Parent root;
- try {
- root = FXMLLoader.load(getClass().getResource("Forma.fxml"));
- Stage stage = new Stage();
- stage.setTitle("Slanje datoteke ");
- stage.setScene(new Scene(root, 400, 150));
- stage.show();
- // Ukoliko želite otvoriti u istom prozoru, otkomentarišite kod ispod
- // ((Node)(event.getSource())).getScene().getWindow().hide();
- }
- catch (IOException e) {
- // handle grešku
- }
- }
- });
- // umjesto toga stavi ovo
- lista.setOnMouseClicked(new EventHandler<MouseEvent>() {
- @Override
- public void handle(MouseEvent event) {
- //Prevencija za klik na praznu listu, ili prazan red, bez da je išta selektovano
- if (!lista.getSelectionModel().isEmpty()) {
- Parent root;
- try {
- root = FXMLLoader.load(getClass().getResource("Forma.fxml"));
- Stage stage = new Stage();
- stage.setTitle("Slanje datoteke ");
- stage.setScene(new Scene(root, 400, 150));
- stage.show();
- // Ukoliko želite otvoriti u istom prozoru, otkomentarišite kod ispod
- // ((Node)(event.getSource())).getScene().getWindow().hide();
- }
- catch (IOException e) {
- // handle grešku
- }
- }
- }
- });
- // dakle ključan je ovaj uslov if (!lista.getSelectionModel().isEmpty()) koji provjerava da li je išta odabrano, tako da više ne otvara prozor za slanje ukoliko nije ništa odabrano ili je prazna ona lista
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement