當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。