Skip to content

Latest commit

 

History

History
83 lines (62 loc) · 2.39 KB

README.md

File metadata and controls

83 lines (62 loc) · 2.39 KB

temperature-converter-tool

It was the part of mine training (Internshala) Java App Development. which is the basic application that converts the temperature as per users choise ie from degree celsius into fahrenheit and vice versa . 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");
	}

}

}