File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JavaFX and the fly likes How to fit javafx Screen in browser window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JavaFX
Bookmark "How to fit javafx Screen in browser window" Watch "How to fit javafx Screen in browser window" New topic
Author

How to fit javafx Screen in browser window

shalini chaurasia
Greenhorn

Joined: Jun 28, 2013
Posts: 9
I made javafx application so when i am running this app at browser it showing half part of the screen, so how can i make this fit to screen in browser.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4540
    
    5

Have you gone through the tutorial?


luck, db
There are no new questions, but there may be new answers.
John Damien Smith
Ranch Hand

Joined: Jan 26, 2012
Posts: 144
    
    9
Darryl's right, the relevant part of the tutorial is, the part which says =>

width and height
Dimensions used to reserve space for an embedded application. The values can be absolute (in pixels) or relative (for example, 50 or 50%).


But the deployment tutorial will only get you so far with sizing your application to fit a browser window as it is not comprehensive in this regard . . .

So what you want is to have the width and height set to 100%, then your app will fill the html page.
By default browsers will add some padding around html elements, so you need to apply a little bit of css to the web page embedding your app so that it fills the entire area.
Look to the standard Ensemble example for JavaFX for an example of how to do this.
Download the source code for ensemble from the page I linked.

The standard JavaFX deployment packaging tools did not used to directly support percentage sizing for embedded apps, but I have not tried it for a long time and perhaps the current ones do.
What Ensemble had done to get it working was have a custom ant build xml file which post processed the generated html page to modify it to use the percentage values.
Check the Ensemble ant build source to see if that is still in there or if it just directly specifies the percentage sizes in it's ant deployment tasks.
You will need to download the Ensemble project, and build it (either from the command line with the ant tool, or (probably easier) from NetBeans).
Once you have done that, in the dist subdirectory, you find a generated html file that contains the essential dtjava.embed parameters (the 100% width and height specifiers) and the css style rules to remove default padding so that the page will fill the entire screen.







shalini chaurasia
Greenhorn

Joined: Jun 28, 2013
Posts: 9
The code is not working, it is taking browser specified size.
John Damien Smith
Ranch Hand

Joined: Jan 26, 2012
Posts: 144
    
    9
> The code is not working, it is taking browser specified size.

The code works, it is doing what it is supposed to do, (make the JavaFX app fill the available area of a browser window).

Did you follow my instructions and build and run the Ensemble application in a browser?

Perhaps you want a different effect or behaviour, but if so you need to describe what you require much better.
You can link screen shots, offer more in depth explanations, post an sscce, etc.
shalini chaurasia
Greenhorn

Joined: Jun 28, 2013
Posts: 9
I used the given code. but its working only for first page, when i clicked for second page it takes browser specified size like 800*600. please help me !!
John Damien Smith
Ranch Hand

Joined: Jan 26, 2012
Posts: 144
    
    9
I don't think it is possible to assist on this question without an sscce and a better description of issues you are facing.

If you create an sscce you can also post it to either the Oracle JavaFX forums or StackOverflow with a JavaFX tag as both of those places are far more active regarding JavaFX than JavaRanch. If you do decide to crosspost, follow JavaRanch's crossposting rules, don't do it without first creating an sscce and make sure that your question is complete and describes your issue in enough detail that somebody would actually be able to assist you in solving it.
shalini chaurasia
Greenhorn

Joined: Jun 28, 2013
Posts: 9
OK

Thank you very much.
 
 
subject: How to fit javafx Screen in browser window