Introduction To AWT
Introduction To AWT
AWT stands for Abstract Windowing Toolkit. It contains all classes to write the program that interface
between the user and different windowing toolkits. You can use the AWT package to develop user
interface objects like buttons, checkboxes, radio buttons and menus etc.
We can use the AWT package to develop user interface objects like buttons, checkboxes, radio buttons
and menus etc.
1. AWT Components
The class component is extended by all the AWT components. More of the codes can be put
to this class to design lot of AWT components. Following are the AWT components:
i. Canvas
ii. Checkbox
iii. Label
iv. Scrollbar
v. TextField
1. ActionEvent
2. AdjustmentEvent
3. ComponentEvent
4. ContainerEvent
5. FocusEvent
6. InputEvent
7. ItemEvent
8. KeyEvent
9. MouseEvent
10. PaintEvent
11. TextEvent
12. WindowEvent
1. ActionEvent: This is the ActionEvent class extends from the AWTEvent class. It indicates the
component-defined events occurred i.e. the event generated by the component like Button,
Checkboxes etc. The generated event is passed to every EventListener objects that receives such
types of events using the addActionListener() method of the object.
2. AdjustmentEvent: This is the AdjustmentEvent class extends from the AWTEvent class.
When the Adjustable Value is changed then the event is generated.
3. ComponentEvent: ComponentEvent class also extends from the AWTEvent class. This class
creates the low-level event which indicates if the object moved, changed and it's states (visibility
of the object). This class only performs the notification about the state of the object. The
ComponentEvent class performs like root class for other component-level events.
4. ContainerEvent: The ContainerEvent class extends from the ComponentEvent class. This is
a low-level event which is generated when container's contents changes because of addition or
removal of a components.
5. FocusEvent: The FocusEvent class also extends from the ComponentEvent class. This class
indicates about the focus where the focus has gained or lost by the object. The generated event is
passed to every objects that is registered to receive such type of events using the
addFocusListener() method of the object.
6. InputEvent: The InputEvent class also extends from the ComponentEvent class. This event
class handles all the component-level input events. This class acts as a root class for all
component-level input events.
7. ItemEvent: The ItemEvent class extends from the AWTEvent class. The ItemEvent class
handles all the indication about the selection of the object i.e. whether selected or not. The
generated event is passed to every ItemListener objects that is registered to receive such types of
event using the addItemListener() method of the object.
8. KeyEvent: KeyEvent class extends from the InputEvent class. The KeyEvent class handles all
the indication related to the key operation in the application if you press any key for any
purposes of the object then the generated event gives the information about the pressed key. This
type of events check whether the pressed key left key or right key, 'A' or 'a' etc.
9. MouseEvent: MouseEvent class also extends from the InputEvent class. The MouseEvent
class handle all events generated during the mouse operation for the object. That contains the
information whether mouse is clicked or not if clicked then checks the pressed key is left or
right.
10. PaintEvent: PaintEvent class also extends from the ComponentEvent class. The PaintEvent
class only ensures that the paint() or update() are serialized along with the other events delivered
from the event queue.
11. TextEvent: TextEvent class extends from the AWTEvent class. TextEvent is generated when
the text of the object is changed. The generated events are passed to every TextListener object
which is registered to receive such type of events using the addTextListener() method of the
object.
12. WindowEvent : WindowEvent class extends from the ComponentEvent class. If the window or
the frame of your application is changed (Opened, closed, activated, deactivated or any other
events are generated), WindowEvent is generated.
Swing Features
import java.sql.*;
import java.sql.*;
import java.sql.*;
import java.sql.*;
JDBC- Statement
Once a connection is obtained we can interact with the database. The JDBC Statement,
CallableStatement, and PreparedStatement interfaces define the methods and properties that enable us
to send SQL or PL/SQL commands and receive data from our database. They also define methods that
help bridge data type differences between Java and SQL data types used in a database.
A statement object is used to send and execute SQL statements to a database.To execute SQL
statements, instantiate a Statement object from the connection object by using the createStatement()
method.
After creating a Statement object, use it to execute a SQL statement with one of its three execute
methods.
1. boolean execute(String SQL) : Returns a boolean value of true if a ResultSet object can be
retrieved; otherwise, it returns false. Use this method to execute SQL DDL statements or when
you need to use truly dynamic SQL.
2. int executeUpdate(String SQL) : Returns the numbers of rows affected by the execution of the
SQL statement. Use this method to execute SQL statements for which you expect to get a
number of rows affected - for example, an INSERT, UPDATE, or DELETE statement.
3. ResultSet executeQuery(String SQL) : Returns a ResultSet object. Use this method when you
expect to get a result set, as you would with a SELECT statement.
The following code segment creates a PreparedStatement object to select user data based on the user's
email address.