
Quick Contact
Java Tutorial
- What is Java?
- History of Java
- Hello Java Program
- Features of Java
- Basic Syntax
- Java Setup
- Data Types in Java
- Java Variables
- Operators in Java
- JVM
- Java If-else Statement
- Switch Case Statement
- Java Loops
- Do-While Loop
- Java While Loop
- Continue Statement
- Break Statement in Java
- Constructors in Java
- Oops Concept in Java
- Features of OOPs
- Inheritance
- Exeception handeling
- Aggregation (HAS-A relationship) in Java
- Method Overriding in Java
- Method Overloading
- Java Static Keyword
- Java This Keyword
- Java Final Keyword
- Polymorphism
- Static Binding and Dynamic Binding
- Abstract class in Java
- Access Modifiers in Java
- Difference between abstract class and interface
- Interface in Java
- Garbage Collection in Java
- Java Package
- Encapsulation
- Serialization and Deserialization in Java
- Java Inner Classes
- Java Applets
- Multithreading in Java
- Thread Priorities in Java
- Thread Creation
- Inter Thread Communication
- Wrapper Classes in Java
- Java Input Output
- Java AWT Introduction
- Java Layout Manager
- Java Layout Policy
- Java AWT Events
- Collection Framework
- Collection Framework List Interface
- Swing in Java
- Swing Utility Classes
- Swing Layout Managers
- Java JDBC
- Hibernate Framework Overview – Architecture and Basics
Springboot
- Spring Environment Setup
- Spring Boot CRUD REST API Project using IntelliJ IDEA | Postman | MySQL
- Dockerizing Spring Boot Application | Spring Boot Docker Tutorial
- spring-boot-restapidocumentation with swagger
- Spring Boot HttpClient Overview
- Apache HttpClient POST HTTP Request Example
- Apache HttpClient PUT HTTP Request Example
- Apache HttpClient DELETE HTTP Request Example
- Apache HttpClient HTML Form POST Request Example
- Spring Boot JSP Exampl
- Deploying Spring Boot WAR file with JSP to Tomcat
- Spring Boot Annotations
- Spring Core Annotations
- Spring MVC Annotations with Examples
- Spring Scheduling Annotations
- Spring - Java-based Container Configuration
- Spring Java Based Configuration Example
Hibernate
- Hibernate 5 hello world
- Hibernate- One to One Unidirectional Mapping Annotation Example
- Hibernate - Batch Processing
- Hibernate - Interceptors
- Hibernate 5 - Create, Read, Update and Delete (CRUD) Operations Example
- Hibernate Transaction Management
- Hibernate One to Many Unidirectional Mapping Example
- Hibernate One to Many Bidirectional Mapping Example
- Hibernate Many to Many Annotation Mapping Example
- Hibernate Primary KeyJoin Column
- Hibernate First Level Cache with Example
- Hibernate XML Configuration Example with Maven + Eclipse + MySQL Database
- Hibernate Java Configuration Example
- JPA 2 with Hibernate 5 Bootstrapping Example
- JPA and Hibernate Cascade Types
- Hibernate/JPA - Primary Key Generation
- Hibernate 5 - Enum Type Mapping Example
- Hibernate Component Mapping
- Hibernate Object States – Transient,Persistent and Detached
- Hibernate 5 - Save an Entity Example
- Hibernate 5 - Persist an Entity Example
- Hibernate 5 - saveOrUpdate() Method Example
- Hibernate 5 - get(), load() and byId() Method Examples
- Hibernate 5 - merge() Example
- Hibernate 5 - Delete or Remove an Entity Example
- Hibernate 5 - load() Method Example
- Hibernate Session Interface Methods
- Hibernate Session.clear() Method Example
- Introduction Of Java strutes to Architecture
- Struts 2 - Architecture
- Struts 2 - Configuration Files
- Struts 2 - Actions
- Struts 2 - Interceptors
- Struts 2 - Results & Result Types
- Struts 2 - Value Stack/OGNL
- Struts 2 - File Uploading
- Struts 2 - Database Access
- Struts 2 - Validations Framework
JAVA FX
- JavaFX Tutorial
- Introduction to JavaFX Pane
- JavaFX Popup
- JavaFX group
- JavaFX Controller
- JavaFX Gradient Color
- JavaFXAnchorPane
- JavaFXTabPane
- JavaFX Scene
- JavaFX Stage
- JavaFXWebView
- JavaFX Timeline
- JavaFX Timer
- JavaFX Image
- JavaFX Background
- JavaFX dialog
- JavaFX Font
- JavaFXTextArea
- JavaFXObservableList
- JavaFX GUI
- JavaFX FXML
- JavaFXEventHandler
- JavaFXGradle
- JavafxScrollpane
- JavaFXAPI
JavaFXWebView
JavaFXWebView is used to show the web pages, that’s why the name webView here. It acts as a mini or a small browser that is able to represent the pages on the view. It is capable of showing CSS, HTML, and JAVASCRIPT code on the webView, inside the JavaFX application. To use this we need to import the library from the JavaFX while programming. In short, webView is used to render the web pages in the JavaFX application, It is very easy to use where we can show our different pages like news, blogs and also able to download them very fast. In the next section, we will discuss the WebView in detail.
Syntax:
To use WebView inside our JavaFX application we need to import the library into our program. As we know it is the part of JavaFX package. For more understating see the syntax below;
importjavafx.scene.web.WebView;
WebViewname_varible = new WebView();
As you can see in the above lines of code first we are importing the package in which webView is present after that we are creating an object of the webView simply using the ‘new’ keyword. Also this class available inside the JavaFX package only. Let’s see one practice syntax for beginners for a better understanding of the syntax see below;
importjavafx.scene.web.WebView;
WebViewmyview = new WebView();
// logic to call methods
Here we are just assigning the name for the variable and after this, we can call any method which is available inside the web view class to handle the web pages in JavaFX application
How JavaFXWebView works?
As now we know that WebView is used to show our web pages in the JavaFX application. This is very lightweight and can be easily used. By using this WebView we can render our HTML pages on the web view. This also supports CSS and JavaScript. This module is the node for the JavaFX application so we need to import this while using in the program. Also internally WebView uses a web-kit to render our web pages on the mini or a small browser. Let’s see and understand the internal working of the WebView node in JavaFX see below;
e.g. :
importjavafx.scene.web.WebView; String myText = "Demo to show internal working of webview"; WebViewmyview = new WebView(); myview.loadContent(myText, "file.html");
In the above lines of code, we are trying to show the text into the HTML file using WebView in JavaFX application. For this, we have created an instance of the WebView first after this e are calling loadContent() method of the WebView node in JavaFX to show the text on the HTML file. This loadContent() method takes 2 parameters inside it. First is the text that you want to show and another one is the file name on which we want to print this text. After this we can easily able to see our text on the HTML page.
Constructors
WebView is a node and in order to use this node, we need to have an object of this Class. After the object creation only we are able to use its method inside the program. Also in order to create the object in an object-oriented programming language, we need a constructor. In WebView w have only one constructor as the instance method for the WebView, by the use of it we can initialize it easily. Let’s discuss its usages in JavaFX application see below;
Syntax:
WebViewmyview = new WebView();
This is the default constructor or no parameter constructor in WebView to initialize the object of WebView. In order to create the object new use ‘new’ keyword here. After this we are able to access is methods and other variables present inside the WebView class.
Methods
JavaFXWebView provides a number of methods to deal with the web pages in JavaFX application. Let’s discuss each of the methods in detail which are as follows see below:
-
width:
This method is used to set the width for our webview.
-
maxHeight:
This method is used to set the maximum height for the webview node in JavaFX application.
-
height:
This method is used to set the height for the WebView node in JavaFX application.
-
maxWidth:
This method is used to set the maximum width for the WebView node in JavaFX application.
-
zoom:
This method is used to get the zoom object in webview.
-
prefWidth:
This method is used to set the preferred width for the WebView node in JavaFX application.
-
prefHeight:
This method is used to set the preferred height for the WebView node in JavaFX application.
-
min-width:
This method is used to set the minimum width for the WebView node in JavaFX application.
-
minHeight:
This method is used to set the minimum height for the WebView node in JavaFX application.
-
fontScale:
This method is used to specify the font scale for the font in WebView.
-
contextMenuEnabled:
This method used to check context menu is enabled or not.
Example of JavaFXWebView
In this example, we are creating a window and inside it, we are trying to open the google link. For this, we are using webview in JavaFX application.
import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.layout.VBox; import javafx.scene.web.WebView; import javafx.stage.Stage; import javafx.stage.Stage; import javafx.scene.web.WebEngine; public class DemoWebView extends Application { public static void main(String[] args) { launch(args); } public void demo (Stage mystage) { System.out.println("Demo for webview"); //webview object creation //web engine object creation WebViewmyview = new WebView(); // setting min height myview.minHeight(1050); // setting preferred width myview.prefWidth(1950); // setting prefheigth myview.prefHeight(1070); //setting min width myview.minWidth(1050); final WebEnginemywebEngine = webView.getEngine(); mywebEngine.load("http://www.google.com"); VBoxmybox = new VBox(webView); Scene myscene = new Scene(mybox, 960, 600); mystage.setScene(myscene); mystage.show(); } }
Apply now for Advanced Java Training Course