javafx.scene.control.Button#setOnAction ( )源码实例Demo

下面列出了javafx.scene.control.Button#setOnAction ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: SmartCity-ParkingManagement   文件: PmMap.java
protected Marker createMarker(final LatLong lat, final String title) {
	final MarkerOptions options = new MarkerOptions();
	options.position(lat).title(title).visible(true);
	final Marker $ = new MyMarker(options, title, lat);
	markers.add($);
	fromLocation.getItems().add(title);
	toLocation.getItems().add(title);
	final HBox hbox = new HBox();
	hbox.setPadding(new Insets(8, 5, 8, 5));
	hbox.setSpacing(8);
	final Label l = new Label(title);
	final Button btn = new Button("remove");
	btn.setOnAction(λ -> {
		map.removeMarker($);
		markerVbox.getChildren().remove(hbox);
		fromLocation.getItems().remove(title);
		toLocation.getItems().remove(title);
	});
	btns.add(btn);
	hbox.getChildren().addAll(l, btn);
	VBox.setMargin(hbox, new Insets(0, 0, 0, 8));
	markerVbox.getChildren().add(hbox);
	return $;

}
 
public void display(final Stage primaryStage, final gui.manager.WindowEnum none, final ArrayList<AbstractWindow> prevWindows) {
	window.setTitle("ManagerEdit1");
	window.setWidth(400);
	window.setHeight(100);
	final VBox vbox = new VBox(8);
	vbox.setPadding(new Insets(10, 10, 10, 10));
	vbox.setAlignment(Pos.CENTER);
	final Scene scene = new Scene(vbox);

	final Button editButton = new Button("View & Edit");
	editButton.setOnAction(λ -> {

	});
	vbox.getChildren().add(editButton);
	// scene.getStylesheets().add(getClass().getResource("mainStyle.css").toExternalForm());
	window.setScene(scene);
	window.show();

}
 
源代码3 项目: arma-dialog-creator   文件: WizardStageDialog.java
public WizardStageDialog(@Nullable Stage primaryStage, @Nullable String title, boolean hasHelp, @NotNull WizardStep... wizardSteps) {
	super(primaryStage, new StackPane(), title, true, true, hasHelp);


	wizardStepsReadOnly = new ReadOnlyList<>(wizardSteps);

	btnPrevious = new Button(Lang.ApplicationBundle().getString("Wizards.previous"));
	btnPrevious.setOnAction(new EventHandler<ActionEvent>() {
		@Override
		public void handle(ActionEvent event) {
			goBackwardStep();
		}
	});

	btnPrevious.setPrefWidth(GenericResponseFooter.PREFFERED_BUTTON_OK_WIDTH);
	footer.getRightContainer().getChildren().add(1, btnPrevious);
	footer.btnOk.setText(Lang.ApplicationBundle().getString("Wizards.next"));

	Collections.addAll(this.wizardSteps, wizardSteps);

	for (WizardStep step : wizardSteps) {
		addWizardStep(step);
	}
	btnPrevious.setDisable(true);
}
 
源代码4 项目: BlockMap   文件: Pin.java
@Override
protected PopOver initInfo() {
	PopOver info = super.initInfo();
	GridPane content = new GridPane();
	content.getStyleClass().add("grid");

	content.add(new Label("Player position:"), 0, 2);

	Vector3dc position = player.getPosition();
	Button jumpButton = new Button(position.toString());
	jumpButton.setTooltip(new Tooltip("Click to go there"));
	content.add(jumpButton, 1, 2);
	jumpButton.setOnAction(e -> {
		Vector2d spawnpoint = new Vector2d(position.x(), position.z());
		AABBd frustum = viewport.frustumProperty.get();
		viewport.translationProperty.set(spawnpoint.negate().add((frustum.maxX - frustum.minX) / 2, (frustum.maxY - frustum.minY) / 2));
		info.hide();
	});

	info.setContentNode(content);
	return info;
}
 
源代码5 项目: RichTextFX   文件: RichTextDemo.java
private Button createButton(String styleClass, Runnable action, String toolTip) {
    Button button = new Button();
    button.getStyleClass().add(styleClass);
    button.setOnAction(evt -> {
        action.run();
        area.requestFocus();
    });
    button.setPrefWidth(25);
    button.setPrefHeight(25);
    if (toolTip != null) {
        button.setTooltip(new Tooltip(toolTip));
    }
    return button;
}
 
