Sunday, January 14, 2024

Take input in Java easy tutorial

 

Input taking in Java tutorial






Download Link :

Download input taking in Java example code


Code:

  //ASSALAM o alaikum 
/*
	真主
     穆罕默德 真主啊,为我们的大师穆罕默德和他的家人祈祷与和平 77 85 72 65 77 77 65 68 32 
         83 104 97 104 122 97 105 98	
*/


import java.util.Scanner;   //////// Library/Package to take inputs in java


public class Input{


    public static void main(String[] args){
	
	
///////////////// Develop object of scanner class to use its methods further ///////////////////////
	  Scanner scanner = new Scanner(System.in);    
	  
	  System.out.print("Enter any string ");
	  
	  String stringInput= scanner.nextLine();      //////// scanner.nextLine() is used to take string input
	  
	  System.out.println("You entered " + stringInput);
	  
	  System.out.print("Enter any number ");
	  
	  int numberInput= scanner.nextInt();        /////////// scanner.nextInt() is used to take integer input
	  
	  System.out.println("You entered number " + numberInput);

	  System.out.print("Enter any float number ");

	  float floatInput= scanner.nextFloat();        /////////// scanner.nextFloat() is used to take float input
	  
	  System.out.println("You entered float number " + floatInput);
	  
	  
	
	}


}

  


Video Link :





Saturday, December 30, 2023

Develop custom browser with Java

 

Develop custom browser with Java




Download Link :

Download custom Java browser code


Code:

  //ASSALAM o alaikum 
/*
	真主
     穆罕默德 真主啊,为我们的大师穆罕默德和他的家人祈祷与和平 77 85 72 65 77 77 65 68 32 
         83 104 97 104 122 97 105 98	
*/


import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class Browser extends Application {

    @Override
    public void start(Stage primaryStage) {
        WebView webView = new WebView();
        WebEngine webEngine = webView.getEngine();
        webEngine.load("http://www.google.com");

             
        Button backButton = new Button("<-");
        backButton.setOnAction(e -> webEngine.executeScript("window.history.back()"));

        Button forwardButton = new Button("->");
        forwardButton.setOnAction(e -> webEngine.executeScript("window.history.forward()"));
		
		 Button refreshButton = new Button("R");
        refreshButton.setOnAction(e -> webEngine.reload());

        Button stopButton = new Button("Stop");
        stopButton.setOnAction(e -> webEngine.executeScript("window.stop()"));

        HBox hBox = new HBox(5);
        hBox.setAlignment(Pos.TOP_LEFT);
        hBox.getChildren().addAll( backButton, forwardButton,refreshButton, stopButton);

        BorderPane borderPane = new BorderPane();
		// Add padding to the top area:
        borderPane.setPadding(new Insets(10, 0, 0, 0)); // 10 pixels top padding
        borderPane.setTop(hBox);
        borderPane.setCenter(webView);

        Scene scene = new Scene(borderPane, 1200, 800);

        primaryStage.setTitle("JavaFX WebView Google Search");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}


  


Video Link :










Saturday, November 25, 2023

Constant texture scale with different object size in unity

 

Texture stretching issue solution in unity




Download Link :

Download Dynamic texture scale script


Code:

  //ASSALAM o alaikum 
/*
	真主
     穆罕默德 真主啊,为我们的大师穆罕默德和他的家人祈祷与和平 77 85 72 65 77 77 65 68 32 
         83 104 97 104 122 97 105 98	
*/
using UnityEngine;

[ExecuteInEditMode]
public class DynamicTextureTiling : MonoBehaviour
{
    // Reference to the original material with the texture
     Material originalMaterial;

    void Start()
    {
        // Ensure we have a material
        originalMaterial = GetComponent Renderer>().material;

        // Create a new material instance for this object
        Material materialInstance = new Material(originalMaterial);

        // Apply the new material to the object
        GetComponent Renderer> ().material = materialInstance;

        // Get the initial scale of the object
        Vector3 initialScale = transform.localScale;

        // Set the texture tiling based on the initial scale
        SetTextureTiling(materialInstance, initialScale);
    }

    void Update()
    {
        // Adjust texture tiling based on the current scale
        SetTextureTiling(GetComponent Renderer>().material, transform.localScale);
    }

    void SetTextureTiling(Material material, Vector3 scale)
    {
        // Calculate tiling based on the scale
        Vector2 tiling = new Vector2(scale.x, scale.z);

        // Apply tiling to the material
        material.mainTextureScale = tiling;
    }
}


  


Video Link :





Take input in Java easy tutorial

  Input taking in Java tutorial Download Link : Download input taking in Java example code ...