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


Java Button.setStyle方法代码示例

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


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

示例1: ColorButtonSample

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

示例2: createButton

import javafx.scene.control.Button; //导入方法依赖的package包/类
public static Button createButton(String text, Node graphic, String style, Insets insets)
{
	Button button = createButton(text);
	button.setGraphic(graphic);
	button.setStyle(style);
	button.setPadding(insets);
	return button;
}
 
开发者ID:PolyphasicDevTeam,项目名称:NoMoreOversleeps,代码行数:9,代码来源:JavaFxHelper.java

示例3: load

import javafx.scene.control.Button; //导入方法依赖的package包/类
private void load(String fxml, String buttonName, Image background, boolean showDefault) {
    Parent parent = null;
    try {
        parent = FXMLLoader.load(Main.class.getResource("/fxml/" + fxml + ".fxml"));
        panes.put(fxml, parent);
        ImageView imageView = new ImageView(background);
        imageView.setFitHeight(30);
        imageView.setFitWidth(30);
        Button button = new Button(buttonName, imageView);
        button.setAlignment(Pos.BASELINE_LEFT);
        button.setPrefSize(200, 50);
        button.setStyle("-fx-border-width: 0;");
        InterfaceManager.addInterface(Container.create(fxml, button));
        if (showDefault) FrameController.instance.pane.getChildren().add(getInstance(fxml));
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:IzzelAliz,项目名称:LCL,代码行数:19,代码来源:Main.java

示例4: 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

示例5: createArrowDownButton

import javafx.scene.control.Button; //导入方法依赖的package包/类
public static Button createArrowDownButton() {
    Button b = new Button(ARROW_DOWN);
    b.setStyle("-fx-text-fill: dimgray;");
    return b;
}
 
开发者ID:dbisUnibas,项目名称:ReqMan,代码行数:6,代码来源:Utils.java

示例6: createArrowUpButton

import javafx.scene.control.Button; //导入方法依赖的package包/类
public static Button createArrowUpButton() {
    Button b = new Button(ARROW_UP);
    b.setStyle("-fx-text-fill: dimgray;");
    return b;
}
 
开发者ID:dbisUnibas,项目名称:ReqMan,代码行数:6,代码来源:Utils.java


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