我正在学习JavaFX,我正在尝试创建一个AnchorPane
,其中包含3多个AnchorPane
。目前,我有一个问题,面板的阴影是隐藏的,因为它旁边的面板。所以我需要一些关于如何解决这个问题的建议。
我试着在它们之间创建一个距离,但我可以看到后面有一个白色的层。我试着改变图层的z-顺序,但似乎不起作用,所以在两个小时的不知道该怎么做之后,我在这里问。也许有人知道。
我的代码:
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);
}
}
发布于 2019-03-01 09:03:32
子节点按照添加顺序呈现,因此以相反的顺序添加它们就足够了:
main_layout.getChildren().addAll(viewPane, menuPane, iconPane);
https://stackoverflow.com/questions/54935277
复制相似问题