我正在学习 JavaFX,我正在尝试创建一个AnchorPane本身包含 3 个以上AnchorPane的内容。目前,我有一个问题,即面板的阴影由于旁边的面板而被隐藏。所以我需要一些关于如何解决这个问题的建议。
我试图在它们之间创建一个距离,但是我可以看到后面有一个白色层。我试图改变图层的 z 顺序,似乎没有用,所以现在在不知道该怎么做 2 小时后,我在这里问。也许有人知道。
我的代码:
DropShadow dropShadow2;
AnchorPane iconPane, menuPane, viewPane;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage){
dropShadow2 = new DropShadow();
dropShadow2.setOffsetX(6.0);
dropShadow2.setOffsetY(4.0);
//Main layout
AnchorPane main_layout = new AnchorPane();
//Icon layout (left)
setUpIconLayout();
//Menu layout (center)
setUpMenuLayout();
//View layout (right)
setUpViewLayout();
main_layout.getChildren().addAll(iconPane, menuPane, viewPane);
Scene scene = new Scene(main_layout, 1000, 600);
primaryStage.setTitle("Delivery System Database");
primaryStage.setScene(scene);
primaryStage.show();
}
private void setUpIconLayout() {
iconPane = new AnchorPane();
iconPane.setPrefSize(50,600);
String hexColor_left = "D64550";
iconPane.setStyle("-fx-background-color: #" + hexColor_left);
iconPane.setEffect(dropShadow2);
}
private void setUpMenuLayout() {
menuPane = new AnchorPane();
menuPane.setPrefSize(200,600);
String hexColor_mid = "EA9E8D";
menuPane.setStyle("-fx-background-color: #" + hexColor_mid);
menuPane.setEffect(dropShadow2);
menuPane.setTranslateX(50);
}
private void setUpViewLayout() {
viewPane = new AnchorPane();
viewPane.setPrefSize(700,600);
String hexColor_right = "DAEFB3";
viewPane.setStyle("-fx-background-color: #" + hexColor_right);
viewPane.setEffect(dropShadow2);
viewPane.setTranslateX(250);
}
}
精慕HU
慕村9548890
相关分类