Example usage for javafx.scene.control Button setId

List of usage examples for javafx.scene.control Button setId

Introduction

In this page you can find the example usage for javafx.scene.control Button setId.

Prototype

public final void setId(String value) 

Source Link

Usage

From source file:TwoButtons.java

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    final RowLayout layout = new RowLayout();
    shell.setLayout(layout);//from   w ww .ja  v  a2 s.c om

    /* Create the SWT button */
    final org.eclipse.swt.widgets.Button swtButton =
            new org.eclipse.swt.widgets.Button(shell, SWT.PUSH);
    swtButton.setText("SWT Button");

    /* Create an FXCanvas */
    final FXCanvas fxCanvas = new FXCanvas(shell, SWT.NONE) {

        public Point computeSize(int wHint, int hHint, boolean changed) {
            getScene().getWindow().sizeToScene();
            int width = (int) getScene().getWidth();
            int height = (int) getScene().getHeight();
            return new Point(width, height);
        }
    };
    /* Create a JavaFX Group node */
    Group group = new Group();
    /* Create a JavaFX button */
    final Button jfxButton = new Button("JFX Button");
    /* Assign the CSS ID ipad-dark-grey */
    jfxButton.setId("ipad-dark-grey");
    /* Add the button as a child of the Group node */
    group.getChildren().add(jfxButton);
    /* Create the Scene instance and set the group node as root */
    Scene scene = new Scene(group, Color.rgb(shell.getBackground().getRed(), shell.getBackground().getGreen(),
            shell.getBackground().getBlue()));
    /* Attach an external stylesheet */
    scene.getStylesheets().add("twobuttons/Buttons.css");
    fxCanvas.setScene(scene);

    /* Add Listeners */
    swtButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            jfxButton.setText("JFX Button: Hello from SWT");
            shell.layout();
        }
    });
    jfxButton.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent event) {
            swtButton.setText("SWT Button: Hello from JFX");
            shell.layout();
        }
    });

    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    BorderPane root = new BorderPane();
    Scene scene = new Scene(root, 180, 250);

    String[] keys = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "*", "0", "#" };

    GridPane numPad = new GridPane();
    for (int i = 0; i < 12; i++) {
        Button button = new Button(keys[i]);
        button.getStyleClass().add("num-button");
        numPad.add(button, i % 3, (int) Math.ceil(i / 3));
    }/*  ww  w  .ja v a  2s.  c o  m*/

    Button call = new Button("Call");
    call.setId("call-button");
    call.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    numPad.add(call, 0, 4);

    GridPane.setColumnSpan(call, 3);
    GridPane.setHgrow(call, Priority.ALWAYS);

    root.setCenter(numPad);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:AudioPlayer3.java

private Button createOpenButton() {
    final Button openButton = new Button();
    openButton.setId("openButton");
    openButton.setOnAction(new OpenHandler());
    openButton.setPrefWidth(32);// w  ww.  j av  a2s . c  o m
    openButton.setPrefHeight(32);
    return openButton;
}

From source file:AudioPlayer3.java

private Node createControlPanel() {
    final HBox hbox = new HBox();
    hbox.setAlignment(Pos.CENTER);/*from   w  ww .j  av a2  s . co m*/
    hbox.setFillHeight(false);

    final Button playPauseButton = createPlayPauseButton();

    final Button seekStartButton = new Button();
    seekStartButton.setId("seekStartButton");
    seekStartButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            seekAndUpdatePosition(Duration.ZERO);
        }
    });

    final Button seekEndButton = new Button();
    seekEndButton.setId("seekEndButton");
    seekEndButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            final MediaPlayer mediaPlayer = songModel.getMediaPlayer();
            final Duration totalDuration = mediaPlayer.getTotalDuration();
            final Duration oneSecond = Duration.seconds(1);
            seekAndUpdatePosition(totalDuration.subtract(oneSecond));
        }
    });

    hbox.getChildren().addAll(seekStartButton, playPauseButton, seekEndButton);
    return hbox;
}

From source file:AudioPlayer3.java

private Button createPlayPauseButton() {
    URL url = getClass().getResource("resources/pause.png");
    pauseImg = new Image(url.toString());

    url = getClass().getResource("resources/play.png");
    playImg = new Image(url.toString());

    playPauseIcon = new ImageView(playImg);

    final Button playPauseButton = new Button(null, playPauseIcon);
    playPauseButton.setId("playPauseButton");
    playPauseButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override/* w  w w  .  ja va 2  s  . com*/
        public void handle(ActionEvent arg0) {
            final MediaPlayer mediaPlayer = songModel.getMediaPlayer();
            if (mediaPlayer.getStatus() == MediaPlayer.Status.PLAYING) {
                mediaPlayer.pause();
            } else {
                mediaPlayer.play();
            }
        }
    });
    return playPauseButton;
}

