admin管理员组文章数量:1134248
I'm using java 21.0.5, JavaFX version 20.0.2. My problem is that running the below code
import javafx.collections.*;
import javafx.geometry.*;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.*;
import javafx.scene.*;
import javafx.application.Application;
import javafx.application.Platform;
public class MyApplication extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
VBox root = new VBox();
root.getChildren().add(new Label("test"));
root.setStyle("-fx-background-color:transparent;");
Scene scene = new Scene(root, 800, 600);
primaryStage.setTitle("Cursor Control");
scene.setFill(Color.TRANSPARENT);
//primaryStage.initStyle(StageStyle.UNIFIED);
scene.setFill(Color.TRANSPARENT);
primaryStage.resizableProperty().setValue(Boolean.FALSE);
primaryStage.setScene(scene);
primaryStage.show();
}
}
The window does unify, however removing focus from it in any way, for example clicking off, causes the entire unified window to turn pure white. When commenting out the single initStyle
, while the stage is still white as expected, the test text is visible, whereas said text and any more content within the main window disappears upon defocusing when the unified stage style is selected/uncommented.
Images attached are screenshots of the unified and non-unified windows focused/defocused:
Unified Style
Focused:
Unfocused:
Normal Style (not unified)
Focused:
Unfocused:
Hopefully there is a way for a unified window to not exhibit this behaviour, I would greatly appreciate it if there is a solution. This is the main code I'm working with to try and sort the issue before expanding it, and no errors are produced in the console.
本文标签: javaHow can I prevent a unified JavaFX window from turning allwhite on defocusStack Overflow
版权声明:本文标题:java - How can I prevent a unified JavaFX window from turning all-white on defocus? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736764356a1951732.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论