Abstract Class ComponentAdapter in Java

0
208
Spread the love
  • 29
  • 34
  • 56
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    166
    Shares

Abstract Class ComponentAdapter in Java:

ComponentAdapter class is an implementation of ComponentListener interface containing empty bodies of each methods of the ComponentListener interface. If we do not wish to write every methods of ComponentListener interface in our class,ComponentAdapter class helps in that aspect.

ComponentAdapter is a class that implements the methods of ComponentListener with empty functions. It may be easier for us to extend ComponentAdapter, overriding only those methods we are interested in than to implement ComponentListener and provide the empty functions ourselves.

The structure of abstract class ComponentAdapter is given as:

public abstract class java.awt.event.ComponentAdapter  extends java.lang.Object implements  java.awt.event.ComponentListener{
//constructor
public ComponentAdapter();
//methods
public void componentHidden(ComponentEvent e);
public void componentMoved(ComponentEvent e);
public void componentResized(ComponentEvent e);
public void componentShown(ComponentEvent e);
} 

The details of the class structure are given as follows:

public void componentHidden(ComponentEvent e);

public void componentHidden(ComponentEvent e) method actually does nothing.We need to override this function to be notified when a component is hidden.

Parameter
e – The event that has occurred.

public void componentMoved(ComponentEvent e);

public void componentMoved(ComponentEvent e) method actually does nothing.We need to override this function to be notified when a component is moved.

Parameter
e – The event that has occurred.

public void componentResized(ComponentEvent e);

public void componentResized(ComponentEvent e) method actually does nothing.We need to override this function to be notified when a component is resized.

Parameter
e – The event that has occurred.

public void componentShown(ComponentEvent e);

public void componentShown(ComponentEvent e) method actually does nothing.We need to override this function to be notified when a component is shown.

Parameter
e – The event that has occurred.

Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 29
  • 34
  • 56
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    166
    Shares

LEAVE A REPLY

Please enter your comment!
Please enter your name here