Raja has Published 469 Articles

How can we detect the double click events of a JTable row in Java?

raja

raja

Updated on 11-Feb-2020 12:07:15

4K+ Views

A JTable is a subclass of JComponent for displaying complex data structures. A JTable can follow the Model View Controller (MVC) design pattern for displaying the data in rows and columns. A JTable can generate TableModelListener, TableColumnModelListener, ListSelectionListener, CellEditorListener and RowSorterListener interfaces. We can detect the double click events of a JTable by using a ... Read More

What is the importance of JViewport class in Java?

raja

raja

Updated on 11-Feb-2020 11:11:40

487 Views

JViewportA JViewport class defines the basic scrolling model and it is designed to support both logical scrolling and pixel-based scrolling.The viewport's child called the view is scrolled by calling JViewport.setViewPosition() method.A JViewport class supports logical scrolling, that is a kind of scrolling in which view coordinates are not pixels.To support a logical scrolling, JViewport defines a ... Read More

What is the importance of a SwingWorker class in Java?

raja

raja

Updated on 11-Feb-2020 10:36:25

792 Views

A SwingWorker class enables us to perform an asynchronous task in a worker thread (such as a long-running task) then update Swing components from the Event Dispatch Thread (EDT) based on the task results. It was introduced in Java 1.6 Version.SwingWorker classThe java.swing.SwingWorker class is a task worker, which performs time-consuming tasks in the ... Read More

What are the differences between a static block and a constructor in Java?

raja

raja

Updated on 11-Feb-2020 10:10:35

2K+ Views

Static blockThe static blocks are executed at the time of class loading.The static blocks are executed before running the main () method.The static blocks don't have any name in its prototype.If we want any logic that needs to be executed at the time of class loading that logic needs to placed inside the static ... Read More

How many types of anonymous inner classes are defined in Java?

raja

raja

Updated on 11-Feb-2020 09:26:32

1K+ Views

An anonymous inner class is an inner class which is declared without any class name at all. In other words, a nameless inner class is called an anonymous inner class. Since it does not have a name, it cannot have a constructor because we know that a constructor name is the ... Read More

How to instantiate member inner class in Java?

raja

raja

Updated on 11-Feb-2020 09:21:14

2K+ Views

A class that is declared inside a class but outside a method is known as member inner class.We can instantiate a member Inner class in two waysInvoked within the classInvoked outside the classRules for Inner ClassThe outer class (the class containing the inner class) can instantiate as many numbers of ... Read More

How to call an interface method in Java?

raja

raja

Updated on 11-Feb-2020 08:06:59

22K+ Views

In order to call an interface method from a java program, the program must instantiate the interface implementation program. A method can then be called using the implementation object.Examplepublic interface InterfaceDemo{     default public void displayNameDefault(String name){        System.out.println("Your name is : " + name);    } ... Read More

What are the main features and enhancements introduced in Java 9?

raja

raja

Updated on 11-Feb-2020 08:00:28

242 Views

Oracle has released Java 9 version with a rich set of new features and brings a lot of new enhancements.Below are a few important features and enhancements introduced in Java 9.Factory Methods for Collections: Factory methods are special kinds of static methods that can be used to create unmodifiable instances of collections, ... Read More

Can we declare a main method as private in Java?

raja

raja

Updated on 11-Feb-2020 07:49:21

5K+ Views

Yes, we can declare the main method as private in Java.It compiles successfully without any errors but at the runtime, it says that the main method is not public.Example:class PrivateMainMethod {    private static void main(String args[]){        System.out.println("Welcome to Tutorials Point");     } }The above code ... Read More

How to set Temporary and Permanent Paths in Java?

raja

raja

Updated on 11-Feb-2020 07:39:28

22K+ Views

There are two ways to set the path in java, First is Temporary Path and second is Permanent Path.Setting Temporary PathOpen command prompt in WindowsCopy the path of jdk/bin directory where java located (C:\Program Files\Java\jdk_version\bin)Write in the command prompt: SET PATH=C:\Program Files\Java\jdk_version\bin and hit enter command.Setting Permanent PathGo to My ... Read More

Advertisements