View on GitHub

CC

CC practice and cheat sheets

Java Fx

​```java import javafx.application.Application; import javafx.stage.Stage; public class demo extends Application{ public static void main(String args[]){

}
@Override
public void start(Stage primaryStage)throws Exception }   ```
Function Available
primaryStage.show();
primaryStage.setScene(val);
primaryStage.setTitle(val);
primaryStage.getTitle();
primaryStage.setWidth(val);
primaryStage.setHeight(val);
primaryStage.getWidth();
primaryStage.getHeight();
primaryStage.setFullScreen(true);
primaryStage.isFullScreen();
primaryStage.close();

Events in Java

Java has a wide variety of events, most common of which are ActionEvent

import javafx.event.ActionEvent;
import javafx.event.EventHandler;

We define an action event callback as follows :

EventHandler<ActionEvent> event = new EventHandler<ActionEvent>() {

            public void handle(ActionEvent e) {
                System.out.println("Hello World");
            }
        };

We then call our JavaFx object and register this callback

Button btn = new Button("Click Me") ;
btn.setOnAction(event);