源代码6 项目: marathonv5   文件: HTMLView.java
public HTMLView() {
    viewport = ToolBarContainer.createDefaultContainer(Orientation.RIGHT);
    webView = new WebView();
    viewport.setContent(webView);
    VLToolBar bar = new VLToolBar();
    Button openInBrowser = FXUIUtils.createButton("open-in-browser", "Open in External Browser", true);
    Button prevPage = FXUIUtils.createButton("prev", "Previous Page", false);
    WebHistory history = webView.getEngine().getHistory();
    prevPage.setOnAction((event) -> {
        history.go(-1);
    });
    bar.add(prevPage);
    Button nextPage = FXUIUtils.createButton("next", "Next Page", false);
    nextPage.setOnAction((event) -> {
        history.go(1);
    });
    bar.add(nextPage);
    openInBrowser.setOnAction((event) -> {
        try {
            URI uri = ProjectHTTPDServer.getURI(fileHandler.getCurrentFile().toPath());
            if (uri != null)
                Desktop.getDesktop().browse(uri);
            else
                Desktop.getDesktop().open(fileHandler.getCurrentFile());
        } catch (IOException e) {
            e.printStackTrace();
        }
    });
    bar.add(openInBrowser);
    history.currentIndexProperty().addListener((ob, o, n) -> {
        nextPage.setDisable(n.intValue() == history.getEntries().size() - 1);
        prevPage.setDisable(n.intValue() == 0);
    });
    viewport.getToolBarPanel().add(bar);
}
 
源代码7 项目: mars-sim   文件: SettlementScene.java
public Scene createScene() {
    Group  root  =  new  Group();
    Scene  settlementScene  =  new  Scene(root);
    settlementScene.getStylesheets().addAll("/fxui/css/settlementskin.css");		
    Button continueButton = new Button("Back to Main Menu");
    continueButton.setOnAction(new EventHandler<ActionEvent>() {
    @Override
    public void handle(ActionEvent arg0) {
    	//MainMenu.changeScene(1);
    }
});
    
    root.getChildren().add(continueButton);
    return (settlementScene);
}
 
源代码8 项目: mars-sim   文件: MarsNode.java
public Button createGreenhouseDialog(Farming farm) {
	String name = farm.getBuilding().getNickName();
	Button b = new Button(name);
	b.setMaxWidth(Double.MAX_VALUE);

     List<String> choices = new ArrayList<>();
     choices.add("Lettuce");
     choices.add("Green Peas");
     choices.add("Carrot");

     ChoiceDialog<String> dialog = new ChoiceDialog<>("List of Crops", choices);
     dialog.setTitle(name);
     dialog.setHeaderText("Plant a Crop");
     dialog.setContentText("Choose Your Crop:");
     dialog.initOwner(stage); // post the same icon from stage
     dialog.initStyle(StageStyle.UTILITY);
     //dialog.initModality(Modality.NONE);

	b.setPadding(new Insets(20));
	b.setId("settlement-node");
	b.getStylesheets().add("/fxui/css/settlementnode.css");
    b.setOnAction(e->{
        // The Java 8 way to get the response value (with lambda expression).
    	Optional<String> selected = dialog.showAndWait();
        selected.ifPresent(crop -> System.out.println("Crop added to the queue: " + crop));
    });

   //ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE);
   //ButtonType buttonTypeOk = new ButtonType("OK", ButtonData.OK_DONE);
   //dialog.getButtonTypes().setAll(buttonTypeCancel, buttonTypeOk);

    return b;
}
 
源代码9 项目: SONDY   文件: DataManipulationUI.java
public final VBox createImportButton(){
    VBox buttonBox = new VBox();
    buttonBox.setAlignment(Pos.CENTER);
    Button importButton = new Button("Import");
    UIUtils.setSize(importButton,Main.columnWidthRIGHT,24);
    importButton.setOnAction((ActionEvent event) -> {
        AppParameters.disableUI(true);
        newDatasetProperties.put("id",newDatasetIdentifierField.getText());
        newDatasetProperties.put("description",newDatasetDescriptionField.getText());
        Dataset dataset = new Dataset();
        AppParameters.disableUI(true);
        String messagesFilePath = newDatasetProperties.get("messagesFile");
        String networkFilePath = newDatasetProperties.get("networkFile");
        LogUI.addLogEntry("Importing '"+newDatasetIdentifierField.getText()+"' (messages file: "+messagesFilePath+", network file: "+networkFilePath+")...");
        final Task<String> waitingTask = new Task<String>() {
                @Override
                public String call() throws Exception {
                    String[] log = dataset.create(newDatasetProperties);
                    LogUI.addLogEntry(log[0]);
                    LogUI.addLogEntry(log[1]);
                    return "" ;
                }
            };
            waitingTask.setOnSucceeded((WorkerStateEvent event1) -> {
                newDatasetProperties.clear();
                availableDatasets.update();
                messagesFileButton.setText("Choose file...");
                networkFileButton.setText("Choose file...");
                newDatasetIdentifierField.clear();
                newDatasetDescriptionField.clear();
                AppParameters.disableUI(false);
        }); 
        ExecutorService executor = Executors.newSingleThreadExecutor();
        executor.submit(waitingTask);
    });
    buttonBox.getChildren().addAll(importButton);
    return buttonBox;
}
 
