-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainClass
81 lines (60 loc) · 2.16 KB
/
mainClass
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package sample;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import java.util.Optional;
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
FXMLLoader loader = new
FXMLLoader(getClass().getResource("sample.fxml"));
VBox rootNode = loader.load();
Scene scene = new Scene(rootNode);
primaryStage.setScene(scene);
primaryStage.setTitle("Temperature converter tool");
MenuBar menuBar=createmenu();
rootNode.getChildren().add(0,menuBar);
primaryStage.show();
}
private MenuBar createmenu(){
Menu filemenu=new Menu("File");
MenuItem newMenuItems=new MenuItem("New");
MenuItem exitMenuItems=new MenuItem("Exit");
SeparatorMenuItem separatorMenuItems=new SeparatorMenuItem();
filemenu.getItems().addAll(newMenuItems, separatorMenuItems,exitMenuItems);
exitMenuItems.setOnAction(event ->{
Platform.exit();
System.exit(0);
});
newMenuItems.setOnAction(event ->System.out.println("new menu item is clicked"));
Menu help=new Menu("Help");
MenuItem about=new MenuItem("about developer");
help.getItems().addAll(about);
about.setOnAction(event -> aboutapp());
MenuBar menuBar=new MenuBar();
menuBar.getMenus().addAll(filemenu,help);
return menuBar;
}
private void aboutapp() {
Alert alertDialog=new Alert(Alert.AlertType.INFORMATION);
alertDialog.setTitle("MY FIRST DESKTOP APP");
alertDialog.setHeaderText("LEARNING JAVA FX");
alertDialog.setContentText("(DEVELOPER---> SONU KUMAR KUSHWAHA)This Is My First Desktop Application ,As I Am A Beginner,Soon I Will Be An Expert In Java fx ");
ButtonType yb=new ButtonType("YES");
ButtonType nb=new ButtonType("NO");
alertDialog.getButtonTypes().setAll(yb,nb);
Optional<ButtonType> ClickedBtn=alertDialog.showAndWait();
if(ClickedBtn.isPresent() && ClickedBtn.get()==yb){
System.out.println("yes button clicked");
}else{
System.out.println("no button clicked");
}
}
}