
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
JavaFX group
In JavaFX, a group is a container component that does not apply any special layout for the children. Here, every child component or node will be kept at the position 0,0. Normally, this group component is mainly used to put transformations or effects to a control set together-that is, as a group. Suppose a layout to the children that are available within the group; then it can be nested within the layout component and add them to the group. It is denoted by the javafx.scene.Group class.
Syntax
Below is the syntax of the Group component in JavaFX
Group group = new Group();
How does group work in JavaFX?
The main task in group creation is the addition of components to the group. It is done by getting the children’s list and adding them to it. For example, children can be added to the group, as shown below.
Button b1 = new Button("Button 1"); Button b2 = new Button("Button 2"); Group gp = new Group(); gp.getChildren().add(b1); gp.getChildren().add(b2);
Here, two buttons are created first. Then, after creating a group, children of those are retrieved, and they are all added to the group using the add() method.
Constructors
Following are the two constructors of the class.
-
Group():
A new group can be constructed.
-
Group(Collection c):
A new group can be constructed with the mentioned nodes.
-
Group(Node… c):
A new group can be constructed with the mentioned nodes.
Commonly Used Methods
Different commonly used methods are mentioned below:
-
getChildren()
The children of the particular group will be retrieved.
-
minHeight(double w)
The minimum height of the node will be returned for using the calculations of the layout.
-
minWidth(double h)
The minimum width of the node will be returned for using the calculations of the layout.
-
isAutoSizeChildren()
autoSizeChildren property’s value will be retrieved.
-
prefHeight(double w)
The group will define a preferred height as simply for being the layout bound height.
-
prefWidth(double h)
The group will define preferred width as simply for being the layout bound height.
-
setAutoSizeChildren()
autoSizeChildren property’s value will be set.
Examples
Different examples are mentioned below:
Example #1
JavaFX program to create two buttons with the help of a group.
Code:
import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.stage.Stage; //main class public class GroupProgram extends Application { //stasrt stage @Override public void start(Stage st) throws Exception { //set title st.setTitle("Sample"); //create button one Button bt = new Button("This is Button one"); //create button two Button btn = new Button("Button two"); //create group Groupgp = new Group(); //add children gp.getChildren().add(bt); gp.getChildren().add(btn); //create scene Scenesc = new Scene(gp, 200, 100); //set the scene st.setScene(sc); //display st.show(); } //main method public static void main(String[] args) { Application.launch(args); } }
Example #2
JavaFX program to create a circle using the group.
Code:
import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.stage.Stage; import javafx.scene.control.*; import javafx.scene.layout.*; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.canvas.*; import javafx.scene.web.*; import javafx.scene.shape.*; //main class public class GroupProgram extends Application { //start stage @Override public void start(Stage st) throws Exception { //set title st.setTitle("Sample"); //create a circle Circle c = new Circle(150, 150, 40); //create group Groupgp = new Group(); //add children gp.getChildren().add(c); //create scene Scenesc = new Scene(gp, 600, 400); //set the scene st.setScene(sc); //display st.show(); } //main method public static void main(String[] args) { Application.launch(args); } }
Example #3
JavaFX program to create a circle using a group with authorizing set as true.
Code
import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.stage.Stage; import javafx.scene.control.*; import javafx.scene.layout.*; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.canvas.*; import javafx.scene.web.*; import javafx.scene.shape.*; //main class public class GroupProgram extends Application { //start stage @Override public void start(Stage st) throws Exception { //set title st.setTitle("Sample"); //create a circle circle Circle c = new Circle(50, 50, 40); //create group Groupgp = new Group(); //add children gp.getChildren().add(c); // set auto resize gp.setAutoSizeChildren(true); //create scene Scenesc = new Scene(gp, 600, 400); //set the scene st.setScene(sc); //display st.show(); } //main method public static void main(String[] args) { Application.launch(args); } }
Example #4
JavaFX program to create a rectangle using the group.
Code:
import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.stage.Stage; import javafx.scene.effect.MotionBlur; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.scene.text.Font; import javafx.scene.text.FontWeight; import javafx.scene.text.Text; //main class public class GroupProgram extends Application { //start stage @Override public void start(Stage st) throws Exception { //set title st.setTitle("Sample"); //create rectangle Rectangle r = new Rectangle(); //set x value of rectangle r.setX(20); //set y value of rectangle r.setY(40); //set width of rectangle r.setWidth(170); //set height of rectangle r.setHeight(90); //fill the color as green r.setFill(Color.GREEN); //create a text Text t = new Text(); //set the text t.setText("Working . . "); //set the color t.setFill(Color.BLACK); //set the font t.setFont(Font.font("null", FontWeight.BOLD, 28)); //set the x value t.setX(35); //set the y value t.setY(75); //create group Groupgp = new Group(); //create a button Button b = new Button("Sample Button"); //set the cache as true gp.setCache(true); // MotionBlur effect MotionBlurmb = new MotionBlur(); // group effect setting gp.setEffect(mb); // Translation of x axis is as 50 gp.setTranslateX(50); //add the children to group gp.getChildren().addAll(r, b, t); //create scene Scenesc = new Scene(gp, 600, 400); //set the scene st.setScene(sc); st.show(); } //main method public static void main(String[] args) { Application.launch(args); } }
Apply now for Advanced Java Training Course