源代码10 项目: Intro-to-Java-Programming   文件: Exercise_20_09.java
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	MultipleBallPane ballPane = new MultipleBallPane();
	ballPane.setStyle("-fx-border-color: yellow");

	Button btAdd = new Button("+");
	Button btSubtract = new Button("-");
	HBox hBox = new HBox(10);
	hBox.getChildren().addAll(btAdd, btSubtract);
	hBox.setAlignment(Pos.CENTER);

	// Add or remove a ball
	btAdd.setOnAction(e -> ballPane.add());
	btSubtract.setOnAction(e -> ballPane.subtract());

	// Pause and resume animation
	ballPane.setOnMousePressed(e -> ballPane.pause());
	ballPane.setOnMouseReleased(e -> ballPane.play());

	// Use a scroll bar to control animation speed
	ScrollBar sbSpeed = new ScrollBar();
	sbSpeed.setMax(20);
	sbSpeed.setValue(10);
	ballPane.rateProperty().bind(sbSpeed.valueProperty());

	BorderPane pane = new BorderPane();
	pane.setCenter(ballPane);
	pane.setTop(sbSpeed);
	pane.setBottom(hBox);

	// Create a scene and place the in the stage
	Scene scene = new Scene(pane, 250, 150);
	primaryStage.setTitle("Exercise_20_09"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
@Override
public void start(Stage stage) {
    StylesConfig styles = mock(StylesConfig.class);
    LenientExecutionConfirmationDialog victim = new LenientExecutionConfirmationDialog(styles);
    Button button = new Button("show");
    button.setOnAction(a -> confirm = victim.response());
    Scene scene = new Scene(new VBox(button));
    stage.setScene(scene);
    stage.show();
}
 
源代码12 项目: marathonv5   文件: ACEEditor.java
private void createToolBars(ToolBarPanel toolBarPanel) {
    VLToolBar infoToolBar = new VLToolBar();
    infoButton = new MenuButton(null, FXUIUtils.getIcon("info"));
    infoButton.setDisable(true);
    infoToolBar.add(infoButton);
    toolBarPanel.add(infoToolBar);
    VLToolBar clipboardToolBar = new VLToolBar();
    cutButton = FXUIUtils.createButton("cut", "Remove selected text and copy to clipboard");
    cutButton.setOnAction((event) -> cut());
    clipboardToolBar.add(cutButton);
    copyButton = FXUIUtils.createButton("copy", "Copy selected text to clipboard");
    copyButton.setOnAction((event) -> copy());
    clipboardToolBar.add(copyButton);
    pasteButton = FXUIUtils.createButton("paste", "Paste text from clipboard");
    pasteButton.setOnAction((event) -> paste());
    clipboardToolBar.add(pasteButton);
    toolBarPanel.add(clipboardToolBar);
    VLToolBar redoToolBar = new VLToolBar();
    undoButton = FXUIUtils.createButton("undo", "Undo last action");
    undoButton.setOnAction((event) -> editorExecuteProc("undo"));
    redoToolBar.add(undoButton);
    redoButton = FXUIUtils.createButton("redo", "Redo last undone action");
    redoButton.setOnAction((event) -> editorExecuteProc("redo"));
    redoToolBar.add(redoButton);
    toolBarPanel.add(redoToolBar);
    VLToolBar searchToolBar = new VLToolBar();
    Button search = FXUIUtils.createButton("search", "Search for a pattern", true);
    search.setOnAction((event) -> editorExecuteProc("find"));
    searchToolBar.add(search);
    Button replace = FXUIUtils.createButton("replace", "Search for a pattern and replace", true);
    replace.setOnAction((event) -> editorExecuteProc("replace"));
    searchToolBar.add(replace);
    toolBarPanel.add(searchToolBar);
    VLToolBar settingsToolBar = new VLToolBar();
    Button settingsButton = FXUIUtils.createButton("settings", "Modify editor settings", true);
    settingsButton.setOnAction((event) -> onSettings());
    settingsToolBar.add(settingsButton);
    toolBarPanel.add(settingsToolBar);
}
 
源代码13 项目: java-ml-projects   文件: Clustering.java
@Override
public void start(Stage stage) throws Exception {
	loadData();
	tree = new J48();
	tree.buildClassifier(data);

	noClassificationChart = buildChart("No Classification (click to add new data)", buildSingleSeries());
	clusteredChart = buildChart("Clustered", buildClusteredSeries());
	realDataChart = buildChart("Real Data (+ Decision Tree classification for new data)", buildLabeledSeries());

	noClassificationChart.setOnMouseClicked(e -> {
		Axis<Number> xAxis = noClassificationChart.getXAxis();
		Axis<Number> yAxis = noClassificationChart.getYAxis();
		Point2D mouseSceneCoords = new Point2D(e.getSceneX(), e.getSceneY());
		double x = xAxis.sceneToLocal(mouseSceneCoords).getX();
		double y = yAxis.sceneToLocal(mouseSceneCoords).getY();
		Number xValue = xAxis.getValueForDisplay(x);
		Number yValue = yAxis.getValueForDisplay(y);
		reloadSeries(xValue, yValue);
	});

	Label lblDecisionTreeTitle = new Label("Decision Tree generated for the Iris dataset:");
	Text txtTree = new Text(tree.toString());
	String graph = tree.graph();
	SwingNode sw = new SwingNode();
	SwingUtilities.invokeLater(() -> {
		TreeVisualizer treeVisualizer = new TreeVisualizer(null, graph, new PlaceNode2());
		treeVisualizer.setPreferredSize(new Dimension(600, 500));
		sw.setContent(treeVisualizer);
	});

	Button btnRestore = new Button("Restore original data");
	Button btnSwapColors = new Button("Swap clustered chart colors");
	StackPane spTree = new StackPane(sw);
	spTree.setPrefWidth(300);
	spTree.setPrefHeight(350);
	VBox vbDecisionTree = new VBox(5, lblDecisionTreeTitle, new Separator(), spTree,
			new HBox(10, btnRestore, btnSwapColors));
	btnRestore.setOnAction(e -> {
		loadData();
		reloadSeries();
	});
	btnSwapColors.setOnAction(e -> swapClusteredChartSeriesColors());
	lblDecisionTreeTitle.setTextFill(Color.DARKRED);
	lblDecisionTreeTitle.setFont(Font.font(Font.getDefault().getFamily(), FontWeight.BOLD, FontPosture.ITALIC, 16));
	txtTree.setTranslateX(100);
	txtTree.setFont(Font.font(Font.getDefault().getFamily(), FontWeight.BOLD, FontPosture.ITALIC, 14));
	txtTree.setLineSpacing(1);
	txtTree.setTextAlignment(TextAlignment.LEFT);
	vbDecisionTree.setTranslateY(20);
	vbDecisionTree.setTranslateX(20);

	GridPane gpRoot = new GridPane();
	gpRoot.add(realDataChart, 0, 0);
	gpRoot.add(clusteredChart, 1, 0);
	gpRoot.add(noClassificationChart, 0, 1);
	gpRoot.add(vbDecisionTree, 1, 1);

	stage.setScene(new Scene(gpRoot));
	stage.setTitle("Íris dataset clustering and visualization");
	stage.show();
}
 
源代码14 项目: ns-usbloader   文件: DriversInstall.java
public DriversInstall(ResourceBundle rb){

        if (DriversInstall.isRunning)
            return;

        DriversInstall.isRunning = true;

        DownloadDriversTask downloadTask = new DownloadDriversTask();

        Button cancelButton = new Button(rb.getString("btn_Cancel"));

        HBox hBoxInformation = new HBox();
        hBoxInformation.setAlignment(Pos.TOP_LEFT);
        hBoxInformation.getChildren().add(new Label(rb.getString("windowBodyDownloadDrivers")));

        ProgressBar progressBar = new ProgressBar();
        progressBar.setPrefWidth(Double.MAX_VALUE);
        progressBar.progressProperty().bind(downloadTask.progressProperty());

        Label downloadStatusLabel = new Label();
        downloadStatusLabel.setWrapText(true);
        downloadStatusLabel.textProperty().bind(downloadTask.messageProperty());

        runInstallerStatusLabel = new Label();
        runInstallerStatusLabel.setWrapText(true);

        Pane fillerPane1 = new Pane();
        Pane fillerPane2 = new Pane();

        VBox parentVBox = new VBox();
        parentVBox.setAlignment(Pos.TOP_CENTER);
        parentVBox.setFillWidth(true);
        parentVBox.setSpacing(5.0);
        parentVBox.setPadding(new Insets(5.0));
        parentVBox.setFillWidth(true);
        parentVBox.getChildren().addAll(
                hBoxInformation,
                fillerPane1,
                downloadStatusLabel,
                runInstallerStatusLabel,
                fillerPane2,
                progressBar,
                cancelButton
        ); // TODO:FIX

        VBox.setVgrow(fillerPane1, Priority.ALWAYS);
        VBox.setVgrow(fillerPane2, Priority.ALWAYS);

        Stage stage = new Stage();

        stage.setTitle(rb.getString("windowTitleDownloadDrivers"));
        stage.getIcons().addAll(
                new Image("/res/dwnload_ico32x32.png"),    //TODO: REDRAW
                new Image("/res/dwnload_ico48x48.png"),
                new Image("/res/dwnload_ico64x64.png"),
                new Image("/res/dwnload_ico128x128.png")
        );
        stage.setMinWidth(400);
        stage.setMinHeight(150);

        Scene mainScene = new Scene(parentVBox, 405, 155);

        mainScene.getStylesheets().add(AppPreferences.getInstance().getTheme());

        stage.setOnHidden(windowEvent -> {
            downloadTask.cancel(true );
            DriversInstall.isRunning = false;
        });

        stage.setScene(mainScene);
        stage.show();
        stage.toFront();

        downloadTask.setOnSucceeded(event -> {
            cancelButton.setText(rb.getString("btn_Close"));

            String returnedValue = downloadTask.getValue();

            if (returnedValue == null)
                return;

            if (runInstaller(returnedValue))
                stage.close();
        });

        Thread downloadThread = new Thread(downloadTask);
        downloadThread.start();

        cancelButton.setOnAction(actionEvent -> {
            downloadTask.cancel(true );
            stage.close();
        });
    }
 
源代码15 项目: pdfsam   文件: AboutDashboardPane.java
@Inject
public AboutDashboardPane(Pdfsam pdfsam) {
    getStyleClass().add("dashboard-container");
    VBox left = new VBox(5);
    addSectionTitle(pdfsam.name(), left);
    Label copyright = new Label(pdfsam.property(COPYRIGHT));
    FontAwesomeIconFactory.get().setIcon(copyright, FontAwesomeIcon.COPYRIGHT);
    left.getChildren().addAll(new Label(String.format("ver. %s", pdfsam.property(VERSION))), copyright);
    addHyperlink(null, pdfsam.property(LICENSE_URL), pdfsam.property(LICENSE_NAME), left);
    addHyperlink(FontAwesomeIcon.HOME, pdfsam.property(HOME_URL), pdfsam.property(HOME_LABEL), left);
    addHyperlink(FontAwesomeIcon.RSS_SQUARE, pdfsam.property(FEED_URL),
            DefaultI18nContext.getInstance().i18n("Subscribe to the official news feed"), left);

    addSectionTitle(DefaultI18nContext.getInstance().i18n("Environment"), left);
    Label runtime = new Label(String.format("%s %s", System.getProperty("java.runtime.name"),
            System.getProperty("java.runtime.version")));
    Label vendor = new Label(
            String.format(DefaultI18nContext.getInstance().i18n("Vendor: %s"), System.getProperty("java.vendor")));
    Label runtimePath = new Label(String.format(DefaultI18nContext.getInstance().i18n("Java runtime path: %s"),
            System.getProperty("java.home")));
    Label fx = new Label(String.format(DefaultI18nContext.getInstance().i18n("JavaFX runtime version %s"),
            System.getProperty("javafx.runtime.version")));
    Label memory = new Label(DefaultI18nContext.getInstance().i18n("Max memory {0}",
            FileUtils.byteCountToDisplaySize(Runtime.getRuntime().maxMemory())));
    Button copyButton = new Button(DefaultI18nContext.getInstance().i18n("Copy to clipboard"));
    FontAwesomeIconFactory.get().setIcon(copyButton, FontAwesomeIcon.COPY);
    copyButton.getStyleClass().addAll(Style.BUTTON.css());
    copyButton.setId("copyEnvDetails");
    copyButton.setOnAction(a -> {
        ClipboardContent content = new ClipboardContent();
        writeContent(Arrays.asList(pdfsam.name(), pdfsam.property(VERSION), runtime.getText(), vendor.getText(),
                runtimePath.getText(), fx.getText(), memory.getText())).to(content);
        Clipboard.getSystemClipboard().setContent(content);
    });
    left.getChildren().addAll(runtime, vendor, runtimePath, fx, memory, copyButton);

    VBox right = new VBox(5);
    addSectionTitle(DefaultI18nContext.getInstance().i18n("Support"), right);
    addHyperlink(FontAwesomeIcon.BUG, pdfsam.property(TRACKER_URL),
            DefaultI18nContext.getInstance().i18n("Bug and feature requests"), right);
    addHyperlink(FontAwesomeIcon.QUESTION_CIRCLE, pdfsam.property(SUPPORT_URL),
            DefaultI18nContext.getInstance().i18n("Support"), right);
    addHyperlink(FontAwesomeIcon.BOOK, pdfsam.property(DOCUMENTATION_URL),
            DefaultI18nContext.getInstance().i18n("Documentation"), right);

    addSectionTitle(DefaultI18nContext.getInstance().i18n("Contribute"), right);
    addHyperlink(FontAwesomeIcon.GITHUB, pdfsam.property(SCM_URL),
            DefaultI18nContext.getInstance().i18n("Fork PDFsam on GitHub"), right);
    addHyperlink(FontAwesomeIcon.FLAG_ALT, pdfsam.property(TRANSLATE_URL),
            DefaultI18nContext.getInstance().i18n("Translate"), right);
    addHyperlink(FontAwesomeIcon.DOLLAR, pdfsam.property(DONATE_URL),
            DefaultI18nContext.getInstance().i18n("Donate"), right);

    addSectionTitle(DefaultI18nContext.getInstance().i18n("Social"), right);
    addHyperlink(FontAwesomeIcon.TWITTER_SQUARE, pdfsam.property(TWITTER_URL),
            DefaultI18nContext.getInstance().i18n("Follow us on Twitter"), right);
    addHyperlink(FontAwesomeIcon.FACEBOOK_SQUARE, pdfsam.property(FACEBOOK_URL),
            DefaultI18nContext.getInstance().i18n("Like us on Facebook"), right);
    getChildren().addAll(left, right);
}
 
源代码16 项目: Game2048FX   文件: About.java
public About() {
    
    HBox title = new HBox(10);
    title.setAlignment(Pos.CENTER_LEFT);
    title.getChildren().add(new ImageView());
    title.getChildren().add(new Label("About the App"));
    
    Dialog<ButtonType> dialog = new Dialog<>();
    
    Text t00 = new Text("2048");
    t00.getStyleClass().setAll("game-label","game-lblAbout");
    Text t01 = new Text("FX");
    t01.getStyleClass().setAll("game-label","game-lblAbout2");
    Text t02 = new Text(" Game\n");
    t02.getStyleClass().setAll("game-label","game-lblAbout");
    Text t1 = new Text("JavaFX game - " + Platform.getCurrent().name() + " version\n\n");
    t1.getStyleClass().setAll("game-label", "game-lblAboutSub");
    Text t20 = new Text("Powered by ");
    t20.getStyleClass().setAll("game-label", "game-lblAboutSub");
    Hyperlink link11 = new Hyperlink();
    link11.setText("JavaFXPorts");
    link11.setOnAction(e -> browse("http://gluonhq.com/open-source/javafxports/"));
    link11.getStyleClass().setAll("game-label", "game-lblAboutSub2");
    Text t210 = new Text(" & ");
    t210.getStyleClass().setAll("game-label", "game-lblAboutSub");
    Hyperlink link12 = new Hyperlink();
    link12.setText("Gluon Mobile");
    link12.setOnAction(e -> browse("https://gluonhq.com/products/mobile/"));
    link12.getStyleClass().setAll("game-label", "game-lblAboutSub2");
    Text t21 = new Text(" Projects \n\n");
    t21.getStyleClass().setAll("game-label", "game-lblAboutSub");
    Text t23 = new Text("\u00A9 ");
    t23.getStyleClass().setAll("game-label", "game-lblAboutSub");
    Hyperlink link2 = new Hyperlink();
    link2.setText("José Pereda");
    link2.setOnAction(e -> browse("https://twitter.com/JPeredaDnr"));
    link2.getStyleClass().setAll("game-label", "game-lblAboutSub2");
    Text t22 = new Text(", ");
    t22.getStyleClass().setAll("game-label", "game-lblAboutSub");
    Hyperlink link3 = new Hyperlink();
    link3.setText("Bruno Borges");
    link3.setOnAction(e -> browse("https://twitter.com/brunoborges"));
    Text t32 = new Text(" & ");
    t32.getStyleClass().setAll("game-label", "game-lblAboutSub");
    link3.getStyleClass().setAll("game-label", "game-lblAboutSub2");
    Hyperlink link4 = new Hyperlink();
    link4.setText("Jens Deters");
    link4.setOnAction(e -> browse("https://twitter.com/Jerady"));
    link4.getStyleClass().setAll("game-label", "game-lblAboutSub2");
    Text t24 = new Text("\n\n");
    t24.getStyleClass().setAll("game-label", "game-lblAboutSub");

    Text t31 = new Text(" Version " + Game2048.VERSION + " - " + Year.now().toString() + "\n\n");
    t31.getStyleClass().setAll("game-label", "game-lblAboutSub");

    TextFlow flow = new TextFlow();
    flow.setTextAlignment(TextAlignment.CENTER);
    flow.setPadding(new Insets(10,0,0,0));

    flow.getChildren().setAll(t00, t01, t02, t1, t20, link11, t210, link12, t21, t23, link2, t22, link3);
    flow.getChildren().addAll(t32, link4);
    flow.getChildren().addAll(t24, t31);
    
    final ImageView imageView = new ImageView();
    imageView.getStyleClass().add("about");
    
    double scale = Services.get(DisplayService.class)
            .map(display -> {
                if (display.isTablet()) {
                    flow.setTranslateY(30);
                    return 1.3;
                } else {
                    flow.setTranslateY(25);
                    return 1.0;
                }
            })
            .orElse(1.0);
    
    imageView.setFitWidth(270 * scale);
    imageView.setFitHeight(270 * scale);
    imageView.setOpacity(0.1);
    
    dialog.setContent(new StackPane(imageView, flow));
    dialog.setTitle(title);
    
    Button yes = new Button("Accept");
    yes.setOnAction(e -> {
        dialog.setResult(ButtonType.YES); 
        dialog.hide();
    });
    yes.setDefaultButton(true);
    dialog.getButtons().addAll(yes);
    javafx.application.Platform.runLater(dialog::showAndWait);
}
 
源代码17 项目: bisq   文件: SendAlertMessageWindow.java
private void addContent() {
    gridPane.getColumnConstraints().get(0).setHalignment(HPos.LEFT);
    gridPane.getColumnConstraints().remove(1);

    InputTextField keyInputTextField = addInputTextField(gridPane, ++rowIndex,
            Res.get("shared.unlock"), 10);
    if (useDevPrivilegeKeys)
        keyInputTextField.setText(DevEnv.DEV_PRIVILEGE_PRIV_KEY);

    Tuple2<Label, TextArea> labelTextAreaTuple2 = addTopLabelTextArea(gridPane, ++rowIndex,
            Res.get("sendAlertMessageWindow.alertMsg"),
            Res.get("sendAlertMessageWindow.enterMsg"));
    TextArea alertMessageTextArea = labelTextAreaTuple2.second;
    Label first = labelTextAreaTuple2.first;
    first.setMinWidth(150);
    CheckBox isUpdateCheckBox = addLabelCheckBox(gridPane, ++rowIndex,
            Res.get("sendAlertMessageWindow.isUpdate"));
    isUpdateCheckBox.setSelected(true);

    InputTextField versionInputTextField = FormBuilder.addInputTextField(gridPane, ++rowIndex,
            Res.get("sendAlertMessageWindow.version"));
    versionInputTextField.disableProperty().bind(isUpdateCheckBox.selectedProperty().not());

    Button sendButton = new AutoTooltipButton(Res.get("sendAlertMessageWindow.send"));
    sendButton.getStyleClass().add("action-button");
    sendButton.setDefaultButton(true);
    sendButton.setOnAction(e -> {
        final String version = versionInputTextField.getText();
        boolean versionOK = false;
        final boolean isUpdate = isUpdateCheckBox.isSelected();
        if (isUpdate) {
            final String[] split = version.split("\\.");
            versionOK = split.length == 3;
            if (!versionOK) // Do not translate as only used by devs
                new Popup().warning("Version number must be in semantic version format (contain 2 '.'). version=" + version)
                        .onClose(this::blurAgain)
                        .show();
        }
        if (!isUpdate || versionOK) {
            if (alertMessageTextArea.getText().length() > 0 && keyInputTextField.getText().length() > 0) {
                if (alertManager.addAlertMessageIfKeyIsValid(
                        new Alert(alertMessageTextArea.getText(), isUpdate, version),
                        keyInputTextField.getText())
                )
                    hide();
                else
                    new Popup().warning(Res.get("shared.invalidKey")).width(300).onClose(this::blurAgain).show();
            }
        }
    });

    Button removeAlertMessageButton = new AutoTooltipButton(Res.get("sendAlertMessageWindow.remove"));
    removeAlertMessageButton.setOnAction(e -> {
        if (keyInputTextField.getText().length() > 0) {
            if (alertManager.removeAlertMessageIfKeyIsValid(keyInputTextField.getText()))
                hide();
            else
                new Popup().warning(Res.get("shared.invalidKey")).width(300).onClose(this::blurAgain).show();
        }
    });

    closeButton = new AutoTooltipButton(Res.get("shared.close"));
    closeButton.setOnAction(e -> {
        hide();
        closeHandlerOptional.ifPresent(Runnable::run);
    });

    HBox hBox = new HBox();
    hBox.setSpacing(10);
    GridPane.setRowIndex(hBox, ++rowIndex);
    hBox.getChildren().addAll(sendButton, removeAlertMessageButton, closeButton);
    gridPane.getChildren().add(hBox);
    GridPane.setMargin(hBox, new Insets(10, 0, 0, 0));
}
 
源代码18 项目: marathonv5   文件: LoginApplication.java
@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 150);
    stage.setScene(scene);
    stage.setTitle("Text Field Sample");

    GridPane grid = new GridPane();
    grid.setPadding(new Insets(10, 10, 10, 10));
    grid.setVgap(5);
    grid.setHgap(5);

    scene.setRoot(grid);

    final TextField name = new TextField();
    name.setPromptText("User Name:");
    HBox.setHgrow(name, Priority.ALWAYS);
    GridPane.setConstraints(name, 0, 0);
    grid.getChildren().add(name);

    final TextField lastName = new TextField();
    lastName.setPromptText("Password:");
    HBox.setHgrow(lastName, Priority.ALWAYS);
    GridPane.setConstraints(lastName, 0, 1);
    grid.getChildren().add(lastName);

    Button submit = new Button("Submit");
    GridPane.setConstraints(submit, 0, 2);
    grid.getChildren().add(submit);

    submit.setOnAction((ActionEvent e) -> {
        ProcessBuilder pb = new ProcessBuilder("java", "-cp", System.getProperty("java.class.path"),
                ButtonSample.class.getName());
        try {
            if (System.getenv("USER_JTO") != null) {
                pb.environment().put("JAVA_TOOL_OPTIONS", System.getenv("USER_JTO"));
            }
            Process process = pb.start();
            System.exit(0);
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    });

    stage.show();
}
 
