Introduction To Javafx
Introduction To Javafx
Introduction To Javafx
Why JavaFX
// TODO Auto-generated method stub Scene scene=new Scene(root,400,300);
ToggleGroup group = new ToggleGroup(); primaryStage.setScene(scene);
RadioButton button1 = new RadioButton("option 1"); primaryStage.setTitle("Radio Button Example");
RadioButton button2 = new RadioButton("option 2"); primaryStage.show();
}
}
package application; //Handling KeyEvent for textfield 1
import javafx.application.Application; tf1.setOnKeyPressed(new EventHandler<KeyEvent>()
import javafx.event.EventHandler; {
import javafx.scene.Group; @Override
import javafx.scene.Scene; public void handle(KeyEvent key) {
import javafx.scene.control.TextField; // TODO Auto-generated method stub
import javafx.scene.input.KeyEvent; tf2.setText("Key Pressed :"+" "+key.getText());
import javafx.scene.paint.Color; }
import javafx.stage.Stage; });
public class JavaFX_KeyEvent extends Application{ //setting group and scene
@Override Group root = new Group();
public void start(Stage primaryStage) throws Exception { root.getChildren().addAll(tf2,tf1);
// TODO Auto-generated method stub Scene scene = new Scene(root,500,200,Color.WHEAT)
;
//Creating TextFields and setting position for them
primaryStage.setScene(scene);
TextField tf1 = new TextField();
primaryStage.setTitle("Handling KeyEvent");
TextField tf2 = new TextField();
primaryStage.show();
tf1.setTranslateX(100);
}
tf1.setTranslateY(100);
public static void main(String[] args) {
tf2.setTranslateX(300);
launch(args); } }
tf2.setTranslateY(100);
}
Layout Panes
JavaFX provides many types of panes for organizing
nodes in a container.
15