Java Code Examples for javafx.scene.control.Button

The following examples show how to use javafx.scene.control.Button. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: bisq   Author: bisq-network   File: AwesomeFontDemo.java    License: GNU Affero General Public License v3.0 8 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    FlowPane flowPane = new FlowPane();
    flowPane.setStyle("-fx-background-color: #ddd;");
    flowPane.setHgap(2);
    flowPane.setVgap(2);
    List<AwesomeIcon> values = new ArrayList<>(Arrays.asList(AwesomeIcon.values()));
    values.sort((o1, o2) -> o1.name().compareTo(o2.name()));
    for (AwesomeIcon icon : values) {
        Label label = new Label();
        Button button = new Button(icon.name(), label);
        button.setStyle("-fx-background-color: #fff;");
        AwesomeDude.setIcon(label, icon, "12");
        flowPane.getChildren().add(button);
    }

    primaryStage.setScene(new Scene(flowPane, 1200, 950));
    primaryStage.show();
}
 
Example #2
Source Project: marathonv5   Author: jalian-systems   File: RFXButtonBaseTest.java    License: Apache License 2.0 7 votes vote down vote up
@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]);
}
 
Example #3
Source Project: fxldemo-gradle   Author: edvin   File: FxlDemo.java    License: Apache License 2.0 7 votes vote down vote up
public void start(Stage stage) throws Exception {
    stage.setTitle("Hello World");
    stage.initStyle(StageStyle.UNDECORATED);

    Label label = new Label(stage.getTitle());
    label.setStyle("-fx-font-size: 25");

    // Alibi for including ControlsFX Dependency :)
    SegmentedButton fxcontrol = new SegmentedButton(new ToggleButton("One"), new ToggleButton("Two"), new ToggleButton("Three"));

    Button exitButton = new Button("Exit");
    exitButton.setStyle("-fx-font-weight: bold");
    exitButton.setOnAction(event -> Platform.exit());

    VBox root = new VBox(label, fxcontrol, exitButton);
    root.setAlignment(Pos.CENTER);
    root.setSpacing(20);
    root.setPadding(new Insets(25));
    root.setStyle("-fx-border-color: lightblue");

    stage.setScene(new Scene(root));
    stage.show();
}
 
Example #4
Source Project: metastone   Author: demilich1   File: MetaDeckView.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void displayDecks(List<Deck> decks) {
	contentPane.getChildren().clear();
	for (Deck deck : decks) {
		if (deck.isMetaDeck()) {
			continue;
		}
		ImageView graphic = new ImageView(IconFactory.getClassIcon(deck.getHeroClass()));
		graphic.setFitWidth(48);
		graphic.setFitHeight(48);
		Button deckButton = new Button(deck.getName(), graphic);
		deckButton.setMaxWidth(160);
		deckButton.setMinWidth(160);
		deckButton.setMaxHeight(120);
		deckButton.setMinHeight(120);
		deckButton.setWrapText(true);
		deckButton.setContentDisplay(ContentDisplay.LEFT);
		deckButton.setOnAction(event -> NotificationProxy.sendNotification(GameNotification.ADD_DECK_TO_META_DECK, deck));
		deckButton.setUserData(deck);
		contentPane.getChildren().add(deckButton);
	}
}
 
Example #5
Source Project: WorkbenchFX   Author: dlsc-software-consulting-gmbh   File: DialogControlTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
void getButton() {
  // when asking for a button type
  Optional<Button> button = dialogControl.getButton(BUTTON_TYPE_1);

  // returns its button in an Optional
  assertNotEquals(Optional.empty(), button);
  assertEquals(dialogControl.getButtons().get(0), button.get());

  // if the buttonType doesn't exist
  button = dialogControl.getButton(ButtonType.CANCEL);

  // return empty optional
  assertEquals(Optional.empty(), button);

  // if there are no buttonTypes
  buttonTypes.clear();
  button = dialogControl.getButton(BUTTON_TYPE_1);

  // return empty optional
  assertEquals(Optional.empty(), button);
}
 
Example #6
Source Project: gluon-samples   Author: gluonhq   File: NoteCell.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public NoteCell(Service service, Consumer<Note> edit, Consumer<Note> remove) {
    
    tile = new ListTile();
    tile.setPrimaryGraphic(MaterialDesignIcon.DESCRIPTION.graphic());
    
    Button btnEdit = MaterialDesignIcon.EDIT.button(e -> edit.accept(currentItem));
    Button btnRemove = MaterialDesignIcon.DELETE.button(e -> remove.accept(currentItem));
    HBox buttonBar = new HBox(0, btnEdit, btnRemove);
    buttonBar.setAlignment(Pos.CENTER_RIGHT);

    tile.setSecondaryGraphic(buttonBar);
    
    dateFormat = DateTimeFormatter.ofPattern("EEE, MMM dd yyyy - HH:mm", Locale.ENGLISH);
    
    noteChangeListener = (obs, ov, nv) -> update();
    
    service.settingsProperty().addListener((obs, ov, nv) -> {
        settings = nv;
        update();
    });
    settings = service.settingsProperty().get();
    update();
}
 
Example #7
Source Project: mapper-generator-javafx   Author: alansun2   File: ConfigController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 删除配置
 *
 * @param generatorConfig 配置信息
 */
private void deleteConfig(Button button, GeneratorConfig generatorConfig) {
    ObservableList<Node> children = centerVBox.getChildren();
    int size = children.size();
    if (size == 1) {
        exportController.clearPane();
    } else {
        int i = children.indexOf(button);
        if (i == 0) {
            exportController.showConfig(configNameConfigMap.get(((Button) children.get(1)).getText()));
        } else {
            exportController.showConfig(configNameConfigMap.get(((Button) children.get(0)).getText()));
        }
    }
    children.remove(button);
    configService.deleteConfig(generatorConfig);
}
 
Example #8
Source Project: Notebook   Author: coding-dream   File: DeployFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void initData(Parent node, Map<String, String> bundle) {
	btn_deploy = (Button) node.lookup("#btn_deploy");
	progressbar = (ProgressIndicator) node.lookup("#progressbar");

	btn_deploy.setOnAction(e->{
		progressbar.isIndeterminate();// һ ��������ʾ�����ڷ�ȷ��ģʽ,����progressbar����һ����ֵ�и�Сbug������¡�
		progressbar.setVisible(true);
		progressbar.setProgress(-1f);
		progressbar.setProgress(0.5f);
		progressbar.setProgress(-1f);
		btn_deploy.setDisable(true);// �����ظ����

		AnnotationHandler.sendMessage("work",null);
	});

	AnnotationHandler.register(this);

}
 