源代码19 项目: phoebus   文件: ToolbarHandler.java
private void addZoom(final boolean active)
{
    final Button stagger = newButton(ToolIcons.STAGGER, Messages.Zoom_Stagger_TT);
    if (active)
        stagger.setOnAction(event -> plot.stagger(true));
}
 
源代码20 项目: FXMaps   文件: RefImplToolBar.java
/**
 * Creates and returns the control for loading maps
 * @return  the control for loading stored maps
 */
public GridPane getMapControl() {
    GridPane gp = new GridPane();
    gp.setPadding(new Insets(5, 5, 5, 5));
    gp.setHgap(5);
    gp.setVgap(5);
    
    Button gpxLoader = getGPXLoadControl();
    gpxLoader.setPrefHeight(15);
    
    Label l = new Label("Select or enter map name:");
    l.setFont(Font.font(l.getFont().getFamily(), 12));
    l.setTextFill(Color.WHITE);
    
    Button add = new Button("Add");
    add.disableProperty().set(true);
    add.setOnAction(e -> mapCombo.valueProperty().set(mapCombo.getEditor().getText()));
    
    Button clr = new Button("Erase map");
    clr.disableProperty().set(true);
    clr.setOnAction(e -> map.eraseMap());
    
    Button del = new Button("Delete map");
    del.disableProperty().set(true);
    del.setOnAction(e -> {
        map.clearMap();
        map.deleteMap(mapCombo.getEditor().getText());
        mapCombo.getItems().remove(mapCombo.getEditor().getText());
        mapCombo.getSelectionModel().clearSelection();
        mapCombo.getEditor().clear();
        map.setMode(Mode.NORMAL);
        mapChooser.fire();
        map.setOverlayVisible(true);
        routeChooser.setDisable(true);
    });
    
    mapCombo.getEditor().textProperty().addListener((v, o, n) -> {
        if(mapCombo.getEditor().getText() != null && mapCombo.getEditor().getText().length() > 0) {
            add.disableProperty().set(false);
            if(map.getMapStore().getMap(mapCombo.getEditor().getText()) != null) {
                clr.disableProperty().set(false);
                del.disableProperty().set(false);
            }else{
                clr.disableProperty().set(true);
                del.disableProperty().set(true);
            }
        }else{
            add.disableProperty().set(true);
            clr.disableProperty().set(true);
            del.disableProperty().set(true);
        }
    });
    
    gp.add(gpxLoader, 0, 0, 2, 1);
    gp.add(new Separator(), 0, 1, 2, 1);
    gp.add(l, 0, 2, 2, 1);
    gp.add(mapCombo, 0, 3, 3, 1);
    gp.add(add, 3, 3);
    gp.add(clr, 4, 3);
    gp.add(del, 5, 3);
    
    return gp;
}