Example usage for javafx.event EventHandler EventHandler

List of usage examples for javafx.event EventHandler EventHandler

Introduction

In this page you can find the example usage for javafx.event EventHandler EventHandler.

Prototype

EventHandler

Source Link

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Group p = new Group();
    Scene scene = new Scene(p);
    stage.setScene(scene);//from  ww w.ja v a  2 s  .  co m
    stage.setWidth(500);
    stage.setHeight(500);
    p.setTranslateX(80);
    p.setTranslateY(80);

    //create a circle with effect
    final Circle circle = new Circle(20, Color.rgb(156, 216, 255));
    circle.setEffect(new Lighting());
    //create a text inside a circle
    final Text text = new Text(i.toString());
    text.setStroke(Color.BLACK);
    //create a layout for circle with text inside
    final StackPane stack = new StackPane();
    stack.getChildren().addAll(circle, text);
    stack.setLayoutX(30);
    stack.setLayoutY(30);

    p.getChildren().add(stack);
    stage.show();

    //create a timeline for moving the circle
    timeline = new Timeline();
    timeline.setCycleCount(Timeline.INDEFINITE);
    timeline.setAutoReverse(true);

    //You can add a specific action when each frame is started.
    timer = new AnimationTimer() {
        @Override
        public void handle(long l) {
            text.setText(i.toString());
            i++;
        }
    };

    //create a keyValue with factory: scaling the circle 2times
    KeyValue keyValueX = new KeyValue(stack.scaleXProperty(), 2);
    KeyValue keyValueY = new KeyValue(stack.scaleYProperty(), 2);

    //create a keyFrame, the keyValue is reached at time 2s
    Duration duration = Duration.millis(2000);
    //one can add a specific action when the keyframe is reached
    EventHandler onFinished = new EventHandler<ActionEvent>() {
        public void handle(ActionEvent t) {
            stack.setTranslateX(java.lang.Math.random() * 200 - 100);
            //reset counter
            i = 0;
        }
    };

    KeyFrame keyFrame = new KeyFrame(duration, onFinished, keyValueX, keyValueY);

    //add the keyframe to the timeline
    timeline.getKeyFrames().add(keyFrame);

    timeline.play();
    timer.start();
}

From source file:net.sf.anathema.framework.presenter.action.about.AnathemaAboutAction.java

private void showCloseButton(MigPane parent, final Stage aboutStage) {
    Button close = new Button(getString("Help.AboutDialog.CloseButton"));
    close.setOnAction(new EventHandler<ActionEvent>() {
        @Override/*  w  ww  .  j a v  a2 s . com*/
        public void handle(ActionEvent actionEvent) {
            closeDialog(aboutStage);
        }
    });
    parent.add(close, new CC().dockSouth().alignX("center"));
}

From source file:account.management.controller.ViewVouchersController.java