From source file:org.pdfsam.ui.dashboard.about.AboutDashboardPane.java

@Inject
public AboutDashboardPane(Pdfsam pdfsam) {
    getStyleClass().add("dashboard-container");
    VBox left = new VBox(5);
    addSectionTitle(pdfsam.name(), left);
    Label copyright = new Label("Copyright 2014 by Andrea Vacondio");
    AwesomeDude.setIcon(copyright, AwesomeIcon.COPYRIGHT);
    left.getChildren().addAll(new Label(String.format("ver. %s", pdfsam.version())), copyright);
    addHyperlink(null, "http://www.gnu.org/licenses/agpl-3.0.html", "GNU Affero General Public License v3",
            left);//  ww  w .  j  a v  a2 s  .co m
    addHyperlink(AwesomeIcon.HOME, "http://www.pdfsam.org", "www.pdfsam.org", left);
    addHyperlink(AwesomeIcon.RSS_SQUARE, "http://www.pdfsam.org/feed/",
            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 fxRuntime = new Label(
            String.format("JavaFX %s", com.sun.javafx.runtime.VersionInfo.getRuntimeVersion()));
    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"));
    AwesomeDude.setIcon(copyButton, AwesomeIcon.COPY);
    copyButton.getStyleClass().addAll(Style.BUTTON.css());
    copyButton.setId("copyEnvDetails");
    copyButton.setOnAction(a -> {
        ClipboardContent content = new ClipboardContent();
        writeContent(Arrays.asList(pdfsam.name(), pdfsam.version(), runtime.getText(), fxRuntime.getText(),
                memory.getText())).to(content);
        Clipboard.getSystemClipboard().setContent(content);
    });
    left.getChildren().addAll(runtime, fxRuntime, memory, copyButton);

    addSectionTitle(DefaultI18nContext.getInstance().i18n("Thanks to"), left);
    addHyperlink(null, "http://www.pdfsam.org/thanks_to",
            DefaultI18nContext.getInstance().i18n("The open source projects making PDFsam possible"), left);
    VBox right = new VBox(5);
    addSectionTitle(DefaultI18nContext.getInstance().i18n("Support"), right);
    addHyperlink(AwesomeIcon.BUG, "http://www.pdfsam.org/issue_tracker",
            DefaultI18nContext.getInstance().i18n("Bug and feature requests"), right);
    addHyperlink(AwesomeIcon.QUESTION_CIRCLE, "http://www.pdfsam.org/wiki", "HowTo wiki", right);
    addHyperlink(AwesomeIcon.YOUTUBE_PLAY, "http://www.pdfsam.org/quickstart_video",
            DefaultI18nContext.getInstance().i18n("Play the \"get started\" video"), right);

    addSectionTitle(DefaultI18nContext.getInstance().i18n("Contribute"), right);
    addHyperlink(AwesomeIcon.GITHUB, "http://www.pdfsam.org/scm",
            DefaultI18nContext.getInstance().i18n("Fork PDFsam on GitHub"), right);
    addHyperlink(AwesomeIcon.FLAG_ALT, "http://www.pdfsam.org/translate",
            DefaultI18nContext.getInstance().i18n("Translate"), right);
    addHyperlink(AwesomeIcon.DOLLAR, "http://www.pdfsam.org/donate",
            DefaultI18nContext.getInstance().i18n("Donate"), right);

    addSectionTitle(DefaultI18nContext.getInstance().i18n("Social"), right);
    addHyperlink(AwesomeIcon.TWITTER_SQUARE, "http://www.pdfsam.org/twitter",
            DefaultI18nContext.getInstance().i18n("Follow us on Twitter"), right);
    addHyperlink(AwesomeIcon.GOOGLE_PLUS_SQUARE, "http://www.pdfsam.org/gplus",
            DefaultI18nContext.getInstance().i18n("Follow us on Google Plus"), right);
    addHyperlink(AwesomeIcon.FACEBOOK_SQUARE, "http://www.pdfsam.org/facebook",
            DefaultI18nContext.getInstance().i18n("Like us on Facebook"), right);
    getChildren().addAll(left, right);

}