AWT stands for Abstract Window Toolkit. AWT enables programmers to develop Java applications with GUI components, such as windows, and buttons.
JFC stands for Java Foundation Classes. The Java Foundation Classes (JFC) are a set of Java class libraries created as part of Java 2 Platform, Standard Edition (J2SE) to support building graphics user interface (GUI) and graphics functionality for client applications.
Differentiate between Swing and AWT?
AWT is heavy-weight components, but Swing is light-weight components. AWT is OS dependent because it uses native components, But Swing components are OS independent. We can change the look and feel in Swing which is not possible in AWT. Swing takes less memory compared to AWT. For drawing AWT uses screen rendering where Swing uses double buffering.
Define heavyweight components ?
A heavyweight component is that is associated with its own native screen resource.
Define lightweight component?
A lightweight component is that who "borrows" the screen resource of an ancestor.
Define double buffering ?
Double buffering is the process of use of two buffers rather than one to temporarily hold data being moved to and from an I/O device.
Define an event?
Changing the state of an object is called an event.
Define an event handler ?
It is a part of a computer program created to say the program how to act in response to a specific event.
Define a layout manager?
It is an object that is used to organize components in a container.
it is the process of confining paint operations to a limited area or shape.
Which containers use a border Layout as their default layout?
Window, Frame and Dialog classes.
What is the preferred size of a component?
It is the minimum component size that will grant the component to display normally.
Which method is used to define a container's layout?
The setLayout() method .
Which containers use a FlowLayout as their default layout?
The Panel and Applet classes .
Differentiate between invokeAndWait() and invokeLater()?
A invokeAndWait is synchronous. It blocks until Runnable task is complete. InvokeLater is asynchronous. It posts an action event to the event queue and returns immediately. It will not wait for the task to complete
An Applet is a java program that runs within a web browser.
Differentiate between applications and applets?
A Application must be run explicitly within Java Virtual Machine whereas applet loads and runs itself automatically in a java-enabled browser. Application starts execution with its main method whereas applet starts execution with its init method. Application can run with or without graphical user interface whereas applet must run within a graphical user interface.
When we should go for codebase in applet?
If the applet class is not in the same directory.
Define lifecycle of an applet?
- init( ) method
- start( ) method
- paint( ) method
- stop( ) method
- destroy( ) method
Which method is used for setting security in applets?
A setSecurityManager method is used to set the security in applets.
Define event and what are the models available for event handling?
Changing the state of an object is called an event. An event is an event object that describes a state of change.
Define advantages of the event-delegation model over the event-inheritance model?
a) Event delegation model enables event handling by objects other than the ones that generate the events. b) It performs much better in applications where many events are generated. \
Define source and listener ?
A source is an object that generates an event.This occurs when the internal state of that object changes in some way. A listener is an object that is notified when an event occurs.
Define controls and what are different types of controls in AWT?
A Controls are components that allow a user to interact with your application. AWT supports the following types of controls: Labels, Push Buttons, Check Boxes, Choice Lists, Lists, Scrollbars, Text Components.
Differentiate between choice and list?
A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices and only one item may be selected from a choice. A List may be displayed in such a way that several list items are visible and it supports the selection of one or more list items.
Differentiate between scrollbar and scrollpane?
A Scrollbar is a Component, but not a Container whereas Scrollpane is a Container and handles its own events and perform its own scrolling.