当前位置: 首页>>代码示例>>Java>>正文


Java Button.setDefaultButton方法代码示例

本文整理汇总了Java中javafx.scene.control.Button.setDefaultButton方法的典型用法代码示例。如果您正苦于以下问题:Java Button.setDefaultButton方法的具体用法?Java Button.setDefaultButton怎么用?Java Button.setDefaultButton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.control.Button的用法示例。


在下文中一共展示了Button.setDefaultButton方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: WebViewPane

import javafx.scene.control.Button; //导入方法依赖的package包/类
public WebViewPane() {
    VBox.setVgrow(this, Priority.ALWAYS);
    setMaxWidth(Double.MAX_VALUE);
    setMaxHeight(Double.MAX_VALUE);

    WebView view = new WebView();
    view.setMinSize(500, 400);
    view.setPrefSize(500, 400);
    final WebEngine eng = view.getEngine();
    eng.load("http://www.oracle.com/us/index.html");
    final TextField locationField = new TextField("http://www.oracle.com/us/index.html");
    locationField.setMaxHeight(Double.MAX_VALUE);
    Button goButton = new Button("Go");
    goButton.setDefaultButton(true);
    EventHandler<ActionEvent> goAction = new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent event) {
            eng.load(locationField.getText().startsWith("http://") ? locationField.getText() :
                    "http://" + locationField.getText());
        }
    };
    goButton.setOnAction(goAction);
    locationField.setOnAction(goAction);
    eng.locationProperty().addListener(new ChangeListener<String>() {
        @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            locationField.setText(newValue);
        }
    });
    GridPane grid = new GridPane();
    grid.setVgap(5);
    grid.setHgap(5);
    GridPane.setConstraints(locationField, 0, 0, 1, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.SOMETIMES);
    GridPane.setConstraints(goButton,1,0);
    GridPane.setConstraints(view, 0, 1, 2, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.ALWAYS);
    grid.getColumnConstraints().addAll(
            new ColumnConstraints(100, 100, Double.MAX_VALUE, Priority.ALWAYS, HPos.CENTER, true),
            new ColumnConstraints(40, 40, 40, Priority.NEVER, HPos.CENTER, true)
    );
    grid.getChildren().addAll(locationField, goButton, view);
    getChildren().add(grid);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:WebViewBrowser.java

示例2: WebViewSample

import javafx.scene.control.Button; //导入方法依赖的package包/类
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);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:37,代码来源:WebViewSample.java

示例3: PrescriptionAction

import javafx.scene.control.Button; //导入方法依赖的package包/类
public PrescriptionAction() {

        button = new Button();
        button0 = new Button();

        setSpacing(3.0);
        setStyle("-fx-background-color: none;");
        getStylesheets().add("/view/common/../../css/main.css");

        button.setDefaultButton(true);
        button.setMnemonicParsing(false);
        button.setOnAction(this::handleEditButton);
        button.setText("Edit");

        button0.setCancelButton(true);
        button0.setMnemonicParsing(false);
        button0.setOnAction(this::handleDeleteButton);
        button0.setText("Delete");

        getChildren().add(button);
        getChildren().add(button0);

    }
 
开发者ID:kmrifat,项目名称:Dr-Assistant,代码行数:24,代码来源:PrescriptionAction.java

示例4: IoVariableChangeDialog

import javafx.scene.control.Button; //导入方法依赖的package包/类
/**
 * Opens a dialog that allows to change the column header of a specification table.
 * It is impossible to set the {@link SpecIoVariable}s name to a name that is already used
 * inside the table.
 *
 * @param variableToChange the model to change
 * @param alreadyDefinedVariables the already defined variables for finding out whether
 *                                the name was changed to something illegal
 */
public IoVariableChangeDialog(
    SpecIoVariable variableToChange, List<SpecIoVariable> alreadyDefinedVariables) {
  setTitle("Change Settings of " + variableToChange.getName());
  this.variableToChange = variableToChange;
  this.changeButton = new ButtonType("Change");
  this.definitionPane = new IoVariableDefinitionPane(
      variableToChange.getCategory(),
      variableToChange.getRole(),
      variableToChange.getName(),
      variableToChange.getType());

  setResultConverter(this::convertResult);

  getDialogPane().setContent(definitionPane);
  getDialogPane().getButtonTypes().add(changeButton);
  Button button = (Button) getDialogPane().lookupButton(changeButton);
  button.setDefaultButton(true);
  getDialogPane().setId("IoVariableChangeDialogPane");

  getDialogPane().lookupButton(changeButton).disableProperty()
      .bind(definitionPane.createDefinitionInvalidBinding(alreadyDefinedVariables));
}
 
开发者ID:VerifAPS,项目名称:stvs,代码行数:32,代码来源:IoVariableChangeDialog.java

示例5: StageSample

