Java Interview Questions On Applet and Swing |
25. What is the advantage of the event-delegation model over the earlier event-inheritance model?
Answer
The event-delegation model has two advantages over the event-inheritance model. First, it enables event handling to be handled by objects other than the ones that generate the events (or their containers). This allows a clean separation
between a component's design and its use. The other advantage of the event-delegation model is that it performs much better in applications where many events are generated. This performance improvement is due to the fact that the event-delegation model does not have to repeatedly process unhandled events, as is the case of the event-inheritance
model. |
26. How can a GUI component handle its own events?
Answer
A component can handle its own events by implementing the required event-listener interface and adding itself as its own event listener. |
27. How are the elements of a GridBagLayout organized?
Answer
The elements of a GridBagLayout are organized according to a grid. However, the elements are of different sizes and may occupy more than one row or column of the grid. In addition, the rows and columns may have different sizes |
28. What advantage do Java's layout managers provide over traditional windowing systems?
Answer
Java uses layout managers to lay out components in a consistent manner across all windowing platforms. Since Java's layout managers aren't tied to absolute sizing and positioning, they are able to accomodate platform-specific differences among windowing systems. |
29. What is the difference between a Choice and a List?
Answer
A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices. Only one item may be selected from a Choice. A List may be displayed in such a way that several List items are visible. A List supports the selection of one or more List items |
30. What Checkbox method allows you to tell if a Checkbox is checked?
Answer
getState() |
31. What is the purpose of the enableEvents() method?
Answer
The enableEvents() method is used to enable an event for a particular object. Normally, an event is enabled when a listener is added to an object for a particular event. The enableEvents() method is used by objects that handle events by overriding their event-dispatch methods. |