Example #9
Source Project: bisq   Author: bisq-network   File: FormBuilder.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
public static <T> Tuple3<Label, ComboBox<T>, Button> addLabelComboBoxButton(GridPane gridPane,
                                                                            int rowIndex,
                                                                            String title,
                                                                            String buttonTitle,
                                                                            double top) {
    Label label = addLabel(gridPane, rowIndex, title, top);

    HBox hBox = new HBox();
    hBox.setSpacing(10);

    Button button = new AutoTooltipButton(buttonTitle);
    button.setDefaultButton(true);

    ComboBox<T> comboBox = new JFXComboBox<>();

    hBox.getChildren().addAll(comboBox, button);

    GridPane.setRowIndex(hBox, rowIndex);
    GridPane.setColumnIndex(hBox, 1);
    GridPane.setMargin(hBox, new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(hBox);

    return new Tuple3<>(label, comboBox, button);
}
 
Example #10
Source Project: pcgen   Author: PCGen   File: KitSelectionDialog.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
private void initComponents()
{
	Container pane = getContentPane();
	pane.setLayout(new BorderLayout());

	pane.add(kitPanel, BorderLayout.CENTER);

	Button closeButton = new Button(LanguageBundle.getString("in_close"));
	closeButton.setOnAction(this::onClose);

	Box buttons = Box.createHorizontalBox();
	buttons.add(GuiUtility.wrapParentAsJFXPanel(closeButton));
	pane.add(buttons, BorderLayout.PAGE_END);

	Utility.installEscapeCloseOperation(this);
}
 
Example #11
Source Project: examples-javafx-repos1   Author: bekwam   File: GetDataDialog.java    License: Apache License 2.0 6 votes vote down vote up
public void init() {
    vbox = new VBox();
    vbox.setSpacing(20.0d);
    vbox.setPadding(new Insets(10.0d));

    TextField tf = new TextField();

    Button btn = new Button("Submit");
    btn.setOnAction( (evt) -> {
        data = tf.getText();
        ((Button)evt.getSource()).getScene().getWindow().hide();
    } );

    vbox.getChildren().add(new Label("Enter Data"));
    vbox.getChildren().add(tf);
    vbox.getChildren().add(btn);
}
 
Example #12
Source Project: archivo   Author: fflewddur   File: Archivo.java    License: GNU General Public License v3.0 5 votes vote down vote up
public boolean showErrorMessageWithAction(String header, String message, String action,
                                          EventHandler<ActionEvent> eventHandler) {
    Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.setTitle("Something went wrong...");
    alert.setHeaderText(header);

    VBox contentPane = new VBox();
    HyperlinkLabel contentText = new HyperlinkLabel(message);
    contentText.setPrefWidth(500);
    contentPane.setPadding(new Insets(30, 15, 20, 15));
    contentPane.getChildren().add(contentText);
    alert.getDialogPane().setContent(contentPane);

    if (eventHandler != null) {
        contentText.setOnAction(eventHandler);
        contentText.addEventHandler(ActionEvent.ACTION, (event) -> alert.close());
    }

    ButtonType closeButtonType = new ButtonType("Close", ButtonBar.ButtonData.CANCEL_CLOSE);
    ButtonType actionButtonType = new ButtonType(action, ButtonBar.ButtonData.YES);
    ButtonType reportButtonType = new ButtonType("Report Problem", ButtonBar.ButtonData.HELP_2);
    alert.getButtonTypes().setAll(closeButtonType, reportButtonType);
    if (action != null) {
        alert.getButtonTypes().add(actionButtonType);
        ((Button) alert.getDialogPane().lookupButton(closeButtonType)).setDefaultButton(false);
        ((Button) alert.getDialogPane().lookupButton(reportButtonType)).setDefaultButton(false);
        ((Button) alert.getDialogPane().lookupButton(actionButtonType)).setDefaultButton(true);
    }

    Optional<ButtonType> result = alert.showAndWait();
    while (result.isPresent() && result.get() == reportButtonType) {
        rootController.reportProblem(null);
        result = alert.showAndWait();
    }
    return (result.isPresent() && result.get() == actionButtonType);
}
 
Example #13
Source Project: marathonv5   Author: jalian-systems   File: SimpleWebServer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("Simple Web Server");
    BorderPane root = new BorderPane();
    TextArea area = new TextArea();
    root.setCenter(area);
    ToolBar bar = new ToolBar();
    Button openInBrowser = FXUIUtils.createButton("open-in-browser", "Open in External Browser", true);
    openInBrowser.setOnAction((event) -> {
        try {
            Desktop.getDesktop().browse(URI.create(webRoot));
        } catch (IOException e) {
            e.printStackTrace();
        }
    });
    Button changeRoot = FXUIUtils.createButton("fldr_closed", "Change Web Root", true);
    changeRoot.setOnAction((event) -> {
        DirectoryChooser chooser = new DirectoryChooser();
        File showDialog = chooser.showDialog(primaryStage);
        if (showDialog != null)
            server.setRoot(showDialog);
    });
    bar.getItems().add(openInBrowser);
    bar.getItems().add(changeRoot);
    root.setTop(bar);
    System.setOut(new PrintStream(new Console(area)));
    System.setErr(new PrintStream(new Console(area)));
    area.setEditable(false);
    primaryStage.setScene(new Scene(root));
    primaryStage.setOnShown((e) -> startServer(getParameters().getRaw()));
    primaryStage.show();
}
 
Example #14
Source Project: pdfsam   Author: torakiki   File: OverwriteConfirmationDialogTest.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void start(Stage stage) {
    StylesConfig styles = mock(StylesConfig.class);
    OverwriteConfirmationDialog victim = new OverwriteConfirmationDialog(styles);
    Button button = new Button("show");
    button.setOnAction(a -> overwrite = victim.title("Title").messageTitle("MessageTitle")
            .messageContent("MessageContent").response());
    Scene scene = new Scene(new VBox(button));
    stage.setScene(scene);
    stage.show();
}
 
