JavaFX:当舞台上有阴影效果时,如何正确地滑动窗格?
我在“”上见过这个问题 我不明白John Astralidis发表的最后一条评论中的部分代码。这似乎解决了我的问题。我想滑动带有阴影舞台的窗格。现在我的问题是幻灯片动画播放出我的视觉根窗格绑定,它只是播放阶段(或实际根窗格)绑定 我的可视根窗格是实际根窗格的子窗格,我使用padding和Corlor.TRANSPARENT设置了实际根窗格,以实现我的可视根窗格阴影效果 这是我从约翰·阿斯特拉利迪斯和菲利佩·吉扎尔·迪亚兹那里修改的代码。 启动代码:JavaFX:当舞台上有阴影效果时,如何正确地滑动窗格?,javafx,slide,shadow,stage,Javafx,Slide,Shadow,Stage,我在“”上见过这个问题 我不明白John Astralidis发表的最后一条评论中的部分代码。这似乎解决了我的问题。我想滑动带有阴影舞台的窗格。现在我的问题是幻灯片动画播放出我的视觉根窗格绑定,它只是播放阶段(或实际根窗格)绑定 我的可视根窗格是实际根窗格的子窗格,我使用padding和Corlor.TRANSPARENT设置了实际根窗格,以实现我的可视根窗格阴影效果 这是我从约翰·阿斯特拉利迪斯和菲利佩·吉扎尔·迪亚兹那里修改的代码。 启动代码: @Override public void
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
stage.initStyle(StageStyle.TRANSPARENT);
Scene scene = new Scene(root);//
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
FXMLDocument.fxml文件:
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" fx:id="anchorPane" prefWidth="500" prefHeight="500" style="-fx-background-color: transparent;"
fx:controller="leftslidemenusample.FXMLDocumentController">
<children>
<ToolBar AnchorPane.topAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" minHeight="56.0" >
<Button text="menu" fx:id="menu" />
</ToolBar>
<StackPane fx:id="mainContent" style="-fx-background-color:rgba(0,0,0,0.30)" AnchorPane.bottomAnchor="0.0" AnchorPane.topAnchor="56.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" >
<children>
</children>
</StackPane>
<AnchorPane fx:id="navList" style="-fx-background-color:white" AnchorPane.topAnchor="56.0" AnchorPane.bottomAnchor="0.0" prefWidth="180.0" translateX="-180" >
<children>
<Label text="left side menu"/>
</children>
</AnchorPane>
</children>
最后,我完成了。我认为John Astralidis的答案是错误的。但是谢谢。关键是:
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class FXApplication extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
stage.initStyle(StageStyle.TRANSPARENT);
Scene scene = new Scene(root);//
scene.setFill(Color.TRANSPARENT);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
布局FXML文件--FXMLDocument.FXML
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<StackPane xmlns:fx="http://javafx.com/fxml/1" fx:id="pane" prefWidth="500" prefHeight="500" style="-fx-background-color: transparent;"
fx:controller="FXMLDocumentController">
<children>
<AnchorPane fx:id="anchorPane" prefWidth="500" prefHeight="500" style="-fx-background-color: WHITE;">
<children>
<ToolBar AnchorPane.topAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" minHeight="56.0" >
<Button text="menu" fx:id="menu" />
</ToolBar>
<StackPane fx:id="mainContent" style="-fx-background-color:rgba(0,0,0,0.30)" AnchorPane.bottomAnchor="0.0" AnchorPane.topAnchor="56.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" >
<children>
</children>
</StackPane>
<AnchorPane fx:id="navList" style="-fx-background-color:white" AnchorPane.topAnchor="56.0" AnchorPane.bottomAnchor="0.0" prefWidth="180.0" translateX="-180" >
<children>
<Label text="left side menu"/>
</children>
</AnchorPane>
</children>
</AnchorPane>
</children>
}
如下图所示:
最后,我完成了。我认为约翰·阿斯特拉利迪斯的答案是错误的。但是谢谢。关键是:
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class FXApplication extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
stage.initStyle(StageStyle.TRANSPARENT);
Scene scene = new Scene(root);//
scene.setFill(Color.TRANSPARENT);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
布局FXML文件--FXMLDocument.FXML
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<StackPane xmlns:fx="http://javafx.com/fxml/1" fx:id="pane" prefWidth="500" prefHeight="500" style="-fx-background-color: transparent;"
fx:controller="FXMLDocumentController">
<children>
<AnchorPane fx:id="anchorPane" prefWidth="500" prefHeight="500" style="-fx-background-color: WHITE;">
<children>
<ToolBar AnchorPane.topAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" minHeight="56.0" >
<Button text="menu" fx:id="menu" />
</ToolBar>
<StackPane fx:id="mainContent" style="-fx-background-color:rgba(0,0,0,0.30)" AnchorPane.bottomAnchor="0.0" AnchorPane.topAnchor="56.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" >
<children>
</children>
</StackPane>
<AnchorPane fx:id="navList" style="-fx-background-color:white" AnchorPane.topAnchor="56.0" AnchorPane.bottomAnchor="0.0" prefWidth="180.0" translateX="-180" >
<children>
<Label text="left side menu"/>
</children>
</AnchorPane>
</children>
</AnchorPane>
</children>
}
如下图所示:
有人能帮我吗?阴影效果有错吗?我的阴影效果是由两个窗格创建的,视觉根窗格和实际根窗格,视觉根窗格是实际窗格的子窗格。我使用填充和stage initStyle设置实际根窗格,场景填充透明,然后使用“-fx effect”设置视觉根窗格阴影效果。如何在可视根窗格而非实际根窗格上滑动窗格?是否有人可以帮助我?是否有阴影效果错误?我的阴影效果由两个窗格创建,可视根窗格和实际根窗格,可视根窗格是实际窗格的子窗格。我将实际根窗格设置为带填充和舞台初始化样式,并将场景填充为透明,然后使用“-fx effect”设置可视根窗格阴影效果。如何在可视根窗格而非实际根窗格上滑动窗格?