How do you use WindowListener?
How do you use WindowListener?
Methods of WindowListener interface
- public abstract void windowActivated (WindowEvent e);
- public abstract void windowClosed (WindowEvent e);
- public abstract void windowClosing (WindowEvent e);
- public abstract void windowDeactivated (WindowEvent e);
- public abstract void windowDeiconified (WindowEvent e);
What is a WindowListener?
Window listeners are commonly used to implement custom window-closing behavior. For example, a window listener is used to save data before closing the window, or to exit the program when the last window closes.
Which of the following interface is implemented for WindowEvent?
Interface WindowListener. The listener interface for receiving window events. The class that is interested in processing a window event either implements this interface (and all the methods it contains) or extends the abstract WindowAdapter class (overriding only the methods of interest).
Which method used to register window listener?
addWindowListener() method
The class which processes the WindowEvent should implement this interface. The object of that class must be registered with a component. The object can be registered using the addWindowListener() method.
What is setBounds in Java Swing?
What is the use of setBounds() method in Java? The setBounds() method is used in such a situation to set the position and size. To specify the position and size of the components manually, the layout manager of the frame can be null.
What is WindowAdapter in Java?
The class WindowAdapter is an abstract (adapter) class for receiving window events. All methods of this class are empty. This class is convenience class for creating listener objects.
What are the types of controls supported by the AWT?
The AWT supports the following types of controls:
- Labels.
- Push buttons.
- Check boxes.
- Choice lists.
- Lists.
- Scroll bars.
- Text Area.
- Text Field.
When list item is double clicked which event is generated?
Action event
Explanation: Action event is generated when a button is pressed, a list item is double-clicked or a menu item is selected. 2.
Which listener handles all list related events?
The Event listener represent the interfaces responsible to handle events.
Why setBounds () method is used?
setBounds is used to define the bounding rectangle of a component. This includes it’s position and size. The is used in a number of places within the framework. It is used by the layout manager’s to define the position and size of a component within it’s parent container.
What is the use of GridLayout in Java?
java file. A GridLayout object places components in a grid of cells. Each component takes all the available space within its cell, and each cell is exactly the same size.
What is an adapter class with an example?
9 Answers. Adapter is a pattern that provides default (often empty) implementation of interface or abstract class. For example MouseAdapter provides empty implementation of MouseListener interface.