Java 类javafx.application.Platform 实例源码

项目:WebtoonDownloadManager    文件:ManualController.java   
/**
 * 웹툰조회
 */
public void getWebtoon(String code) {

    if (!"".equals(code)) {
        CommonService cs = new CommonService();

        Connection conn = cs.getConnection(code);
        conn.timeout(5000);

        Document doc = null;

        codeInputField.setText(code);
        wDesc.setWrapText(true);

        try {

            doc = conn.get();

            String title = doc.select("title").text().split("::")[0];
            setTitle(title);

            String author = doc.select("div.detail h2 > span").text();
            wTitle.setText(title + "(" + author + ")");

            String desc = doc.select("div.detail p").text();
            wDesc.setText(desc);

            String img = doc.select("div.thumb > a img").attr("src");
            thumbnail.setImage(new Image(img, true));

        } catch (Exception e) {
            e.printStackTrace();
        }
    } else {
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                AlertSupport alert = new AlertSupport("웹툰코드를 입력하세요.");
                alert.alertInfoMsg(stage);
            }
        });
    }
}
项目:marathonv5    文件:DisplayWindow.java   
@Override public void handleInput(GroupInputInfo info) {
    try {
        File file = info.getFile();
        if (file == null) {
            return;
        }
        Group group = Group.createGroup(type, file.toPath(), info.getName());
        if (group == null) {
            return;
        }
        fileUpdated(file);
        navigatorPanel.updated(DisplayWindow.this, new FileResource(file.getParentFile()));
        suitesPanel.updated(DisplayWindow.this, new FileResource(file));
        featuresPanel.updated(DisplayWindow.this, new FileResource(file));
        storiesPanel.updated(DisplayWindow.this, new FileResource(file));
        issuesPanel.updated(DisplayWindow.this, new FileResource(file));
        Platform.runLater(() -> openFile(file));
    } catch (Exception e) {
        e.printStackTrace();
        FXUIUtils.showConfirmDialog(DisplayWindow.this,
                "Could not complete creation of " + type.fileType().toLowerCase() + " file.",
                "Error in creating a " + type.fileType().toLowerCase() + " file", AlertType.ERROR);
    }
}
项目:IO    文件:SelectDeviceController.java   
@Override
protected void performSetup() {
    setTitle();
    // TODO: Better loading.
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            devicesLoadingLabel.setVisible(true);
            diskListView.setCellFactory(lv -> {
                TextFieldListCell<Disk> cell = new TextFieldListCell<>();
                cell.setConverter(workflowController.getStringConverterForDisks());
                return cell;
            });
            ObservableList<Disk> disks = FXCollections.observableArrayList();
            disks.addAll(workflowController.getAvailableDisks());
            devicesLoadingLabel.setVisible(false);
            diskListView.setItems(disks);
        }});
}
项目:marathonv5    文件:RFXChoiceBoxTest.java   
@Test public void getText() {
    ChoiceBox<?> choiceBox = (ChoiceBox<?>) getPrimaryStage().getScene().getRoot().lookup(".choice-box");
    LoggingRecorder lr = new LoggingRecorder();
    List<String> text = new ArrayList<>();
    Platform.runLater(() -> {
        RFXChoiceBox rfxChoiceBox = new RFXChoiceBox(choiceBox, null, null, lr);
        choiceBox.getSelectionModel().select(1);
        rfxChoiceBox.focusLost(null);
        text.add(rfxChoiceBox._getText());
    });
    new Wait("Waiting for choice box text.") {
        @Override public boolean until() {
            return text.size() > 0;
        }
    };
    AssertJUnit.assertEquals("Cat", text.get(0));
}
项目:marathonv5    文件:DisplayWindow.java   
/**
 * Initialize the status bar
 */
