- 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
- 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
- Exeception handeling
- Aggregation (HAS-A relationship) in Java
- Method Overriding in Java
- Method Overloading
- Java Static Keyword
- Java This Keyword
- Java Final Keyword
- 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
- 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
- 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 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
- JavaFX Tutorial
- Introduction to JavaFX Pane
- JavaFX Popup
- JavaFX group
- JavaFX Controller
- JavaFX Gradient Color
- JavaFX Scene
- JavaFX Stage
- JavaFX Timeline
- JavaFX Timer
- JavaFX Image
- JavaFX Background
- JavaFX dialog
- JavaFX Font
- JavaFX GUI
- JavaFX FXML
While adding components to a containers, one important issue is related to the position and size of the component. The components position can be specified in two ways.
In absolute positioning, we specify the exact location at which the component should be added. This method gives us fine control and may be the best choice if we design the GUI for just one platform.
For example, a component can be added in middle of container along horizontal direction, by specifying the co-ordinates of top-left corner of the component.
We can calculate these co-ordinates based on the container width and the component width. But the component will not be left in the middle. If the container width changes or the size of the component changes.
The other approach, relative positioning, may not allow us to specify the exact location of the components but may be suitable in the situation where we want that the component should always be in the middle of the container along the horizontal direction.
We can achieve this by specifying the relative position of the component like left, right, center etc. it is very common to center headings in documents using word processors. The headings remain centered even if the width of the page changes this is an example or relative positioning.
In java it is possible to use absolute positioning but it is not advisable. The AWT is designed to use relative positioning. We can specify component layouts with relative specifications, such as the component will be added to the right of the previous component, the component will be added below some other component, the component will appear at top, size of the component will be ¼th of the container width etc. such specifications are useful even without knowledge of component sizes.
Java encourages relative positioning because it is platform independent and the same GUI should work on a wide variety of platforms without modifications.
Built-in java classes called layout managers handle the task of mapping relative positions to actual/physical positions. Java supports many types of layout managers, we will discuss about following layout mangers.
Two Observations when working with layout managers:
- We do not have to bear the burden of specifying the exact position and dimension of each component.
- We no longer had the power to specify the exact position and dimensions of each component.
Why Java uses layout managers?
There are two reasons:
The theory lies in the position that precise layout (that is, specification in pixels of each component’s size and position) is a repetitious and often performed task; therefore, according to OOP’s layout functionality ought to be encapsulated into one or more classes to automate the task.
Certainly the layout managers eliminate a lot of development tedious. Many programmers dislike the idea of layout managers first, but come to appreciate them more and more as tedious choices are eliminated.
The practical reason for having layout manager stems from java’s platform independence. In java, AWT components borrow their behavior from the window system of the underlying hardware on which the JVM is running.
Thus on a Macintosh, an AWT buttons tools like any other Mac button; on a motif platform, a java button looks like any other motif button, and so on. The problem here is that buttons and other components have different sizes when instantiated on different platforms.
If java encouraged precise pixel-level sizing and positioning, there would be lot of java GUI’s that looked exquisite on their platform of origin and terrible or even unusable, on other platforms.
Apply now for Advanced Java Training Course