Example #15
Source Project: SONDY   Author: AdrienGuille   File: DataCollectionUI.java    License: GNU General Public License v3.0 5 votes vote down vote up
final public void collectDataUI(){
    GridPane gridLEFT = new GridPane();
    Label queryLabel = new Label("Query");
    UIUtils.setSize(queryLabel,Main.columnWidthLEFT/2, 24);
    TextField queryField = new TextField();
    queryField.setPromptText("formatted query");
    UIUtils.setSize(queryField,Main.columnWidthLEFT/2, 24);
    Label durationLabel = new Label("Duration");
    UIUtils.setSize(durationLabel,Main.columnWidthLEFT/2, 24);
    TextField durationField = new TextField();
    durationField.setPromptText("duration in days (e.g. 2)");
    UIUtils.setSize(durationField,Main.columnWidthLEFT/2, 24);
    Label datasetIDLabel = new Label("Dataset ID");
    UIUtils.setSize(datasetIDLabel,Main.columnWidthLEFT/2, 24);
    TextField datasetIDField = new TextField();
    datasetIDField.setPromptText("unique identifier");
    UIUtils.setSize(datasetIDField,Main.columnWidthLEFT/2, 24);
    
    gridLEFT.add(queryLabel,0,0);
    gridLEFT.add(queryField,1,0);
    gridLEFT.add(new Rectangle(0,3),0,1);
    gridLEFT.add(durationLabel,0,2);
    gridLEFT.add(durationField,1,2);
    gridLEFT.add(new Rectangle(0,3),0,3);
    gridLEFT.add(datasetIDLabel,0,4);
    gridLEFT.add(datasetIDField,1,4);
    
    Button button = new Button("Collect");
    UIUtils.setSize(button,Main.columnWidthRIGHT, 24);
    button.setAlignment(Pos.CENTER);
    VBox buttonBox = new VBox();
    buttonBox.setAlignment(Pos.CENTER);
    buttonBox.getChildren().add(button);
    
    HBox collectDataBOTH = new HBox(5);
    collectDataBOTH.getChildren().addAll(gridLEFT,buttonBox);
    grid.add(collectDataBOTH,0,8);
}
 
Example #16
Source Project: Game2048FX   Author: jperedadnr   File: SettingsPresenter.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void showAlertDialog(GameMode mode) {
    HBox title = new HBox(10);
    title.setAlignment(Pos.CENTER_LEFT);
    title.getChildren().add(new ImageView());
    title.getChildren().add(new Label("Game will be restarted"));
    Dialog<ButtonType> dialog = new Dialog();
    dialog.setContent(new Label("The game will be restarted and non saved data will be lost. \nDo you want to continue?"));
    dialog.setTitle(title);
    Button yes = new Button("Yes");
    yes.setOnAction(e -> {
        dialog.setResult(ButtonType.YES);
        dialog.hide();
    });
    yes.setDefaultButton(true);
    Button no = new Button("No");
    no.setCancelButton(true);
    no.setOnAction(e -> {
        dialog.setResult(ButtonType.NO);
        dialog.hide();
    });
    dialog.getButtons().addAll(yes, no);
    Platform.runLater(() -> {
        Optional result = dialog.showAndWait();
        if (result.isPresent() && result.get().equals(ButtonType.YES)) {
            gameModel.setGameMode(mode);
        } else {
            gameMode.set(gameModel.getGameMode());
        }
        getApp().switchToPreviousView();
    });
}
 
Example #17
Source Project: jmonkeybuilder   Author: JavaSaBr   File: AssetBarComponent.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Instantiates a new Asset bar component.
 */
public AssetBarComponent() {

    final Button refreshAction = new Button();
    refreshAction.setGraphic(new ImageView(Icons.REFRESH_18));
    refreshAction.setOnAction(event -> FX_EVENT_MANAGER.notify(new RequestedRefreshAssetEvent()));

    FXUtils.addToPane(refreshAction, this);
}
 
Example #18
Source Project: PreferencesFX   Author: dlsc-software-consulting-gmbh   File: PreferencesFxDialog.java    License: Apache License 2.0 5 votes vote down vote up
private void unbindVisibility(Button closeBtn, Button cancelBtn) {
  // make sure if visibleProperty was bound in a previous call to unbind it first
  if (closeBtn != null) {
    closeBtn.visibleProperty().unbind();
  }
  if (cancelBtn != null) {
    cancelBtn.visibleProperty().unbind();
  }
}
 