private void initStatusBar() {
    statusPanel.getFixtureLabel().setOnMouseClicked((e) -> {
        onSelectFixture();
    });
    statusPanel.getRowLabel().setOnMouseClicked((e) -> {
        gotoLine();
    });
    statusPanel.getInsertLabel().setOnMouseClicked((e) -> {
        Platform.runLater(() -> {
            if (currentEditor != null) {
                currentEditor.toggleInsertMode();
            }
        });
    });
}
项目:javafx-qiniu-tinypng-client    文件:MainView.java   
@Override
protected void onViewCreated() {
    siderBarView.setOnItemSelectedListener(contentView::loadBucket);
    contentView.setOnItemSelectedListener(this::updateSelectItem);
    contentView.setUpdateListener(bucketFile -> {
        if (Platform.isFxApplicationThread()) {
            updateSelectItem(bucketFile);
        } else {
            runOnUiThread(() -> this.updateSelectItem(bucketFile));
        }
    });

    // 初始化菜单
    Menu setting = new Menu("设置");
    setting.getItems().add(getMenuItem("TinyPNG", "tinypng"));
    setting.getItems().add(getMenuItem("七牛", "qiniu"));
    setting.getItems().add(getMenuItem("Gif", "gif"));

    Menu about = new Menu("关于");
    about.getItems().add(getMenuItem("关于BlogHelper", "aboutBlogHelper"));
    about.getItems().add(getMenuItem("关于作者cmlanche", "aboutAnchor"));

    menuBar.getMenus().add(setting);
    menuBar.getMenus().add(about);

    if (PlatformUtil.isMac()) {
        menuBar.setUseSystemMenuBar(true);
    }

    // 操作按钮
    downloadBtn.setOnAction(event -> contentView.handleAction("download"));
    renameBtn.setOnAction(event -> contentView.handleAction("rename"));
    deleteBtn.setOnAction(event -> contentView.handleAction("delete"));
    optimizeBtn.setOnAction(event -> contentView.handleAction("optimize"));
    uploadBtn.setOnAction(event -> contentView.handleAction("upload"));
}
项目:textmd    文件:EditorPane.java   
public boolean spellcheckDocument() {
    editorToolBar.setActionText("Spell checking document \'" + file.getName() + "\'");
    Platform.runLater(() -> {
        try {
            timer.start();
            List<RuleMatch> matches = spellcheck.check(getContent());
            MarkdownHighligher.computeSpellcheckHighlighting(matches, this);
            editorToolBar.setActionText("Found " + matches.size() + " misspellings in the document \'" + file.getName() + "\' (" + timer.end() + "ms)");
        } catch (IOException e) {
            dialogFactory.buildExceptionDialogBox(
                    dict.DIALOG_EXCEPTION_TITLE,
                    dict.DIALOG_EXCEPTION_SPELLCHECK_CONTENT,
                    e.getMessage(),
                    e
            );
        }
    });

    return true;
}
项目:marathonv5    文件:RFXTreeViewCheckBoxTreeCellTest.java   
@Test public void select() {
    TreeView<?> treeView = (TreeView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(new Runnable() {
        @Override public void run() {
            Point2D point = getPoint(treeView, 1);
            RFXTreeView rfxListView = new RFXTreeView(treeView, null, point, lr);
            rfxListView.focusGained(rfxListView);
            CheckBoxTreeItem<?> treeItem = (CheckBoxTreeItem<?>) treeView.getTreeItem(1);
            treeItem.setSelected(true);
            rfxListView.focusLost(rfxListView);
        }
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("Child Node 1:checked", recording.getParameters()[0]);
}
项目:atbash-octopus    文件:ApplicationMenu.java   
public void initialize() {
    MenuBar menuBar = new MenuBar();
    // Make same width as the stage
    menuBar.prefWidthProperty().bind(primaryStage.widthProperty());
    rootPane.setTop(menuBar);

    // File menu - new, save, exit
    Menu fileMenu = new Menu("File");
    MenuItem newMenuItem = createMenuItem("New", actionEvent -> this.onNewFile());

    MenuItem openMenuItem = createMenuItem("Open", actionEvent -> this.onOpenFile());

    MenuItem saveMenuItem = createMenuItem("Save", actionEvent -> this.onSaveFile());
    saveMenuItem.disableProperty().bind(jwkSetData.changedProperty().not());

    MenuItem exitMenuItem = createMenuItem("Exit", actionEvent -> Platform.exit());

    fileMenu.getItems().addAll(newMenuItem, openMenuItem, saveMenuItem,
            new SeparatorMenuItem(), exitMenuItem);

    menuBar.getMenus().addAll(fileMenu);
}
项目:EMBER    文件:EmberTest.java   
@Test
public void testNormalStart() throws Exception {
    Platform.runLater(() -> {
        Ember ember = new Ember();
        Stage stage = new Stage();
        try {
            ember.start(stage);
        } catch (Exception ex) {
            fail("An exception is thrown.");
            Logger.getLogger(
                    EmberTest.class.getName()).
                    log(Level.SEVERE, null, ex);
        }
    });

}
项目:marathonv5    文件:JavaFXElementTest.java   
public void startGUI(Pane pane) {
    Platform.runLater(new Runnable() {
        @Override public void run() {
            primaryStage.hide();
            primaryStage.setScene(new Scene(pane));
            primaryStage.sizeToScene();
            primaryStage.show();
        }
    });
    new Wait("Waiting for applicationHelper to be initialized") {
        @Override public boolean until() {
            try {
                return primaryStage.getScene().getRoot() == pane;
            } catch (Throwable t) {
                return false;
            }
        }
    };
}
项目:TOA-DataSync    文件:DataSyncController.java   
@FXML
    public void startAutoSync() {
        DataSync.getMainStage().setOnCloseRequest(closeEvent -> this.syncController.kill());
        this.syncController.execute((count) -> {
            Platform.runLater(() -> {
                Date date = new Date();
                TOALogger.log(Level.INFO, "Executing update #" + count + " at " + DateFormat.getTimeInstance(DateFormat.SHORT).format(date));
                TOALogger.log(Level.INFO, "There are " + Thread.activeCount() + " threads.");
                this.matchesController.syncMatches();
                this.matchesController.checkMatchSchedule();
                this.matchesController.checkMatchDetails();
//                this.rankingsController.syncRankings();
                // We're going to try THIS instead....
                this.rankingsController.getRankingsByFile();
                this.rankingsController.postRankings();
                if (this.btnSyncMatches.selectedProperty().get()) {
                     this.matchesController.postCompletedMatches();
                }
            });
        });
    }
项目:marathonv5    文件:RFXMenuItemTest.java   
@Test public void duplicateMenuPath() {
    List<String> path = new ArrayList<>();
    Platform.runLater(() -> {
        Menu menuFile = new Menu("File");
        MenuItem add = new MenuItem("Shuffle");

        MenuItem clear = new MenuItem("Clear");
        MenuItem clear1 = new MenuItem("Clear");
        MenuItem clear2 = new MenuItem("Clear");

        MenuItem exit = new MenuItem("Exit");

        menuFile.getItems().addAll(add, clear, clear1, clear2, new SeparatorMenuItem(), exit);
        RFXMenuItem rfxMenuItem = new RFXMenuItem(null, null);
        path.add(rfxMenuItem.getSelectedMenuPath(clear2));
    });
    new Wait("Waiting for menu selection path") {
        @Override public boolean until() {
            return path.size() > 0;
        }
    };
    AssertJUnit.assertEquals("File>>Clear(2)", path.get(0));
}
项目:flexfx    文件:Bootstrap.java   
/**
 * Called by a thread created when
 */
public static void startMe()
{
    if (primaryStage == null)
    {
        try
        {
            Platform.setImplicitExit(false);
            Bootstrap.launch();
        }
        catch (Exception exception)
        {
            FlexFXBundle.setStartupException(exception);
        }
    }
    else
    {
        FlexFXBundle.setStage(primaryStage, IS_FX_THREAD_RESTART);
    }
}
项目:charts    文件:World.java   
private void registerListeners() {
    widthProperty().addListener(o -> resize());
    heightProperty().addListener(o -> resize());
    sceneProperty().addListener(o -> {
        if (!locations.isEmpty()) { addShapesToScene(locations.values()); }
        if (isZoomEnabled()) { getScene().addEventFilter( ScrollEvent.ANY, new WeakEventHandler<>(_scrollEventHandler)); }

        locations.addListener((MapChangeListener<Location, Shape>) CHANGE -> {
            if (CHANGE.wasAdded()) {
                addShapesToScene(CHANGE.getValueAdded());
            } else if(CHANGE.wasRemoved()) {
                Platform.runLater(() -> pane.getChildren().remove(CHANGE.getValueRemoved()));
            }
        });
    });
}
项目:marathonv5    文件:AdvancedMedia.java   
protected void updateValues() {
    if (playTime != null && timeSlider != null && volumeSlider != null && duration != null) {
        Platform.runLater(new Runnable() {
            public void run() {
                Duration currentTime = mp.getCurrentTime();
                playTime.setText(formatTime(currentTime, duration));
                timeSlider.setDisable(duration.isUnknown());
                if (!timeSlider.isDisabled() && duration.greaterThan(Duration.ZERO) && !timeSlider.isValueChanging()) {
                    timeSlider.setValue(currentTime.divide(duration).toMillis() * 100.0);
                }
                if (!volumeSlider.isValueChanging()) {
                    volumeSlider.setValue((int) Math.round(mp.getVolume() * 100));
                }
            }
        });
    }
}
项目:twichat    文件:Controller.java   
@Override
  public void initialize(URL location, ResourceBundle resources) {
    Main.bot.currentChannel = Main.bot.getChannels().get(0);
vbox.setSpacing(30);

      System.out.println("initialized");
      updateViewCount();

      new Timer().schedule(new TimerTask() {

    @Override
    public void run() {
        Platform.runLater(() -> { Controller.controller.viewCount
            .setText("Viewers: " + Main.bot.getChannels().get(0).getViewersNum()); });

    }
}, 0, 10000);

      vbox.heightProperty().addListener(new ChangeListener<Number>() {
    @Override
    public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
        scrollPane.setVvalue(1.0);
    }
});

  }
项目:Notebook    文件:ArticleFragment.java   
private void loadData(int page) {

        ThreadUtils.run(() ->{
            Result<Article> result;
            synchronized (ArticleFragment.class) {
                 result = ArticleDao.getInstance().getPage(page);
            }
            Platform.runLater(()->{
                listView.getItems().clear();
                List<Article> datas = result.recordList;
                listView.getItems().addAll(datas);

                pager_article.setPageCount(result.pageCount);// ע��ҳ���Ķ�̬�仯
                if(FIRST){
                    pager_article.setVisible(true);
                    FIRST = false;
                }
            });
        });

    }
项目:xpanderfx    文件:MainFXMLDocumentController.java   
/**
 * 
 * @param root 
 */
private void setExitAnimationToNode(Node root) {
    if(about.isShowing()) {
        this.popupCloser(about, about_box);
    }
    if(help.isShowing()) {
        this.popupCloser(help, help_box);
    }
    ScaleTransition st = new ScaleTransition(Duration.seconds(.4), root);
    st.setToX(0);
    st.setToY(0);
    st.play();

    FadeTransition fd = new FadeTransition(Duration.seconds(.3), root);
    fd.setToValue(.1);
    fd.play();

    st.setOnFinished(e -> Platform.exit());
}
项目:maven-package-gui-installer    文件:MainController.java   
private void openFile(File file) {
    Platform.runLater(() -> {
        try {
            MavenBean bean = handler.handle(file);
            bean.setId(filesInfo.size() + 1);
            if (null != bean) {
                filesInfo.add(bean);
            }
        } catch (Exception ex) {
            StringBuilder reason = new StringBuilder();
            reason.append(Application.getResource().getString("error.reason"))
                    .append(":")
                    .append(file.getName())
                    .append(ex.getMessage());
            Alert alert = ComponentUtils.dialog(stage, "", reason.toString());
            alert.show();
        }
    });
}
项目:marathonv5    文件:RFXButtonBaseTest.java   
@Test public void click() {
    Button button = (Button) getPrimaryStage().getScene().getRoot().lookup(".button");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(new Runnable() {
        @Override public void run() {
            RFXButtonBase rfxButtonBase = new RFXButtonBase(button, null, null, lr);
            Point2D sceneXY = button.localToScene(new Point2D(3, 3));
            PickResult pickResult = new PickResult(button, sceneXY.getX(), sceneXY.getY());
            Point2D screenXY = button.localToScreen(new Point2D(3, 3));
            MouseEvent me = new MouseEvent(button, button, MouseEvent.MOUSE_PRESSED, 3, 3, sceneXY.getX(), screenXY.getY(),
                    MouseButton.PRIMARY, 1, false, false, false, false, true, false, false, false, false, false, pickResult);
            rfxButtonBase.mouseButton1Pressed(me);
        }
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording select = recordings.get(0);
    AssertJUnit.assertEquals("click", select.getCall());
    AssertJUnit.assertEquals("", select.getParameters()[0]);
}
项目:vars-annotation    文件:AnnotationTableControllerDemo.java   
@Override
public void start(Stage primaryStage) throws Exception {
    UIToolBox toolBox = DemoConstants.getToolBox();
    AnnotationTableController controller = new AnnotationTableController(toolBox);

    Scene scene = new Scene(controller.getTableView());
    scene.getStylesheets().add("/css/common.css");
    scene.getStylesheets().add("/css/annotable.css");

    primaryStage.setScene(scene);
    primaryStage.show();

    final List<Annotation> annotations = makeAnnotations();
    controller.getTableView().setItems(FXCollections.observableList(annotations));

    primaryStage.setOnCloseRequest(e -> {
        Platform.exit();
        System.exit(0);
    });
}
项目:IO    文件:ProcessController.java   
@Override
public void handleDiskInsertion(Disk insertedDisk) {
    if (state.getSelectedDevice() != null) {
        return;
    }
    else {
        Platform.runLater(() -> {
            state.setSelectedDevice(insertedDisk);
            setupImaging();
            // TODO: Not this way. This code is terrible.
            ImagingController imagingController = BaseController.getCurrentController().loadFXML(ImagingController.class,
                    ImagingController.getFXMLLocation());
            BaseController.changeScene(imagingController.getScene());
            beginImaging();
        });
    }
}
项目:ChatRoom-JavaFX    文件:ChatController.java   
/**
 * 处理通知信息的显示
 * @param notice
 */
public void addNotification(String notice){
    Platform.runLater(() ->{
        SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");//设置日期格式
        String timer = df.format(new Date());// new Date()为获取当前系统时间
        String content = timer +  ": " + notice;
        BubbledTextFlow noticeBubbled = new BubbledTextFlow(EmojiDisplayer.createEmojiAndTextNode(content));
        //noticeBubbled.setTextFill(Color.web("#031c30"));
        noticeBubbled.setBackground(new Background(new BackgroundFill(Color.WHITE,
                   null, null)));
           HBox x = new HBox();
           //x.setMaxWidth(chatPaneListView.getWidth() - 20);
           x.setAlignment(Pos.TOP_CENTER);
           noticeBubbled.setBubbleSpec(BubbleSpec.FACE_TOP);
           x.getChildren().addAll(noticeBubbled);
           chatPaneListView.getItems().add(x);
    });
}
项目:drd    文件:Context.java   
/**
 * Vytvoří nový kontext apliakce
 *
 * @param databaseName Název databáze
 */
public Context(String databaseName, ResourceBundle resources) throws FileNotFoundException {
    this.resources = resources;
    this.appDirectory = new File(appDirs
        .getUserDataDir(CREDENTAILS_APP_NAME, CREDENTAILS_APP_VERSION, CREDENTILS_APP_AUTHOR));
    if (!appDirectory.exists()) {
        if (!appDirectory.mkdirs()) {
            logger.error("Nepodařilo se vytvořit složku aplikace, zavírám...");
            Platform.exit();
        }
    }
    logger.info("Používám pracovní adresář: {}", appDirectory.getPath());
    try {
        database = new SQLite(appDirectory.getPath() + SEPARATOR + databaseName);
    } catch (SQLException e) {
        throw new FileNotFoundException();
    }

    initFirebase();
    userManager = new UserManager(FirebaseDatabase.getInstance());
    initManagers();
}
项目:vars-annotation    文件:VideoBrowserPaneController.java   
public ListView<String> getVideoSequenceListView() {
    if (videoSequenceListView == null) {
        videoSequenceListView = new ListView<>();
        videoSequenceListView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);

        // When a video sequence is selected set the next list to all the video names
        // available in the video sequence
        videoSequenceListView.getSelectionModel()
                .selectedItemProperty()
                .addListener((obs, oldValue, newValue) -> {
                    mediaService.findVideoNamesByVideoSequenceName(newValue)
                            .thenAccept(vs -> Platform.runLater(() -> {
                                getVideoListView().setItems(FXCollections.observableArrayList(vs));
                                if (vs.size() == 1) {
                                    getVideoListView().getSelectionModel().select(0);
                                }
                            }));
                });

        videoSequenceListView.getSelectionModel()
                .selectedItemProperty()
                .addListener(obs ->  getVideoListView().setItems(FXCollections.emptyObservableList()));
    }
    return videoSequenceListView;
}
项目:hygene    文件:GraphStoreTest.java   
@Test
void testOpenGffFile()  throws IOException, ExecutionException, InterruptedException {
    final File file = new File("src/test/resources/gff/simple.gff");

    final CompletableFuture<Object> future = new CompletableFuture<>();

    Platform.runLater(() -> {
        try {
            graphStore.loadGffFile(file, ProgressUpdater.DUMMY);
        } catch (final IOException e) {
            e.printStackTrace();
        }

        Platform.runLater(() -> {
            assertThat(graphStore.getGffFileProperty().get()).isNotNull();
            future.complete(null);
        });
    });

    assertThat(future.get()).isNull();

    Files.deleteIfExists(Paths.get(file.getPath() + FileDatabaseDriver.DB_FILE_EXTENSION));
}
项目:CalendarFX    文件:CalendarViewTimeUpdateThread.java   
@Override
@SuppressWarnings("InfiniteLoopStatement")
public void run() {
    while (true) {
        Platform.runLater(() -> {
            calendarView.setToday(LocalDate.now());
            calendarView.setTime(LocalTime.now());
        });

        try {
            sleep(TEN_SECONDS);
        } catch (InterruptedException e) {
            // Do nothing
        }
    }
}
项目:marathonv5    文件:JavaFXTableViewElementScrollTest.java   
@Test public void scrollToCell() throws Throwable {
    Stage primaryStage = getPrimaryStage();
    primaryStage.setWidth(250);
    primaryStage.setHeight(250);
    TableView<?> tableViewNode = (TableView<?>) primaryStage.getScene().getRoot().lookup(".table-view");
    Platform.runLater(() -> {
        tableViewNode.getSelectionModel().setCellSelectionEnabled(true);
        tableView.marathon_select("{\"cells\":[[\"10\",\"Email\"]]}");
    });
    new Wait("Waiting for the point to be in viewport") {
        @Override public boolean until() {
            return getPoint(tableViewNode, 2, 10) != null;
        }
    };
    Point2D point = getPoint(tableViewNode, 2, 10);
    AssertJUnit.assertTrue(tableViewNode.getBoundsInLocal().contains(point));
}
项目:LCL    文件:Transition.java   
public static void lollipop(double x, double y) {
    Circle circle = new Circle(x, y, 2);
    circle.setFill(randomColor());
    FrameController.instance.hover.getChildren().add(circle);
    FadeTransition fadeTransition = new FadeTransition(Duration.millis(500), circle);
    fadeTransition.setAutoReverse(true);
    fadeTransition.setCycleCount(2);
    fadeTransition.setFromValue(0.0);
    fadeTransition.setToValue(1.0);
    ScaleTransition scaleTransition = new ScaleTransition(Duration.millis(1000), circle);
    scaleTransition.setToX(10.0);
    scaleTransition.setToY(10.0);
    scaleTransition.setCycleCount(1);
    ParallelTransition parallelTransition = new ParallelTransition(fadeTransition, scaleTransition);
    parallelTransition.play();
    executorService.schedule(() -> Platform.runLater(() ->
            FrameController.instance.hover.getChildren().remove(circle)), 1000, TimeUnit.MILLISECONDS);
}
项目:Cypher    文件:FXThreadedObservableValueWrapper.java   
@Override
public void addListener(InvalidationListener invalidationListener) {
    synchronized (this) {
        // If first listener start listening to inner value
        if (invalidationListeners.isEmpty()) {
            invalidationListenerObject = (observable) -> {
                Platform.runLater(() -> {
                    synchronized (this) {
                        for (InvalidationListener listener : invalidationListeners) {
                            listener.invalidated(this);
                        }
                    }
                });
            };
            inner.addListener(invalidationListenerObject);
        }
        invalidationListeners.add(invalidationListener);
    }
}
项目:can4eve    文件:TestAppGUI.java   
@Test
public void testVehiclePresenter() throws Exception {
  FXMLSampleApp sampleApp = new FXMLSampleApp("vehiclePresenter");
  sampleApp.showAndOpen();
  VehiclePresenter vehiclePresenter = sampleApp.fxml.loadPresenter("vehicle",
      Vehicle.class, exceptionHandler);
  assertNotNull(vehiclePresenter);
  Platform.runLater(() -> {
    try {
      vehiclePresenter.show(Vehicle.getInstance());
    } catch (Exception e) {
      ErrorHandler.handle(e);
      fail("there should be no exception");
    }
  });
  Thread.sleep(SHOW_TIME);
  sampleApp.close();
}
项目:incubator-netbeans    文件:ComponentsTest.java   
@Test public void loadFX() throws Exception {
    final CountDownLatch cdl = new CountDownLatch(1);
    final CountDownLatch done = new CountDownLatch(1);
    final JFXPanel p = new JFXPanel();
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            Node wv = TestPages.getFX(10, cdl);
            Scene s = new Scene(new Group(wv));
            p.setScene(s);
            done.countDown();
        }
    });
    done.await();
    JFrame f = new JFrame();
    f.getContentPane().add(p);
    f.pack();
    f.setVisible(true);
    cdl.await();
}
项目:testing-video    文件:FxDisplay.java   
public static void runAndWait(Runnable runnable) {
    CompletableFuture<Void> future = new CompletableFuture<>();

    Platform.runLater(() -> {
        try {
            runnable.run();
        } catch (Throwable t) {
            future.completeExceptionally(t);
            return;
        }

        future.complete(null);
    });

    try {
        future.get();
    } catch (InterruptedException | ExecutionException e) {
        throw new RuntimeException(e);
    }
}
项目:ExtremeGuiMakeover    文件:MediaControl.java   
protected void updateValues() {
    if (playTime != null && timeSlider != null && volumeSlider != null) {
        Platform.runLater(() -> {
            MediaPlayer mp = getMediaPlayer();

            Duration currentTime = mp.getCurrentTime();
            playTime.setText(formatTime(currentTime, duration));
            timeSlider.setDisable(duration.isUnknown());
            if (!timeSlider.isDisabled()
                    && duration.greaterThan(Duration.ZERO)
                    && !timeSlider.isValueChanging()) {
                timeSlider.setValue(currentTime.divide(duration).toMillis()
                        * 100.0);
            }
            if (!volumeSlider.isValueChanging()) {
                volumeSlider.setValue((int) Math.round(mp.getVolume()
                        * 100));
            }
        });
    }
}
项目:MysticMaze    文件:MainView.java   
@Override
public void start(Stage primaryStage) {
    this.primaryStage = primaryStage;
    MainViewController mainController = new MainViewController();
    initStartView();

    /*Thread CardGameThread = new Thread(CardGame.instance);
    CardGameThread.start();
    socketClient = new GUISocket(CardGame.instance.getSocketServer());*/

    primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
        @Override
        public void handle(WindowEvent t) {
            Platform.exit();
            System.exit(0);
        }
    });
}
项目:marathonv5    文件:RFXButtonBaseTest.java   
@Test public void getText() {
    Button button = (Button) getPrimaryStage().getScene().getRoot().lookup(".button");
    LoggingRecorder lr = new LoggingRecorder();
    List<String> text = new ArrayList<>();
    Platform.runLater(new Runnable() {
        @Override public void run() {
            RFXButtonBase rfxButtonBase = new RFXButtonBase(button, null, null, lr);
            Point2D sceneXY = button.localToScene(new Point2D(3, 3));
            PickResult pickResult = new PickResult(button, sceneXY.getX(), sceneXY.getY());
            Point2D screenXY = button.localToScreen(new Point2D(3, 3));
            MouseEvent me = new MouseEvent(button, button, MouseEvent.MOUSE_PRESSED, 3, 3, sceneXY.getX(), screenXY.getY(),
                    MouseButton.PRIMARY, 1, false, false, false, false, true, false, false, false, false, false, pickResult);
            rfxButtonBase.mouseButton1Pressed(me);
            text.add(rfxButtonBase.getAttribute("text"));
        }
    });
    new Wait("Waiting for button text.") {
        @Override public boolean until() {
            return text.size() > 0;
        }
    };
    AssertJUnit.assertEquals("Color", text.get(0));
}
项目:vars-annotation    文件:OldReferenceNumberBC.java   
protected void apply() {
    Media media = toolBox.getData().getMedia();
    List<Annotation> selected = new ArrayList<>(toolBox.getData().getSelectedAnnotations());

    decorator.findReferenceNumberAssociations(media, associationKey)
            .thenAccept(as -> {
                List<String> refNums = associationToIdentityRefs(as);
                Platform.runLater(() -> {
                    ChoiceDialog<String> dlg = getDialog();
                    dlg.getItems().clear();
                    if (!refNums.isEmpty()) {
                        dlg.getItems().addAll(refNums);
                        dlg.setSelectedItem(refNums.iterator().next());
                        Optional<String> integer = dlg.showAndWait();
                        integer.ifPresent(i -> {
                            Association a = new Association(associationKey, Association.VALUE_SELF, i);
                            toolBox.getEventBus()
                                    .send(new CreateAssociationsCmd(a, selected));
                        });
                    }
                });

            });
}
项目:worldheatmap    文件:World.java   
private void registerListeners() {
    widthProperty().addListener(o -> resize());
    heightProperty().addListener(o -> resize());
    sceneProperty().addListener(o -> {
        if (!locations.isEmpty()) { addShapesToScene(locations.values()); }
        if (isZoomEnabled()) { getScene().addEventFilter( ScrollEvent.ANY, new WeakEventHandler<>(_scrollEventHandler)); }

        locations.addListener((MapChangeListener<Location, Shape>) CHANGE -> {
            if (CHANGE.wasAdded()) {
                addShapesToScene(CHANGE.getValueAdded());
            } else if(CHANGE.wasRemoved()) {
                Platform.runLater(() -> pane.getChildren().remove(CHANGE.getValueRemoved()));
            }
        });
    });
}
项目:marathonv5    文件:RFXChoiceBoxTest.java   
@Test public void selectOptionWithQuotes() {
    @SuppressWarnings("unchecked")
    ChoiceBox<String> choiceBox = (ChoiceBox<String>) getPrimaryStage().getScene().getRoot().lookup(".choice-box");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(() -> {
        RFXChoiceBox rfxChoiceBox = new RFXChoiceBox(choiceBox, null, null, lr);
        choiceBox.getItems().add(" \"Mouse \" ");
        choiceBox.getSelectionModel().select(" \"Mouse \" ");
        rfxChoiceBox.focusLost(null);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals(" \"Mouse \" ", recording.getParameters()[0]);
}