@Override
public void initialize(URL url, ResourceBundle rb) {

    new AutoCompleteComboBoxListener<>(select_location);
    select_location.setOnHiding((e) -> {
        Location a = select_location.getSelectionModel().getSelectedItem();
        select_location.setEditable(false);
        select_location.getSelectionModel().select(a);
    });//from  ww w. jav  a  2  s. co  m
    select_location.setOnShowing((e) -> {
        select_location.setEditable(true);
    });

    new AutoCompleteComboBoxListener<>(select_voucher_type);
    select_voucher_type.setOnHiding((e) -> {
        VoucherType a = select_voucher_type.getSelectionModel().getSelectedItem();
        select_voucher_type.setEditable(false);
        select_voucher_type.getSelectionModel().select(a);
    });
    select_voucher_type.setOnShowing((e) -> {
        select_voucher_type.setEditable(true);
    });

    account_list = FXCollections.observableArrayList();
    this.account_list = this.getAccounts();
    c_id.setCellValueFactory(new PropertyValueFactory("id"));
    c_date.setCellValueFactory(new PropertyValueFactory("date"));
    c_location.setCellValueFactory(new PropertyValueFactory("location"));
    c_narration.setCellValueFactory(new PropertyValueFactory("narration"));
    c_voucher_type.setCellValueFactory(new PropertyValueFactory("voucher_type"));

    table.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent mouseEvent) {
            if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) {
                if (mouseEvent.getClickCount() == 2) {
                    try {
                        JSONArray res = Unirest.get(MetaData.baseUrl + "get/voucher/with/date")
                                .queryString("start_date", start_date.getValue().toString())
                                .queryString("end_date", end_date.getValue().toString())
                                .queryString("id", table.getSelectionModel().getSelectedItem().getId()).asJson()
                                .getBody().getArray();
                        Voucher v = table.getSelectionModel().getSelectedItem();
                        gerReport("VN" + String.format("%03d", Integer.parseInt(v.getId())), v.getDate(),
                                v.getNarration(), v.getVoucher_type(), v.getLocation(), res.toString());
                        System.out.println(res);
                    } catch (UnirestException ex) {
                        Logger.getLogger(ViewVouchersController.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        }
    });

    locations = FXCollections.observableArrayList();
    new Thread(() -> {
        try {
            HttpResponse<JsonNode> response = Unirest.get(MetaData.baseUrl + "get/locations").asJson();
            JSONArray location_array = response.getBody().getArray();
            locations.add(new Location(0, "All", ""));
            for (int i = 0; i < location_array.length() - 1; i++) {
                String name = location_array.getJSONObject(i).getString("name");
                String details = location_array.getJSONObject(i).getString("details");
                int id = location_array.getJSONObject(i).getInt("id");
                locations.add(new Location(id, name, details));
            }
            select_location.getItems().addAll(locations);

        } catch (UnirestException ex) {
            System.out.println("exception in UNIREST");
        }
    }).start();

    new Thread(() -> {
        try {
            HttpResponse<JsonNode> res = Unirest.get(MetaData.baseUrl + "get/voucher/type").asJson();
            JSONArray type = res.getBody().getArray();
            this.select_voucher_type.getItems().add(new VoucherType(0, "All", ""));
            for (int i = 0; i < type.length(); i++) {
                JSONObject obj = type.getJSONObject(i);
                int id = Integer.parseInt(obj.get("id").toString());
                String name = obj.get("type_name").toString();
                String note = obj.get("details").toString();
                this.select_voucher_type.getItems().add(new VoucherType(id, name, note));
            }
        } catch (UnirestException ex) {
            Logger.getLogger(NewVoucherController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }).start();
}

From source file:org.craftercms.social.migration.controllers.MainController.java

@Override
public void initialize(final URL location, final ResourceBundle resources) {
    configTable();//w w w  . ja v  a 2  s  . c  om
    mnuQuit.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent actionEvent) {
            stopTasks();
            Platform.exit();
        }
    });
    ctxClearLog.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent actionEvent) {
            logTable.getItems().clear();
        }
    });
    ctxClearProfileSelection.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent actionEvent) {
            lstProfileScripts.getSelectionModel().clearSelection();
        }
    });
    ctxClearSocialSelection.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent actionEvent) {
            lstSocialScripts.getSelectionModel().clearSelection();
        }
    });

    lstProfileScripts.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    lstSocialScripts.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    lstProfileScripts.setCellFactory(new Callback<ListView, ListCell>() {
        @Override
        public ListCell call(final ListView listView) {
            return new FileListCell();
        }
    });
    lstSocialScripts.setCellFactory(new Callback<ListView, ListCell>() {
        @Override
        public ListCell call(final ListView listView) {
            return new FileListCell();
        }
    });
    ctxReloadProfileScrp.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent actionEvent) {
            lstProfileScripts.getItems().clear();
            try {
                extractBuildInScripts("profile", lstProfileScripts);
            } catch (MigrationException e) {
                log.error("Unable to extract BuildIn scripts");
            }
            loadScripts(MigrationTool.systemProperties.getString("crafter.migration.profile.scripts"),
                    lstProfileScripts);
        }
    });
    ctxReloadSocialScrp.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent actionEvent) {
            lstSocialScripts.getItems().clear();
            try {
                extractBuildInScripts("profile", lstSocialScripts);
            } catch (MigrationException e) {
                log.error("Unable to extract BuildIn scripts");
            }
            loadScripts(MigrationTool.systemProperties.getString("crafter.migration.social.scripts"),
                    lstSocialScripts);
        }
    });
    final MigrationSelectionAction selectionEventHandler = new MigrationSelectionAction();
    rbtMigrateProfile.setOnAction(selectionEventHandler);
    rbtMigrateSocial.setOnAction(selectionEventHandler);
    loadScripts();
    loadDefaultValues();
    saveLog.setAccelerator(new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN));
    saveLog.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent event) {
            FileChooser fileChooser = new FileChooser();
            fileChooser.setTitle("Save Migration Log");
            fileChooser.setInitialFileName("Crafter-Migration-"
                    + new SimpleDateFormat("yyyy-MM-dd@HH_mm").format(new Date()) + ".html");
            final File savedFile = fileChooser.showSaveDialog(scene.getWindow());
            if (savedFile == null) {
                return;
            }
            try {
                getHtml(new FileWriter(savedFile));
                log.info("Saved Html log file");
            } catch (IOException | TransformerException ex) {
                log.error("Unable to save file", ex);
            }
        }
    });
    mnuStart.setAccelerator(new KeyCodeCombination(KeyCode.F5));
    mnuStart.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent event) {

            if (currentTask == null || !currentTask.isRunning()) {
                ObservableList scriptsToRun;
                if (rbtMigrateProfile.isSelected()) {
                    scriptsToRun = lstProfileScripts.getSelectionModel().getSelectedItems();
                } else {
                    scriptsToRun = lstSocialScripts.getSelectionModel().getSelectedItems();
                }
                currentTask = new MigrationPipeService(logTable, pgbTaskProgress, srcHost.getText(),
                        srcPort.getText(), srcDb.getText(), dstHost.getText(), dstPort.getText(),
                        dstDb.getText(), scriptsToRun);
            }
            if (!currentTask.isRunning()) {
                final Thread t = new Thread(currentTask, "Migration Task");
                t.start();
            }
        }
    });
}

