Java Swing Presentation
Presented to
Manisha Dey, Lecturer, Dept. of Computer Science & Engineering, Mymensingh Engineering College
Presented by
Susmoy Paul Soysob, Sheikh Jami Jashim, Md.Masudur Rahman, Mahfuja Khatun Trisha, MD Shakil Anower Samrat, Izaz Uddin Mahmud.
Students of Dept. of Computer Science & Engineering, Mymensingh Engineering College.
Topics:
Introduction to
Java Swing
Java Swing Class
JListener
Swing Apps
Database
Collected Data from these Sources:
https://www.coursehero.com/
https://celiksoftware.blogspot.com/
https://www.aasansolution.in/
https://cljdoc.org/
https://www.simplilearn.com/
2. Team Members
2
Md.Masudur Rahman
Class Roll:305
Reg. No:2848
Susmoy Paul Soysob
Class Roll:302
Reg. No:2845
Sheikh Jami Jashim
Class Roll:304
Reg.No:2847
Mahfuja Khatun Trisha
Class Roll:306
Reg. No:2849
MD Shakil Anower
Samrat
Class Roll:307
Reg.No:2850
Izaz Uddin
Mahmud
Class Roll:308
Reg.No:2851
5. What is Java Swing?
❝ Java Swing is a combination
of programming components
that provides the ability to
create graphical user
interface(GUI) components. ❞
5
8. ➢ Jcomponent is one of the classes of Java Swing.
JComponent is the base class of all Swing
components except top-level containers. There are
some classes in JComponent. Ex- JFrame,
JPanel, JList etc.
8
Java Swing Class :
10. 10
Some Programs using Java Swing Class
Example 1:
import javax.swing.JOptionPane;
public class ShowMessageDialog {
public static void main(String[] args)
{
JOptionPane.showMessageDialog(null,"java swing class");
}
}
Output
11. 11
Example 2:
import javax.swing.JOptionPane;
public class JavaApplication {
public static void main(String[] args)
{
JOptionPane.showMessageDialog(null,"Correct Password","Warning", JOptionPane.ERROR_MESSAGE);
}
}
Output
13. In Java, an event listener is designed to process some kind of
event - it “listens” for an event ,such as a user’s mouse click
or key press,and then it responds accordingly as shown in
figure.
13
JListener :
14. JListener can be categorized by these parts:
❖ ActionListener
❖ ItemListener
❖ KeyListener
❖ FocusListener
❖ WindowListener
❖ ChangeListener
18. Layout Managers are used to organize elements in a specific order. The
Java Layout Managers allow us to customize the location and size of GUI
form components. LayoutManager is an interface that is implemented by
all layout manager classes.
The layout managers are represented by the following classes:
● BorderLayout
● FlowLayout
● GridLayout
● CardLayout
● GridBagLayout
● BoxLayout
● GroupLayout
● ScrollPaneLayout
● SpringLayout
Layout Managers:
19. The BorderLayout is used to organize the components into five regions:
north, south, east, west, and center. Each region (area) can only have one
component. It is the default layout of a frame or window. The BorderLayout
gives five constants for each region:
BorderLayout:
22. The Java GridLayout class is used to organize the components in a
rectangular grid. Each rectangle contains one component.
GridLayout:
23. The Java FlowLayout class is used to organize the components one after the
other in a line (in a flow). It is the panel's default layout.
FlowLayout:
24. The Java BoxLayout class is used to organize the components vertically or
horizontally.
BoxLayout:
25. The Java CardLayout class organizes the components such that only one is
shown at a time. It considers each component as a card, thus the name
CardLayout.
CardLayout:
26. The Java GridBagLayout class is used to organize components vertically,
horizontally, or along their baseline. The components may not be the same
size. Each GridBagLayout object maintains a dynamic, rectangular grid of
cells. Each component has one or more display cells.
GridBagLayout:
27. GroupLayout organizes its components and arranges them in a Container
structure. Instances of the Group class do the grouping.
GroupLayout:
28. A SpringLayout organizes the children of the container with which it is
connected according to a set of constraints. Constraints are just the
horizontal and vertical distances between the edges of two components. A
Constraint object represents each constraint.
SpringLayout:
29. ScrollPane utilizes the layout manager. ScrollPaneLayout is in control of nine
components: a viewport, two scrollbars, a row header, a column header, and
four "corner" components.
ScrollPaneLayout:
31. Swing Apps
There are so many uses of Java Swing. We can create
application softwares using Java Swing.
In addition, Java Swing is a lightweight Java GUI widget
toolkit that includes a rich set of widgets.
31
32. Java Swing Applications:
Some Application Softwares using Java Swing are following :
● Calendar
● Calculator
● Multiplication Table
● Vowel Counter
● Student Management
● E-HealthCare Management
● Notepad
● Guessing Game
32
34. Database
JDBC(Java Database Connectivity) is a tool or an
application programming interface that establishes a
connection between a standard database and java application
that intends to use that database.
34
35. JDBC’s architecture :
The JDBC interface consists of two layers:
1. The JDBC API supports communication between the
Java application and the JDBC manager.
2. The JDBC driver supports communication between the
JDBC manager and the database driver.
36. Simple database connections and queries:
The steps for connecting to a database with JDBC
are as follows:
1. Install or locate the database you want to access.
2. Include the JDBC library.
3. Ensure the JDBC driver you need is on your classpath.
4. Use the JDBC library to obtain a connection to the
database.
5. Use the connection to issue SQL commands.
6. Close the connection when you are finished.
Good Afternoon, I am Shakil Anower Samrat. My goal for this presentation is to introduce the classes that represent the layout manager…...ending:Instead of specifying the precise location and size of every GUI component, programmers may use layout managers for basic layout features. This capability allows the programmer to focus on the overall look and feel while allowing the layout managers to handle the majority of the layout specifics..That ladies and gentlemen, was what I wanted to share with you. Thank you