Categories bo’limidan JavFX ni tanlaymiz va Projects bolimidan
JavaFX Applicationni tanlaymiz va
Next ni bosamiz va Keyingi oyna ochiladi.
Bu oynada proktini nomini kiritamiz, joylashuvini tanlaymiz va Finish
tugmasini bosamiz va datur kodi yozish oynasi ochiladi.
Java FX da oddiy Salom Dunyo so’zini chiqaruvchi dastur kodini yozib
ko’ramiz. Dastur kodi quyidagicha.
package javafxapplication2;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
/**
*
* @author Mahmud
*/
public class JavaFXApplication2 extends Application {
@Override
public void start(Stage primaryStage) {
Button btn = new Button();
btn.setText("Say 'Salom Dunyo!'");
btn.setOnAction(new EventHandler() {
@Override
public void handle(ActionEvent event) {
System.out.println("Salom Dunyo!");
}
});
StackPane root = new StackPane();
root.getChildren().add(btn);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Salom Dunyo!");
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* @param args
the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
Natijasini ko’rish uchun Run buyrug’ini bosiladi yoki klaviaturadn F6
tugmasi bosilsa ham bo’ladi.
Do'stlaringiz bilan baham: