163 subscribers
3.42K photos
24 videos
39 files
371 links
Link: @java_posts

Contact: java.response.email@gmail.com
Download Telegram
Swing and SwingX
Swing is the primer framework of choice for building new GUI-based Java applications. Swing has a lot of rich UI components. Swing is the successor to AWT as it fixes and replaces many of its features with enhancing them by adding extra functionality. AWT has more comprehensive components than Swing

SwingX is based on the features of Swing and its main role is to create rich components for swing. It comprises some niche components; one such is such as TreeTable which can do sorting, filtering and searching. It also supports searching with a highlighting option.
SWT
SWT (Standard Widget Toolkit) was created by IBM for Eclipse IDE and is one of the Best Java GUI Frameworks. SWT uses the platform’s native widgets with the help of JNI. It is not related to Swing and AWT at all. It is said to be the alternate version of Swing.

SWT is created by IBM with the main purpose to create a native GUI. It is fast and can be run on the Eclipse IDE. When compared to Swing, it still requires native DLLs across different systems in use. Its users are decreasing day by day as more comprehensive Java GUI tools emerge in the market.
Java pinned «Chapter 4: Java GUI Programming 1. GUI Programming with AWT 2. Label 3. Examples 4. MouseEvent and MouseListener Interface 5. KeyEvent and KeyListener interface 6. Nested Classes 7. Adaptor Class Event Listeners 8. An Introduction to Swing 9. Content…»
Java
Chapter 5: Object-Oriented Programming 1. Why OOP ? 2. Java Constructor 3. Accessing Parent Class Variables 4. The Java OOP Concepts 5. Abstraction 6. Encapsulation 7. Polymorphism 8. Inheritance 9. Association 10. Aggregation 11. Composition 12.…
What is OOPs Concept ?
Object-oriented programming is a core of Java Programming, which is used for designing a program using classes and objects. OOPs, can also be characterized as data controlling for accessing the code. In this approach, programmers define the data type of a data structure and the operations that are applied to the data structure.
What is OOPs in Java ?
OOps in java is to improve code readability and reusability by defining a Java program efficiently. The main principles of object-oriented programming are abstraction, encapsulation, inheritance, and polymorphism. These concepts aim to implement real-world entities in programs.
List of OOPs Concepts in Java
* Object
* Classes
* Object
* Class
* Abstraction
* Inheritance
* Polymorphism
* Encapsulation
What are Objects ?
Objects are always called instances of a class which are created from a class in java or any other language. They have states and behaviour.

These objects always correspond to things found in the real world, i.e., real entities. So, they are also called run-time entities of the world. These are self–contained which consists of methods and properties which make data useful. Objects can be both physical and logical data. It contains addresses and takes up some space in memory. Some examples of objects are a dog, chair, tree etc.

When we treat animals as objects, it has states like colour, name, breed etc., and behaviours such as eating, wagging the tail etc.
Suppose, we have created a class called My book, we specify the class name followed by the object name, and we use the keyword new.
public class MyBook {
int x = 10;
Public static void main(String args[]) {
Mybook Myobj = new Mybook ();
System.out.println(MyObj.x);
}
}
In the above example, a new object is created, and it returns the value of x which may be the number of books.

Mybook Myobj= new Mybook ();

This is the statement used for creating objects.

System.out.println(Myobj.x);

This statement is used to return the value of x of an object.

We can also create multiple objects in the same class and we can create in one class and access it in another class. This method is used for better organization of classes and always remember that name of the java file and the class name remains the same.
Example 2:
The below example shows how multiple objects are created in the same class and how they are accessed from another class.
* Mybook.java
Public class Mybook {
int x=10;
int y=8;
}

* count.java
Class Count {
Public static void main(String[] args)
{
Mybook myobj1 = new myobj1();
Mybook myobj2 = new myobj2();
System.out.println(myobj1.x);
System.out.println(myobj2,y);
}
}
What are Classes ?
Classes are like object constructors for creating objects. The collection of objects is said to be a class. Classes are said to be logical quantities. Classes don’t consume any space in the memory. Class is also called a template of an object. Classes have members which can be fields, methods and constructors. A class has both static and instance initializers.

A class declaration consists of:

1. Modifiers: These can be public or default access.
2. Class name: Initial letter.
3. Superclass: A class can only extend (subclass) one parent.
4. Interfaces: A class can implement more than one interface.
5. Body: Body surrounded by braces, { }.
A class keyword is used to create a class. A simplified general form of the class definition is given below:

class classname {
type instance variable 1;
type instance variable 2;
.
.
.
type instance variable n;
type methodname 1 (parameter list) {
// body od method
}
type methodname 2 (parameter list) {
// body od method
}
type methodnamen(parameter list) {
// body od method
}
}
The variables or data defined within a class are called instance variables. Code is always contained in the methods. Therefore, the methods and variables defined within a class are called members of the class. All the methods have the same form as the main () these methods are not specified as static or public.
What is Abstract ?
Abstraction is a process which displays only the information needed and hides the unnecessary information. We can say that the main purpose of abstraction is data hiding. Abstraction means selecting data from a large number of data to show the information needed, which helps in reducing programming complexity and efforts.
There are also abstract classes and abstract methods. An abstract class is a type of class that declares one or more abstract methods. An abstract method is a method that has a method definition but not implementation. Once we have modelled our object using data abstraction, the same sets of data can also be used in different applications—abstract classes, generic types of behaviours and object-oriented programming hierarchy. Abstract methods are used when two or more subclasses do the same task in different ways and through different implementations. An abstract class can have both methods, i.e., abstract methods and regular methods.
Now let us see an example related to abstraction.

Suppose we want to create a student application and ask to collect information about the student.

We collect the following information.

Name
Class
Address
Dob
Fathers name
Mothers’ names and so on.
We may not require every information that we have collected to fill out the application. So, we select the data that is required to fill out the application. Hence, we have fetched, removed, and selected the data, the student information from large data. This process is known as abstraction in the oops concept.