當前位置: 首頁>>代碼示例>>Java>>正文


Java JFXButton.setBackground方法代碼示例

本文整理匯總了Java中com.jfoenix.controls.JFXButton.setBackground方法的典型用法代碼示例。如果您正苦於以下問題:Java JFXButton.setBackground方法的具體用法?Java JFXButton.setBackground怎麽用?Java JFXButton.setBackground使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.jfoenix.controls.JFXButton的用法示例。


在下文中一共展示了JFXButton.setBackground方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: MDRoundButtonSkin

import com.jfoenix.controls.JFXButton; //導入方法依賴的package包/類
public MDRoundButtonSkin(JFXButton button)
{
    super(button);
    
    this.buttonRippler = new JFXRippler(new StackPane(), RipplerMask.CIRCLE, RipplerPos.FRONT)
    {
        @Override
        protected void initListeners()
        {
            this.ripplerPane.setOnMousePressed((event) -> {
                this.createRipple(event.getX(), event.getY());
            });
        }
    };
    this.buttonContainer.getChildren().add(this.buttonRippler);
    
    button.buttonTypeProperty().addListener((o, oldVal, newVal) -> this.updateButtonType(newVal));
    button.setOnMousePressed((e) -> {
        if(this.clickedAnimation != null)
        {
            this.clickedAnimation.setRate(1);
            this.clickedAnimation.play();
        }
    });
    button.setOnMouseReleased((e) -> {
        if(this.clickedAnimation != null)
        {
            this.clickedAnimation.setRate(-1);
            this.clickedAnimation.play();
        }
    });
    
    button.setPickOnBounds(false);
    this.buttonContainer.setPickOnBounds(false);
    
    this.buttonContainer.borderProperty().bind(this.getSkinnable().borderProperty());
    this.buttonContainer.backgroundProperty().bind(Bindings.createObjectBinding(() -> {
        if(button.getBackground() == null || this.isJavaDefaultBackground(button.getBackground()) || this.isJavaDefaultClickedBackground(button.getBackground()))
            button.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, this.defaultRadii, null)));
        
        if(this.getSkinnable().getBackground() != null && this.getSkinnable().getBackground().getFills().get(0).getInsets().equals(new Insets(-0.2, -0.2, -0.2, -0.2)))
            return new Background(new BackgroundFill(this.getSkinnable().getBackground() != null ? this.getSkinnable().getBackground().getFills().get(0).getFill() : Color.TRANSPARENT, this.getSkinnable().backgroundProperty().get() != null ? this.getSkinnable().getBackground().getFills().get(0).getRadii() : this.defaultRadii, Insets.EMPTY));
        else
            return new Background(new BackgroundFill(this.getSkinnable().getBackground() != null ? this.getSkinnable().getBackground().getFills().get(0).getFill() : Color.TRANSPARENT, this.getSkinnable().getBackground() != null ? this.getSkinnable().getBackground().getFills().get(0).getRadii() : this.defaultRadii, Insets.EMPTY));
    }, this.getSkinnable().backgroundProperty()));
    
    button.ripplerFillProperty().addListener((o, oldVal, newVal) -> this.buttonRippler.setRipplerFill(newVal));
    
    if(button.getBackground() == null || this.isJavaDefaultBackground(button.getBackground()))
        button.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, this.defaultRadii, null)));
    
    this.updateButtonType(button.getButtonType());
    this.updateChildren();
}
 
開發者ID:Leviathan-Studio,項目名稱:MineIDE-UI,代碼行數:55,代碼來源:MDRoundButtonSkin.java

示例2: createCalendarArrowsPane

import com.jfoenix.controls.JFXButton; //導入方法依賴的package包/類
protected BorderPane createCalendarArrowsPane() {

        SVGGlyph leftChevron = new SVGGlyph(0,
            "CHEVRON_LEFT",
            "M 742,-37 90,614 Q 53,651 53,704.5 53,758 90,795 l 652,651 q 37,37 90.5,37 53.5,0 90.5,-37 l 75,-75 q 37,-37 37,-90.5 0,-53.5 -37,-90.5 L 512,704 998,219 q 37,-38 37,-91 0,-53 -37,-90 L 923,-37 Q 886,-74 832.5,-74 779,-74 742,-37 z",
            Color.GRAY);
        SVGGlyph rightChevron = new SVGGlyph(0,
            "CHEVRON_RIGHT",
            "m 1099,704 q 0,-52 -37,-91 L 410,-38 q -37,-37 -90,-37 -53,0 -90,37 l -76,75 q -37,39 -37,91 0,53 37,90 l 486,486 -486,485 q -37,39 -37,91 0,53 37,90 l 76,75 q 36,38 90,38 54,0 90,-38 l 652,-651 q 37,-37 37,-90 z",
            Color.GRAY);
        leftChevron.setFill(DEFAULT_COLOR);
        leftChevron.setSize(6, 11);
        rightChevron.setFill(DEFAULT_COLOR);
        rightChevron.setSize(6, 11);

        backMonthButton = new JFXButton();
        backMonthButton.setMinSize(40, 40);
        backMonthButton.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT,
            new CornerRadii(40),
            Insets.EMPTY)));
        backMonthButton.getStyleClass().add("left-button");
        backMonthButton.setGraphic(leftChevron);
        backMonthButton.setRipplerFill(this.datePicker.getDefaultColor());
        backMonthButton.setOnAction(t -> forward(-1, MONTHS, false, true));

        forwardMonthButton = new JFXButton();
        forwardMonthButton.setMinSize(40, 40);
        forwardMonthButton.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT,
            new CornerRadii(40),
            Insets.EMPTY)));
        forwardMonthButton.getStyleClass().add("right-button");
        forwardMonthButton.setGraphic(rightChevron);
        forwardMonthButton.setRipplerFill(this.datePicker.getDefaultColor());
        forwardMonthButton.setOnAction(t -> forward(1, MONTHS, false, true));

        BorderPane arrowsContainer = new BorderPane();
        arrowsContainer.setLeft(backMonthButton);
        arrowsContainer.setRight(forwardMonthButton);
        arrowsContainer.setPadding(new Insets(4, 12, 2, 12));
        arrowsContainer.setPickOnBounds(false);
        return arrowsContainer;
    }
 
開發者ID:jfoenixadmin,項目名稱:JFoenix,代碼行數:43,代碼來源:JFXDatePickerContent.java


注:本文中的com.jfoenix.controls.JFXButton.setBackground方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。