Found 9150 Articles for Object Oriented Programming

How to add LCD (liquid crystal display) to text in JavaFX?

Maruthi Krishna
Updated on 16-May-2020 05:47:16

273 Views

The javafx.scene.text.Text class has a property named fontSmoothingType, which specifies the smoothing type of the text. You can set the value to this property using the set setFontSmoothingType() method accepts two parameters −FontSmoothingType.GRAY − This specifies the default grayscale smoothing.FontSmoothingType.LCD − This specifies the LCD smoothing. This uses the characteristics of an LCD display and enhances the smoothing of the node.To add an LCD display to a text −Create a text node by instantiating the javafx.scene.text.Text class.Create a required font using one of the font() methods of the javafx.scene.text.Font class.Set the font to the text using the setText() method.Set the ... Read More

How to add custom fonts to a text in JavaFX?

Maruthi Krishna
Updated on 16-May-2020 05:44:24

8K+ Views

You can set the desired font to the text node in JavaFX using the setFont() method. This method accepts an object of the class javafx.scene.text.Font.The Font class represents the fonts in JavaFX, this class provides several variants of a method named font().as shown below −font(double size) font(String family) font(String family, double size) font(String family, FontPosture posture, double size) font(String family, FontWeight weight, double size) font(String family, FontWeight weight, FontPosture posture, double size)All these methods are static and returns a Font object. To set a font you need to create the font object using one of these methods and set the ... Read More

How to redirect to another webpage with JavaScript?

AmitDiwan
Updated on 12-May-2020 13:56:13

2K+ Views

To redirect to another webpage using JavaScript, the code is as follows −Example Live Demo Redirect to a Webpage Example Redirect Click the above button to Redirect to another Webpage    document .querySelector(".redirectBtn") .addEventListener("click", redirectFunction);    function redirectFunction() {       location.href("https://tutorialspoint.com/");    } OutputThe above code will produce the following output −On clicking the “Redirect” button we will be redirected to a new site −

How to create a speed converter with HTML and JavaScript?

AmitDiwan
Updated on 12-May-2020 13:49:56

329 Views

To create a speed converter with HTML and JavaScript, the code is as follows −Example Live Demo    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    input, span {       font-size: 20px;    } Speed Converter Type speed in Kilometer per hour to convert it into meter per hour Kilometer Per Hour Meters Per second:    function KmphtoMphConverter(speed) {       document.querySelector(".metersPerSecond").innerHTML = speed * 0.277778;    } OutputThe above code will produce the following output −On entering some speed in kph −

How to create a length converter with HTML and JavaScript?

AmitDiwan
Updated on 12-May-2020 13:47:55

1K+ Views

To create a length converter with HTML and JavaScript, the code is as follows −Example Live Demo    body{       font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;    }    input,span{       font-size: 20px;    } Length Converter Type length in Kilometers to convert it into meters Kilometers Meters:    function KmtoMConverter(length) {       document.querySelector(".meters").innerHTML=length*1000;    } OutputThe above code will produce the following output −On entering length in kilometers −

How to create a temperature converter with HTML and JavaScript?

AmitDiwan
Updated on 12-May-2020 13:43:48

759 Views

To create a temperature converter with HTML and JavaScript, the code is as follows −Example Live Demo    body{       font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;    }    input,span{       font-size: 20px;    } Temperature Converter Type Temperature in celcius to convert it into fahrenheit Celcius Fahrenheit:    function CtoFConverter(temp) {       document.querySelector(".fahrenheit").innerHTML=(temp-32)/1.8;    } OutputThe above code will produce the following output −On entering temperature in celcius −

How to create a weight converter with HTML and JavaScript?

AmitDiwan
Updated on 12-May-2020 13:41:39

376 Views

To create a weight converter with HTML and JavaScript, the code is as follows −Example Live Demo    body{       font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;    }    input,span{       font-size: 20px;    } Weight Converter Type weight in kg to convert it into grams Kilogram Grams:    function KgtoGConverter(weight) {       document.getElementById("outputGrams").innerHTML=weight*1000;    } OutputThe above code will produce the following output −On typing some weight in KGs −

How to create and use a Syntax Highlighter with JavaScript?

AmitDiwan
Updated on 12-May-2020 12:23:53

281 Views

To create and use syntax highligher, the code is as follows −Example Live Demo    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .colorLinks {       color: rgb(131, 44, 212);       text-decoration: none;       font-size: 20px;       font-weight: bold;    }    .setColor {       margin: 20px;       padding: 10px;       border: none;       font-size: 18px;       background-color: rgb(226, 43, 89);       color: white;    } Syntax Highlighting example Go to google.com Go to facebook.com Click Here Click the above button to highlight the links    var anchrorRg = /[^

How to use media queries with JavaScript?

AmitDiwan
Updated on 12-May-2020 12:21:04

340 Views

To use media queries with JavaScript, the code is as follows −Example Live Demo    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;       color: white;       padding: 20px;    } Using media queries with JavaScript Example Resize the screen to see the color change from blue to red    var mediaQuery = window.matchMedia("(max-width: 700px)");    function setColor(mediaQuery) {       if (mediaQuery.matches) {          document.body.style.backgroundColor = "red";       } else {          document.body.style.backgroundColor = "blue";       }    }    setColor(mediaQuery);    mediaQuery.addListener(myFunction); OutputThe above code will produce the following output on window size greater than 700px −On resizing the browser window size less than 700px −

How to create a draggable HTML element with JavaScript and CSS?

AmitDiwan
Updated on 12-May-2020 12:18:05

629 Views

To create a draggable HTML element with JavaScript and CSS, the code is as follows −Example Live Demo    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .dragDiv {       position: absolute;       z-index: 9;       text-align: center;       border: 1px solid #d3d3d3;       padding: 30px;       cursor: move;       z-index: 10;       background-color: rgb(108, 24, 177);       color: #fff;       font-size: 20px;       font-weight: 500;    } ... Read More

Advertisements