Example #19
Source Project: marathonv5   Author: jalian-systems   File: AbstractSimpleAction.java    License: Apache License 2.0 5 votes vote down vote up
public Button getButtonWithText() {
    String cmd = commandName;
    if (cmd == null) {
        cmd = expand(name);
    }
    Button button = FXUIUtils.createButton(name, description, true, cmd);
    button.setOnAction(this);
    buttons.add(button);
    return button;
}
 
Example #20
Source Project: constellation   Author: constellation-app   File: PluginParametersDialog.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Display a dialog box containing the parameters that allows the user to
 * enter values.
 *
 * @param owner The owner for this stage.
 * @param title The dialog box title.
 * @param parameters The plugin parameters.
 * @param options The dialog box button labels, one for each button.
 */
public PluginParametersDialog(final Stage owner, final String title, final PluginParameters parameters, final String... options) {
    initStyle(StageStyle.UTILITY);
    initModality(Modality.WINDOW_MODAL);
    initOwner(owner);

    setTitle(title);

    final BorderPane root = new BorderPane();
    root.setPadding(new Insets(10));
    root.setStyle("-fx-background-color: #DDDDDD;");
    final Scene scene = new Scene(root);
    setScene(scene);

    final PluginParametersPane parametersPane = PluginParametersPane.buildPane(parameters, null);
    root.setCenter(parametersPane);

    final FlowPane buttonPane = new FlowPane();
    buttonPane.setAlignment(Pos.BOTTOM_RIGHT);
    buttonPane.setPadding(new Insets(5));
    buttonPane.setHgap(5);
    root.setBottom(buttonPane);

    final String[] labels = options != null && options.length > 0 ? options : new String[]{OK, CANCEL};
    for (final String option : labels) {
        final Button okButton = new Button(option);
        okButton.setOnAction(event -> {
            result = option;
            parameters.storeRecentValues();
            PluginParametersDialog.this.hide();
        });
        buttonPane.getChildren().add(okButton);
    }

    // Without this, some parameter panes have a large blank area at the bottom. Huh?
    this.sizeToScene();

    result = null;
}
 