From source file:Main.java

private Node makeDraggable(final Node node) {
    final DragContext dragContext = new DragContext();
    final Group wrapGroup = new Group(node);

    wrapGroup.addEventFilter(MouseEvent.ANY, new EventHandler<MouseEvent>() {
        public void handle(final MouseEvent mouseEvent) {
            if (dragModeActiveProperty.get()) {
                // disable mouse events for all children
                mouseEvent.consume();/*from   w  ww. j  a  va  2 s.  com*/
            }
        }
    });

    wrapGroup.addEventFilter(MouseEvent.MOUSE_PRESSED, new EventHandler<MouseEvent>() {
        public void handle(final MouseEvent mouseEvent) {
            if (dragModeActiveProperty.get()) {
                // remember initial mouse cursor coordinates
                // and node position
                dragContext.mouseAnchorX = mouseEvent.getX();
                dragContext.mouseAnchorY = mouseEvent.getY();
                dragContext.initialTranslateX = node.getTranslateX();
                dragContext.initialTranslateY = node.getTranslateY();
            }
        }
    });

    wrapGroup.addEventFilter(MouseEvent.MOUSE_DRAGGED, new EventHandler<MouseEvent>() {
        public void handle(final MouseEvent mouseEvent) {
            if (dragModeActiveProperty.get()) {
                // shift node from its initial position by delta
                // calculated from mouse cursor movement
                node.setTranslateX(
                        dragContext.initialTranslateX + mouseEvent.getX() - dragContext.mouseAnchorX);
                node.setTranslateY(
                        dragContext.initialTranslateY + mouseEvent.getY() - dragContext.mouseAnchorY);
            }
        }
    });

    return wrapGroup;
}

From source file:org.jacp.demo.perspectives.ContactPerspective.java

@PostConstruct
/**/* ww w. ja  v a2  s . co  m*/
 * create buttons in tool bars; menu entries
 */
