6_jfoenix_自定义舞台,JFXSlider

1_自定义舞台


package sample;

import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.input.MouseEvent;
import javafx.scene.paint.Color;
import javafx.stage.Stage;

import static javafx.stage.StageStyle.*;

public class Main extends Application {

    private double x,y;

    @Override
    public void start(Stage primaryStage) throws Exception{
        Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));

        Scene scene=new Scene(root);
        scene.setFill(Color.TRANSPARENT);

        root.setOnMousePressed(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                x=event.getSceneX();
                y=event.getSceneY();
            }
        });

        root.setOnMouseDragged(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                primaryStage.setX(event.getScreenX() - x);
                primaryStage.setY(event.getScreenY() - y);
            }
        });

        primaryStage.setScene(scene);
        primaryStage.initStyle(TRANSPARENT);
        primaryStage.show();
    }


    public static void main(String[] args) {
        launch(args);
    }
}
复制代码

package sample;

import com.jfoenix.controls.JFXToolbar;
import javafx.fxml.FXML;
import javafx.scene.input.MouseEvent;
import javafx.stage.Stage;

public class Controller {
    @FXML
    private JFXToolbar jfxtoolbar;
    @FXML
    void close(MouseEvent event) {
        Stage stage= (Stage) jfxtoolbar.getScene().getWindow();
        stage.close();
    }

    @FXML
    void max(MouseEvent event) {
        Stage stage=(Stage) jfxtoolbar.getScene().getWindow();
        stage.setFullScreen(true);
    }

    @FXML
    void mix(MouseEvent event) {
        Stage stage=(Stage) jfxtoolbar.getScene().getWindow();
        stage.setIconified(true);
    }

}
复制代码

2_JFXSlider


.jfx-slider > .track {
     -fx-background-color: #ff9a07;
}

.jfx-slider > .colored-track {
     -fx-background-color: #4f8aff;
}

.jfx-slider > .thumb {
     -fx-background-color: red;
}

.jfx-slider > .animated-thumb {
     -fx-background-color: black;
}
复制代码

package sample;

import com.jfoenix.controls.JFXSlider;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;

public class Controller {
    @FXML
    private JFXSlider slider;

    @FXML
    void button(ActionEvent event) {

        System.out.println( Math.round (slider.getValue()));
        
    }
}
复制代码

转载于:https://juejin.im/post/5cf3d5e6e51d4555fc1acc51

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值