Example #21
Source Project: examples-javafx-repos1   Author: bekwam   File: HelpDialogController.java    License: Apache License 2.0 5 votes vote down vote up
@FXML
public void close(ActionEvent evt) {

    //
    // For some reason, this.getScene() which is on the fx:root returns null
    //

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
Example #22
Source Project: marathonv5   Author: jalian-systems   File: ColorButtonSample.java    License: Apache License 2.0 5 votes vote down vote up
public ColorButtonSample() {
    HBox hBox = new HBox();
    hBox.setSpacing(5);
    for(int i=0; i<7; i++) {
        Button b = new Button("Color");
        b.setStyle("-fx-base: rgb("+(10*i)+","+(20*i)+","+(10*i)+");");
        hBox.getChildren().add(b);
    }
    HBox hBox2 = new HBox();
    hBox2.setSpacing(5);
    hBox2.setTranslateY(30);
    Button red = new Button("Red");
    red.setStyle("-fx-base: red;");
    Button orange = new Button("Orange");
    orange.setStyle("-fx-base: orange;");
    Button yellow = new Button("Yellow");
    yellow.setStyle("-fx-base: yellow;");
    Button green = new Button("Green");
    green.setStyle("-fx-base: green;");
    Button blue = new Button("Blue");
    blue.setStyle("-fx-base: rgb(30,170,255);");
    Button indigo = new Button("Indigo");
    indigo.setStyle("-fx-base: blue;");
    Button violet = new Button("Violet");
    violet.setStyle("-fx-base: purple;");
    hBox2.getChildren().add(red);
    hBox2.getChildren().add(orange);
    hBox2.getChildren().add(yellow);
    hBox2.getChildren().add(green);
    hBox2.getChildren().add(blue);
    hBox2.getChildren().add(indigo);
    hBox2.getChildren().add(violet);

    VBox vBox = new VBox(20);
    vBox.getChildren().addAll(hBox,hBox2);
    getChildren().add(vBox);
}
 
Example #23
Source Project: SmartModInserter   Author: narrowtux   File: SettingsWindowController.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
private void updateButton(Button button, Path path) {
    if (path != null) {
        button.setText(".../" + path.getFileName().toString());
    } else {
        button.setText("...");
    }
    closeButton.setDisable(Datastore.getInstance().getDataDir() == null || Datastore.getInstance().getFactorioApplication() == null);
}
 
Example #24
Source Project: pmd-designer   Author: pmd   File: PropertyCollectionView.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
public PropertyCollectionView(@NamedArg("designerRoot") DesignerRoot root) {
    this.root = root;

    this.getStyleClass().addAll("property-collection-view");

    view = new ListView<>();
    initListView(view);
    setOwnerStageFactory(root.getMainStage()); // default

    AnchorPane footer = new AnchorPane();
    footer.setPrefHeight(30);
    footer.getStyleClass().addAll("footer");
    footer.getStylesheets().addAll(DesignerUtil.getCss("flat").toString());


    Button addProperty = new Button("Add property");

    ControlUtil.anchorFirmly(addProperty);

    addProperty.setOnAction(e -> {
        addNewProperty(getUniqueNewName());
        view.requestFocus();
    });
    footer.getChildren().addAll(addProperty);
    this.getChildren().addAll(view, footer);

    myEditPopover = new PopOverWrapper<>(this::rebindPopover);

    myEditPopover.rebind(new PropertyDescriptorSpec());
    myEditPopover.doFirstLoad(root.getMainStage());

}
 
Example #25
Source Project: pmd-designer   Author: pmd   File: PropertyCollectionView.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void fireEditLast() {
    view.getSelectionModel().select(view.getItems().size() - 1);
    view.lookupAll(".list-cell").stream()
        .map(it -> (PropertyDescriptorCell) it)
        .max(Comparator.comparingInt(PropertyDescriptorCell::getIndex))
        .map(it -> (Button) it.lookup("." + PropertyDescriptorCell.DETAILS_BUTTON_CLASS))
        .ifPresent(Button::fire);
}
 
Example #26
Source Project: marathonv5   Author: jalian-systems   File: WebViewSample.java    License: Apache License 2.0 5 votes vote down vote up
public WebViewSample() {
    WebView webView = new WebView();
    
    final WebEngine webEngine = webView.getEngine();
    webEngine.load(DEFAULT_URL);
    
    final TextField locationField = new TextField(DEFAULT_URL);
    webEngine.locationProperty().addListener(new ChangeListener<String>() {
        @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            locationField.setText(newValue);
        }
    });
    EventHandler<ActionEvent> goAction = new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent event) {
            webEngine.load(locationField.getText().startsWith("http://") 
                    ? locationField.getText() 
                    : "http://" + locationField.getText());
        }
    };
    locationField.setOnAction(goAction);
    
    Button goButton = new Button("Go");
    goButton.setDefaultButton(true);
    goButton.setOnAction(goAction);
    
    // Layout logic
    HBox hBox = new HBox(5);
    hBox.getChildren().setAll(locationField, goButton);
    HBox.setHgrow(locationField, Priority.ALWAYS);
    
    VBox vBox = new VBox(5);
    vBox.getChildren().setAll(hBox, webView);
    VBox.setVgrow(webView, Priority.ALWAYS);

    getChildren().add(vBox);
}
 
Example #27
Source Project: phoenicis   Author: PhoenicisOrg   File: ApplicationInformationPanelSkin.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Refreshes the shown scripts.
 * When this method is called it begins by clearing the <code>scriptGrid</code>.
 * Afterwards this method refills it.
 */
private void updateScripts(final GridPane scriptGrid) {
    scriptGrid.getChildren().clear();

    for (int i = 0; i < filteredScripts.size(); i++) {
        ScriptDTO script = filteredScripts.get(i);

        final Label scriptName = new Label(script.getScriptName());
        GridPane.setHgrow(scriptName, Priority.ALWAYS);

        if (getControl().isShowScriptSource()) {
            final Tooltip tooltip = new Tooltip(tr("Source: {0}", script.getScriptSource()));
            Tooltip.install(scriptName, tooltip);
        }

        final Button installButton = new Button(tr("Install"));
        installButton.setOnMouseClicked(evt -> {
            try {
                installScript(script);
            } catch (IllegalArgumentException e) {
                final ErrorDialog errorDialog = ErrorDialog.builder()
                        .withMessage(tr("Error while trying to download the installer"))
                        .withException(e)
                        .build();

                errorDialog.showAndWait();
            }
        });

        scriptGrid.addRow(i, scriptName, installButton);
    }
}
 