public void PostConstructPerspective(final FXComponentLayout layout, final ResourceBundle resourceBundle) {
    LOGGER.debug("PostConstructPerspective ressource:" + resourceBundle);
    // create button in toolbar; button should switch top and bottom id's
    final JACPToolBar north = layout.getRegisteredToolBar(NORTH);
    final JACPToolBar south = layout.getRegisteredToolBar(SOUTH);
    final JACPToolBar west = layout.getRegisteredToolBar(WEST);
    final JACPToolBar east = layout.getRegisteredToolBar(EAST);

    final Button custom = new Button("switch");
    custom.setTooltip(new Tooltip("Switch Components"));
    custom.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(final ActionEvent e) {
            context.send(SWITCH_MESSAGE);

        }
    });
    north.addOnEnd(context.getId(), custom);

    // TEST OPTIONBUTTON ON NORTH
    north.addOnEnd(context.getId(),
            JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, BOTTOM, 10));
    north.addToCenter(context.getId(),
            JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, BOTTOM, 10));
    north.add(context.getId(),
            JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, BOTTOM, 10));
    west.add(context.getId(),
            JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, RIGHT));
    west.addToCenter(context.getId(),
            JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, RIGHT));
    west.addOnEnd(context.getId(),
            JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, RIGHT));
    east.addOnEnd(context.getId(),
            JACPOptionButtonCreator.createDefaultOptionButton("right Button", layout, LEFT));
    east.add(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("right Button", layout, LEFT));
    east.addToCenter(context.getId(),
            JACPOptionButtonCreator.createDefaultOptionButton("right Button", layout, LEFT));
    south.add(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("bottom Button", layout, TOP));
    south.addToCenter(context.getId(),
            JACPOptionButtonCreator.createDefaultOptionButton("bottom Button", layout, TOP));
    south.addOnEnd(context.getId(),
            JACPOptionButtonCreator.createDefaultOptionButton("bottom Button", layout, TOP));

    JACPHoverMenu menu = new JACPHoverMenu("Hovermenu", layout);

    VBox p = new VBox();
    p.setPadding(new Insets(10));
    Button b = new Button("HELLO");
    CheckBox check = new CheckBox("checkbox");

    p.getChildren().addAll(b, check);

    ColorPicker picker = new ColorPicker();
    menu.getContentPane().getChildren().add(p);

    north.addToCenter(context.getId(), menu);
    north.addToCenter(context.getId(), picker);

}

From source file:retsys.client.controller.ItemController.java

/**
 * Initializes the controller class./*from w w  w  . j a  v  a 2 s .  co  m*/
 */
