Upload
backdoor
View
3.114
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Citation preview
IADCS Diploma CourseSwing Programming
U Nyein OoU Nyein Oo
COO/Director(IT)COO/Director(IT)
Myanma Computer Co.,Myanma Computer Co.,
Copyright: MCC Swing Programming 2
Java Foundation Classes?
Set of Java Class Libraries provides as part of J2SE
Support building GUI and graphics functionality for Java based Client Application
Run on Microsoft Platform and others like Mac OSX and Linux
Easily deployed over the web Rich clients for web services
Copyright: MCC Swing Programming 3
Features of JFC
Abstract Windowing Toolkits Java 2D Swing GUI Components Accessibility Internationalization
Copyright: MCC Swing Programming 4
MVC Architecture
Design pattern to Swing UI for JFC Used for constructing entire UI Components Each component has a Model, a View and a
Controller. The model, view ,and controller pieces can
change even while the component is in use.
Copyright: MCC Swing Programming 5
MVC Design Pattern
Model
ControllerView
Inform the view to update visual
Read the contents
Update the contentsInform view of
state change
Copyright: MCC Swing Programming 6
What MVC means?
Model is the piece that represents the state and low level behavior of the component.
(stored the data or stage of object) View is the piece that manage the visual
display of the state represented by the model Controller is the piece that manages user
interaction with the model.(handle the event)
Copyright: MCC Swing Programming 7
Benefits using MVC
To divded large program to views of documents.
A view provides a window into document Multiple views can provide multiple windows
into the document.
Copyright: MCC Swing Programming 8
Swing Programming
AWT is the heave weight component and it has a peer object for the native GUI
When the components are created they take help of the underlying O/S
Java offers Light weight components that do not have a peer object.
It now popular by Swing UI components
Copyright: MCC Swing Programming 9
Why Swing?
Uses fewer system resources Add a lot of more sophisticated components Tailor the Look and Feel of program and Extensing of Existing Components for
- Layout Management
- Event handling
- Thread and Swing
- Printing ….etc
Copyright: MCC Swing Programming 10
Swing Basic
Swing is set of packages build on top of the AWT with number of prebuild classes(over 250 classes and 40UI components)
All swing UI components are started with J for use the terms JFC and Swing interchangeabily
Copyright: MCC Swing Programming 11
Structure of Swing Components
JContainer Classes
JComponent Classes
All Swing Components
Copyright: MCC Swing Programming 12
Swing Components
Windows Menus AbstractButton Panels Layouts Icons Borders Toolbars
Labels Buttons List Boxes Combo Boxes Check Boxes Tables Trees
Copyright: MCC Swing Programming 13
Sub Classes of the JComponent Class
JComponent is the superclass of all swing components. All the components begin with the letter ‘J’. JComponent has the following subclasses:
– AbstractButton class – JButton & JLabel class – JButton – JLabel – JComboBox class – JCheckBox class – Jlist– Jmenu– JPopupMenu– JProgressBar– JScrollBar
– JRadioButton– Jseparator– Jtable– JTextComponent– JToolBar– JTree
Copyright: MCC Swing Programming 14
Swing PackagesSwing Package Description
javax.swing Contains components, adapters, component models and interfaces. It is the highest-level swing package.
javax.swing.basic Contains the user interface classes that implement the look and feel for swing components.
javax.swing.border Declares the border interface, and classes defining the specific border styles.
javax.swing.plaf Contains the plugable look and feel API.
javax.swing.table Contains the interfaces and classes supporting the swing table component.
javax.swing.text Contains the support classes for the swing document framework.
javax.swing.event Defines the events and event listeners.
javax.swing.tree Provides classes and interfaces that support the JTree component.
javax.swing.undo Provides support classes for undo/redo operations.
Copyright: MCC Swing Programming 15
Swing Event Handling
For a Java program to run, the interface should be made receptive to user events
Swing handles events with a set of classes called ‘event listeners’
javax.swing.event package defines a set of event listening interfaces and event classes so that they can used with Swing components
There are various events defined in the javax.swing.event package, such as:
– ChangeEvent – DragEvent – ListDataEvent
ListSelectionEvent TableModelEvent TableColumnEvent
Copyright: MCC Swing Programming 16
Look and Feel
Swing is a real improvement to the AWT, since it supplies rich set of platform GUI components
Platform independence means the components within it are supported across all Java ports
Enables the look and feel of the components to be easily tailored
This is called as Pluggable Look and Feel (L&F) of the swing components
This helps us to create applets and applications that have a look and feel independent to the window platform in which they are executed
Copyright: MCC Swing Programming 17
Look and Feel Cont;
The look and feel consists of the way the program is presented to the user (looks) & the way user interacts with it (feels).
Swing provides the capability to change the look and feel of the applet or application.
Swing components are not tied to GUI components. It is because of this that we can create applets or applications that will use a specific look and feel. Look and feel is a function of view and controller.
Copyright: MCC Swing Programming 18
Thank You
Copyright: MCC Swing Programming 19
1. Frame Test
Copyright: MCC Swing Programming 20
3. Label Test
Copyright: MCC Swing Programming 21
4. Button Test
Copyright: MCC Swing Programming 22
6. Text Area Test
Copyright: MCC Swing Programming 23
7. CheckBox and Radio Button
Copyright: MCC Swing Programming 24
8. Listtest Test
Copyright: MCC Swing Programming 25
9. Color Change Test
Copyright: MCC Swing Programming 26
10. Editable TextArea Test
Copyright: MCC Swing Programming 27
11. Border Test
Copyright: MCC Swing Programming 28
12. Calcuator
Copyright: MCC Swing Programming 29
13. Combo Example
Copyright: MCC Swing Programming 30
14. Menu Example
Copyright: MCC Swing Programming 31
15. Popup Menu Example
Copyright: MCC Swing Programming 32
16. DialogBox Test
Copyright: MCC Swing Programming 33
17. Table Test
Copyright: MCC Swing Programming 34
18. Progress Bar Test
Copyright: MCC Swing Programming 35
19. Tooltips Test
Copyright: MCC Swing Programming 36
20. Color Chooser Test
Copyright: MCC Swing Programming 37
21. File Chooser Test