go to previous page   go to home page   go to next page highlighting

Answer:

Yes. On an Apple, you will get an Apple window, on Microsoft you will get a Microsoft window, and on Linux you will get a Linux window.


Small Graphics Program

This program just shows a Stage with nothing in it. It is not a useful program. But it will get us started.

import javafx.application.*;
import javafx.stage.*;
 
public class TestFX extends Application
{
  public void start( Stage primaryStage )
  {
    primaryStage.show();
  }

  // Not needed for most systems
  public static void main( String[] args )
  {
    launch();
  } 
}

The static main() method is not needed for most system, but it does not hurt to include it. The Java system creates a window and passes a reference to it as a parameter to start(). The system picks a default size for the window. To run the program with the JDK (version 8 and above) do this:

C:\JavaCode\> javac TestFX.java
C:\JavaCode\> java  TestFX
         
     (program runs and displays a window)

     (user clicks on the close icon in the window)
     
C:\JavaCode\>     

You should see an empty window like this:

Window with nothing in it

The window remains on the screen until something is done to close it. To close the window and stop the program, click on the close button of the window, or hit control-C in the command-prompt window.

BlueJ: To run this program on BlueJ, create a project (as usual), create a class TestFX, and copy the above code into it. You can omit the main() method. Compile the class. Run by right-clicking on the class and selecting "Run JavaFX Application."


QUESTION 3:

When the program is running, can the user change the size of the window and drag it across the monitor screen?


go to previous page   go to home page   go to next page