I want to create an Fullscreen Application on an RasperryPI.
But now i have a problem with the fullscreen mode, because everytime if I switch sites I must set the FullSreen property false and then true otherwise the window won't get fullscreen.
But if I switch the site the window is shortly not fullscreen and the it is fullscreen.
SplitPane splitPane = new SplitPane();
splitPane.setOrientation(Orientation.VERTICAL);
splitPane.getItems().addAll(table,vbLayout);
Scene scene = SceneBuilder.create().root(splitPane). build();
primaryStage.setScene(scene);
primaryStage.show();
primaryStage.sizeToScene();
primaryStage.setFullScreen(false);
primaryStage.setFullScreen(true);
I hope you understand what i mean.
Best wishes
Johannes
You should not be able to switch sites when you are in fullscreen mode. If you are able to, you must first stop it. The user must come back to normal mode before doing anything else or you must force the normal mode. It's just like playing a video on fullscreen mode on youtube.
You Can Use Follwing Code:-
I Have Use Rectangle 2D Class
SplitPane splitPane = new SplitPane();
splitPane.setOrientation(Orientation.VERTICAL);
splitPane.getItems().addAll(table,vbLayout);
Rectangle2D primScreenBounds = Screen.getPrimary().getVisualBounds();
Scene scene = SceneBuilder.create().root(splitPane). build();
scence.setWidth(primScreenBounds.getWidth());
scence.setHeight(primScreenBounds.getHeight())
primaryStage.setScene(scene);
primaryStage.show();
Related
I'm new to javaFX and I'm using the webview. Everything works fine on my small monitor and I can see all the content of the webview. But when I drag my application to my bigger monitor (1920 x 1080) resolution. I can only see a part of the webview.
This is how the WebView looks like on my bigger monitor:
As you can see i can not see all the content of the webview on my bigger monitor.
I than tried resizing the webview like this so I can see all the content on my bigger monitor:
double height = Screen.getPrimary().getBounds().getHeight();
double width = Screen.getPrimary().getBounds().getWidth();
StackPane root = new StackPane();
//Create WebView
WebView view = new WebView();
view.setMinWidth(width);
view.setMinHeight(height);
The problem now is that the webview height and width is to big for my smaller screen.
I'm displaying my webview in a tab of a tabpane like this:
tabPane.getTabs().add(tab1);
tab1.setContent(view);
How can I make it so that the webview size will adjust to the current screen the stage currently is?
Any kind of help is appreciated
First of all - I highly recommend you to work with SceneBuilder (Drag & Drop user interface design): https://gluonhq.com/products/scene-builder/
SceneBuilder stores the view in a FXML file, and you can use it as follows:
#Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
primaryStage.setTitle("Hello World");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}
I also recommend you to work with IntelliJ:
https://www.jetbrains.com/help/idea/javafx.html
If you do so, you can set the value of pref width/height property to USE_COMPUTED_SIZE over the SceneBuilder GUI, that would solve your problem.
Another (ugly) solution without SceneBuilder would be:
setMinWidth(getWidth());
setMinHeight(getHeight());
I've been working on MacOS for some weeks now, I noticed that applications can't be overlapped over fullscreen applications.
BUT is there actually a way to change the properties of a stage in my case the primaryStage to overlap it over a fullscreen program, e.g. over Firefox or is this ossided not possible?
I have tried:
primaryStage.setAlwaysOnTop(true);
Which is always on top of non fullscreen applications, but I am not able to drag it over fullscreen applications.
Any idea?
Plain code:
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
primaryStage.setTitle("Hello World");
Scene scene = new Scene(root, 300, 275);
scene.setFill(Color.BLACK);
primaryStage.setScene(scene);
primaryStage.setAlwaysOnTop(true);
primaryStage.show();
Switching between scenes; the Parent scene is smaller than the rest of the scenes, so when I go back to the first scene, the stage holds the With/Hight of the last scene. My code to switch to the parent scene is listed below, how can I set it to get the original size of the parent stage/scene? Thanks!!
public void goBack(MouseEvent e) throws IOException {
Stage stage;
Parent root;
root = FXMLLoader.load(getClass().getResource("Main.fxml"));
stage=(Stage) goBack.getScene().getWindow();
Scene scene = new Scene(root, 331, 181);
stage.sizeToScene();
stage.setScene(scene);
stage.show();
}
it looks like you are creating a new main scene. Its possible that you are not doing anything with that scene, and that is why nothing appears to be happening. Perhaps instead of doing this you should manually set the scene that already exists back to its original size. Without seeing the entire program I cant say for sure but this is a guess. Note also that it is unneccessary to generate a new main scene all the time. instead when switching scenes, the main scene should simply be set to invisible, until the program navigates back to it.
The above program should create a transparent stage with some text, but the stage appears opaque:
public class Test extends Application {
#Override
public void start(Stage primaryStage) {
new TextArea(); //Comment this out to enable transparency
Stage stage = new Stage();
stage.initStyle(StageStyle.TRANSPARENT);
Text text = new Text("Is this transparent?");
VBox box = new VBox();
box.getChildren().add(text);
final Scene scene = new Scene(box, 300, 250);
scene.setFill(null);
stage.setScene(scene);
stage.show();
}
}
The new TextArea() line is what breaks things - comment that out and it all works.
Creating any subclass of control (even via new Control() {};) breaks things - a Region or above does not.
This doesn't occur in Java 7 / JFX2.x.
I've created a JIRA for this since it seems a very obvious regression (https://javafx-jira.kenai.com/browse/RT-38938), but is anyone aware why this happens and thus how to work around it until a fix is provided? I've tried replicating this issue by copying the code in Control's constructor, but this seems to be fine - it's just instantiating Control itself that seems to break things.
I remember some forum discussion on this. I think the general gist is that creating a control forces css to be applied to the layout pane, and the layout pane is getting the opaque background.
As a workaround, make the background of the layout pane transparent:
box.setStyle("-fx-background-color: transparent;");
Playing around with my first JavaFX application. Running it on Java8 but that shouldn't be an issue regarding this question.
My problem:
I have a scene (FXML) in which a menu and menu items exist. When one presses a menu item a new window or popup should show. This works just fine, but I want to disable the parent window while the new window is active. Figured out this is possible with modality.
My real problem is: Determining the parent window from the action event I receive. Because the event comes from an menu item it seems a bit problematic. Probably a really stupid question.
My code snippet:
Stage stage = new Stage();
Parent root = FXMLLoader.load(EbooksdownloaderController.class.getResource("about.fxml"));
stage.setScene(new Scene(root));
stage.initModality(Modality.WINDOW_MODAL);
stage.initOwner(((Node)event.getSource()).getScene().getWindow());
stage.show();
Casting the source to a Node gives a class casting exception. But I don't have a clue which other path to follow.
Thanks.
Have been fiddling around a while without any success.
As a final resort I finished it using the following code:
#FXML
private AnchorPane ap;
Stage stage = new Stage();
Parent root = FXMLLoader.load(EbooksdownloaderController.class.getResource("about.fxml"));
stage.setScene(new Scene(root));
stage.initModality(Modality.WINDOW_MODAL);
stage.initOwner(ap.getScene().getWindow());
stage.show();
Not really the way I would prefer. But it works.