@Override
public void initialize(URL url, ResourceBundle rb) {

    //Begin
    //  TextFields.bindAutoCompletion(name, new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Client>>() 
    AutoCompletionBinding<Item> txt_name = TextFields.bindAutoCompletion(name,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Item>>() {

                @Override
                public Collection<Item> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Item> list = null;
                    HttpHelper helper = new HttpHelper();
                    try {
                        LovHandler lovHandler = new LovHandler("items", "name");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<Item>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<Item>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(ItemController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }

            }, new StringConverter<Item>() {

                @Override
                public String toString(Item object) {
                    return object.getName() + " (ID:" + object.getId() + ")";
                }

                @Override
                public Item 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<Item>>() {

        @Override
        public void handle(AutoCompletionBinding.AutoCompletionEvent<Item> event) {
            Item item = event.getCompletion();
            //fill other item related fields
            id.setText(splitId(name.getText()) + "");
            name.setText(item.getName());
            rate.setText(item.getRate() + "");
            brand.setText(item.getBrand());
            color.setText(item.getColor());
            unit.setText(item.getUnit());
            size.setText(item.getSize());
            billno.setText(item.getBillno());
            Site.setText(item.getSite());
            remarks.setText(item.getRemarks());
            quantity.setText(item.getQuantity() + "");
            unit.setText(item.getUnit());
            transport_mode.setText(item.getTransportmode());
            transport_charges.setText(item.getTransportcharge() + "");
            supervisor.setText(item.getSupervisor());
            vendor.setText(item.getVendor().getName() + " (ID:" + item.getVendor().getId() + ")");
            godown_name.setText(item.getGodownName());
            location1.setText(item.getLocation1());

            minReorder.setText(item.getMinReorder());
            product.setText(item.getProduct().getName() + " (ID:" + item.getProduct().getId() + ")");
            discountPercentage.setText(item.getDiscountPercentage() + "");

            populateAuditValues(item);
        }
    });

    //Ends
    TextFields.bindAutoCompletion(vendor,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Vendor>>() {

                @Override
                public Collection<Vendor> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Vendor> list = null;
                    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(ProjectController.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.");
                }
            });
    //Project query

    TextFields.bindAutoCompletion(Site,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Project>>() {

                @Override
                public Collection<Project> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Project> list = null;
                    try {
                        LovHandler lovHandler = new LovHandler("projects", "name");
                        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.");
                }
            });

    //}
    // 
    //}

    // product query
    TextFields.bindAutoCompletion(product,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Product>>() {

                @Override
                public Collection<Product> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Product> list = null;
                    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.");
                }
            });
}

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();/*from  w  w  w . j  a  v a2s . c om*/
    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:gisintegration.SimpleSwingBrowser.java

private void createScene() {
    Platform.runLater(new Runnable() {
        @Override/*www.  j  a  va 2s .c  o  m*/
        public void run() {

            WebView view = new WebView();
            engine = view.getEngine();

            //                engine.titleProperty().addListener(new ChangeListener<String>() {
            //                    @Override
            //                    public void changed(ObservableValue<? extends String> observable, String oldValue, final String newValue) {
            //                        SwingUtilities.invokeLater(new Runnable() {
            //                            @Override
            //                            public void run() {
            //                                SimpleSwingBrowser.this.setTitle(newValue);
            //                            }
            //                        });
            //                    }
            //                });

            engine.setOnStatusChanged(new EventHandler<WebEvent<String>>() {
                @Override
                public void handle(final WebEvent<String> event) {
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            lblStatus.setText(event.getData());
                        }
                    });
                }
            });

            //                engine.locationProperty().addListener(new ChangeListener<String>() {
            //                    @Override
            //                    public void changed(ObservableValue<? extends String> ov, String oldValue, final String newValue) {
            //                        SwingUtilities.invokeLater(new Runnable() {
            //                            @Override
            //                            public void run() {
            //                                txtURL.setText(newValue);
            //                            }
            //                        });
            //                    }
            //                });

            engine.getLoadWorker().workDoneProperty().addListener(new ChangeListener<Number>() {
                @Override
                public void changed(ObservableValue<? extends Number> observableValue, Number oldValue,
                        final Number newValue) {
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            progressBar.setValue(newValue.intValue());
                        }
                    });
                }
            });

            engine.getLoadWorker().exceptionProperty().addListener(new ChangeListener<Throwable>() {

                public void changed(ObservableValue<? extends Throwable> o, Throwable old,
                        final Throwable value) {
                    if (engine.getLoadWorker().getState() == FAILED) {
                        SwingUtilities.invokeLater(new Runnable() {
                            @Override
                            public void run() {
                                JOptionPane.showMessageDialog(panel,
                                        (value != null) ? engine.getLocation() + "\n" + value.getMessage()
                                                : engine.getLocation() + "\nUnexpected error.",
                                        "Loading error...", JOptionPane.ERROR_MESSAGE);
                            }
                        });
                    }
                }
            });

            jfxPanel.setScene(new Scene(view));
        }
    });
}

From source file:ch.unibas.fittingwizard.presentation.MoleculeListPage.java

protected void fillButtonBar() {
    fittingParameterButton = ButtonFactory.createButtonBarButton("Define fitting parameters",
            new EventHandler<ActionEvent>() {
                @Override//  w w  w  .ja va  2s . co  m
                public void handle(ActionEvent actionEvent) {
                    logger.info("Defining fitting parameter.");

                    navigateTo(FittingParameterPage.class);
                }
            });
    fittingParameterButton.setDisable(true);
    addButtonToButtonBar(fittingParameterButton);
}