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:
}
.jfx-slider > .colored-track {
-fx-background-color:
}
.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