JavaFX get browser width and height

I'm new to JavaFX and I'm writing a simple login application that I would like to launch in my web browser.

How could I get the web browsers width and height? Is there some object for this purpose or a method I would like to be able to resize the application whenever the browser's size is changed.

Thank you very much for your answers and help. :)


I answered a similar question to this in a Oracle forum post. I'll reproduce the answer here.

The answer is to set a percentage height and width on the embedded application.

Is it possible to change the stage size dynamically when the user has changed the size of browser?

Yes, see the Ensemble sample application Ensemble source code in the JavaFX samples package.

The deployment toolkit currently cannot produce the correct html file for you (see RT-19247 "javafxpackager -deploy does not accept percentage heights and widths").

However, editing the html file to make the required changes after the deployment tool has run is trivial and, if you look at the ensemble ant build script, you can see that the changes can also be automated within ant.

Here is an excerpt from the Ensemble sample app which demonstrates how to accomplish this.

  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaFX 2.0 - Ensemble</title>
  <SCRIPT src=""></SCRIPT>
     function javafxEmbed_ensemble() {
           id : 'ensemble',
           url : 'Ensemble.jnlp',
           placeholder : 'javafx-app-placeholder',
           width : '100%',
           height : '100%',
           jnlp_content : 'PD94b...o8L2pubHA+DQo='
           javafx : '2.0+'
     <!-- Embed FX application into web page once page is loaded -->
     html, body, #javafx-app-placeholder, #ensemble-app {  
       margin: 0;  
       overflow: hidden;  
       padding: 0; 
       width: 100%;
       height: 100%; 
<body><div id="javafx-app-placeholder"></div></body>

Need Your Help

What's a solid, full-featured open rich text representation usable on the Web?

editor wysiwyg richtext

I'm looking for an internal representation format for text, which would support basic formatting (font face, size, weight, indentation, basic tables, also supporting the following features:

Store hash-like id in postgresql

sql postgresql normalization

I have a hash-like id from foursquare api. It is not numeric