Example #28
Source Project: mzmine3   Author: mzmine   File: PeriodicTableDialogController.java    License: GNU General Public License v2.0 5 votes vote down vote up
@FXML
public void handleMouseEnter(MouseEvent event) {
  Node source = (Node) event.getSource();
  Button b = (Button) source;
  Elements element = Elements.ofString(b.getText());
  elementSymbol = element.symbol();
  String result = element.name();
  b.setTooltip(new Tooltip(result));
  textLabelup.setText(result + " (" + elementSymbol + ")");
  textLabelup.setFont(new Font(30));
  textLabelbottom.setText("Atomic number" + " " + element.number()
      + (", " + "Group" + " " + element.group()) + ", " + "Period" + " " + element.period()
      + "\n\n\n" + "CAS RN:" + " " + PeriodicTable.getCASId(elementSymbol) + "\n"
      + "Element Category:" + " "
      + serieTranslator(PeriodicTable.getChemicalSeries(elementSymbol)) + "\n" + "State:" + " "
      + phaseTranslator(PeriodicTable.getPhase(elementSymbol)) + "\n" + "Electronegativity:" + " "
      + (PeriodicTable.getPaulingElectronegativity(elementSymbol) == null ? "undefined"
          : PeriodicTable.getPaulingElectronegativity(elementSymbol)));

  StringBuilder sb_up =
      new StringBuilder("<html><FONT SIZE=+2>" + result + " (" + elementSymbol + ")</FONT><br> "
          + "Atomic number" + " " + element.number() + (", " + "Group" + " " + element.group())
          + ", " + "Period" + " " + element.period() + "</html>");


  StringBuilder sb_Center = new StringBuilder("<html><FONT> " + "CAS RN:" + " "
      + PeriodicTable.getCASId(elementSymbol) + "<br> " + "Element Category:" + " "
      + serieTranslator(PeriodicTable.getChemicalSeries(elementSymbol)) + "<br> " + "State:" + " "
      + phaseTranslator(PeriodicTable.getPhase(elementSymbol)) + "<br> " + "Electronegativity:"
      + " "
      + (PeriodicTable.getPaulingElectronegativity(elementSymbol) == null ? "undefined"
          : PeriodicTable.getPaulingElectronegativity(elementSymbol))
      + "<br>" + "</FONT></html>");
}
 
Example #29
Source Project: Quelea   Author: quelea-projection   File: ScheduleThemeNode.java    License: GNU General Public License v3.0 5 votes vote down vote up
public ScheduleThemeNode(UpdateThemeCallback songCallback, UpdateThemeCallback bibleCallback, Stage popup, Button themeButton) {
    this.songCallback = songCallback;
    this.bibleCallback = bibleCallback;
    this.popup = popup;
    themeDialog = new EditThemeDialog();
    themeDialog.initModality(Modality.APPLICATION_MODAL);
    contentPanel = new VBox();
    BorderPane.setMargin(contentPanel, new Insets(10));
    themeButton.layoutXProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
            MainWindow mainWindow = QueleaApp.get().getMainWindow();
            double width = mainWindow.getWidth() - t1.doubleValue() - 100;
            if (width < 50) {
                width = 50;
            }
            if (width > 900) {
                width = 900;
            }
            contentPanel.setPrefWidth(width);
            contentPanel.setMaxWidth(width);
        }
    });
    setMaxHeight(300);
    contentPanel.setSpacing(5);
    contentPanel.setPadding(new Insets(3));
    refresh();
    ScrollPane scroller = new ScrollPane(contentPanel);
    scroller.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    setCenter(scroller);
}
 
Example #30
Source Project: tcMenu   Author: davetcc   File: MainWindowController.java    License: Apache License 2.0 5 votes vote down vote up
private void buildDialogButton(MenuButtonType btn1, HBox buttonArea) {
    if(btn1 != MenuButtonType.NONE) {
        Button btn = new Button(btn1.getButtonName());
        btn.setOnAction((e)-> remoteControl.sendDialogAction(btn1));
        btn.getStyleClass().add("flatButton");
        HBox.setHgrow(btn, Priority.ALWAYS);
        btn.setMaxWidth(Double.MAX_VALUE);
        buttonArea.getChildren().add(btn);
    }
}