import javafx.scene.control.Button; //导入方法依赖的package包/类
public StageSample() {
    //create a button for initializing our new stage
    Button button = new Button("Create a Stage");
    button.setStyle("-fx-font-size: 24;");
    button.setDefaultButton(true);
    button.setOnAction(new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent t) {
            final Stage stage = new Stage();
            //create root node of scene, i.e. group
            Group rootGroup = new Group();
            //create scene with set width, height and color
            Scene scene = new Scene(rootGroup, 200, 200, Color.WHITESMOKE);
            //set scene to stage
            stage.setScene(scene);
            //center stage on screen
            stage.centerOnScreen();
            //show the stage
            stage.show();
            //add some node to scene
            Text text = new Text(20, 110, "JavaFX");
            text.setFill(Color.DODGERBLUE);
            text.setEffect(new Lighting());
            text.setFont(Font.font(Font.getDefault().getFamily(), 50));
            //add text to the main root group
            rootGroup.getChildren().add(text);
        }
    });
    getChildren().add(button);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:30,代码来源:StageSample.java

示例6: RecurrencePopupSkin

import javafx.scene.control.Button; //导入方法依赖的package包/类
public RecurrencePopupSkin(RecurrencePopup popup) {
    super();

    this.popup = popup;

    Button okButton = new Button(Messages.getString("RecurrencePopupSkin.OK")); //$NON-NLS-1$
    okButton.setDefaultButton(true);
    okButton.setOnAction(evt -> {
        popup.hide();
        popup.fireEvent(
                new RecurrencePopupEvent(RecurrencePopupEvent.OK_PRESSED));
    });

    Button cancelButton = new Button(Messages.getString("RecurrencePopupSkin.CANCEL")); //$NON-NLS-1$
    cancelButton.setCancelButton(true);
    cancelButton.setOnAction(evt -> {
        popup.hide();
        popup.fireEvent(
                new RecurrencePopupEvent(RecurrencePopupEvent.CANCEL_PRESSED));
    });

    HBox buttonBox = new HBox();
    buttonBox.setAlignment(Pos.CENTER);
    buttonBox.getChildren().addAll(cancelButton, okButton);
    buttonBox.getStyleClass().add("button-pane"); //$NON-NLS-1$

    BorderPane contentPane = new BorderPane();
    contentPane.getStyleClass().add("content"); //$NON-NLS-1$
    contentPane.setCenter(popup.getRecurrenceView());
    contentPane.setBottom(buttonBox);

    stackPane = popup.getRoot();
    stackPane.getChildren().add(contentPane);
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:35,代码来源:RecurrencePopupSkin.java

示例7: Actions

import javafx.scene.control.Button; //导入方法依赖的package包/类
public Actions() {

        columnConstraints = new ColumnConstraints();
        columnConstraints0 = new ColumnConstraints();
        columnConstraints1 = new ColumnConstraints();
        rowConstraints = new RowConstraints();
        button = new Button();
        button0 = new Button();
        button1 = new Button();

        setPrefHeight(32.0);
        setPrefWidth(186.0);
        setStyle("-fx-background-color: none;");
        getStylesheets().add("/view/common/../../css/main.css");

        columnConstraints.setHgrow(javafx.scene.layout.Priority.SOMETIMES);
        columnConstraints.setMaxWidth(120.0);
        columnConstraints.setMinWidth(10.0);
        columnConstraints.setPrefWidth(95.0);

        columnConstraints0.setHgrow(javafx.scene.layout.Priority.SOMETIMES);
        columnConstraints0.setMaxWidth(150.0);
        columnConstraints0.setMinWidth(10.0);
        columnConstraints0.setPrefWidth(100.0);

        columnConstraints1.setHgrow(javafx.scene.layout.Priority.SOMETIMES);
        columnConstraints1.setMaxWidth(192.0);
        columnConstraints1.setMinWidth(10.0);
        columnConstraints1.setPrefWidth(110.0);

        rowConstraints.setMinHeight(10.0);
        rowConstraints.setPrefHeight(30.0);
        rowConstraints.setVgrow(javafx.scene.layout.Priority.SOMETIMES);

        button.setDefaultButton(true);
        button.setMnemonicParsing(false);
        button.setOnAction(this::handleEditButton);
        button.setText("Edit");

        GridPane.setColumnIndex(button0, 1);
        button0.setMnemonicParsing(false);
        button0.setOnAction(this::handleViewButton);
        button0.getStyleClass().add("btn-primary");
        button0.setText("View");

        GridPane.setColumnIndex(button1, 2);
        button1.setCancelButton(true);
        button1.setMnemonicParsing(false);
        button1.setOnAction(this::handleDeleteButton);
        button1.setText("Delete");

        getColumnConstraints().add(columnConstraints);
        getColumnConstraints().add(columnConstraints0);
        getColumnConstraints().add(columnConstraints1);
        getRowConstraints().add(rowConstraints);
        getChildren().add(button);
        getChildren().add(button0);
        getChildren().add(button1);

    }
 
开发者ID:kmrifat,项目名称:Dr-Assistant,代码行数:61,代码来源:Actions.java


注:本文中的javafx.scene.control.Button.setDefaultButton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。