5-Jan-16 R Ramesh Swing. 5-Jan-16 R Ramesh An Introduction to Java Foundation Classes (JFC) A suite...
-
Upload
hubert-benson -
Category
Documents
-
view
213 -
download
0
Transcript of 5-Jan-16 R Ramesh Swing. 5-Jan-16 R Ramesh An Introduction to Java Foundation Classes (JFC) A suite...
Apr 21, 2023R Ramesh
Swing
Apr 21, 2023R Ramesh
An Introduction to Java Foundation Classes (JFC)
A suite of libraries to assist programmers create enterprise applications.Extends the original Abstract Window Toolkit (AWT) by adding a comprehensive set of graphical user interface class libraries
Apr 21, 2023R Ramesh
The Five API’s of JFC
Abstract window toolkit (AWT)SwingAccessibilityJava 2DDrag and Drop
Apr 21, 2023R Ramesh
AWT
Basic GUI toolkitNew event modelDownward compatibility for java versions less than 1.1
Apr 21, 2023R Ramesh
Swing
Built on top of the core 1.1 and 1.2 AWT librariesHas twice the number of components as AWTCleaner design throughoutDepends on event handling mechanism of AWT 1.1
Apr 21, 2023R Ramesh
Accessibility
Assistance to users who have trouble with traditional user interfacesUsed in conjunction with devices such as audible text readers or braille keyboards
Apr 21, 2023R Ramesh
Java 2D
Classes for implementing various painting styles, complex shapes, fonts and colorsBased on APIs that were licensed from IBM’s Taligent divisionNot a part of Swing
Apr 21, 2023R Ramesh
Drag and Drop
Moving objects in and out of window or frame with predictable resultsCan be used to transfer information between Java applications and native applicationsNot a part of Swing
Apr 21, 2023R Ramesh
The Five API’s of JFC
Apr 21, 2023R Ramesh
Why Swing and Why Not AWT?
AWT provided minimum functionality necessary to create a windowing applicationSwing is not a replacement for AWT but built on top of core AWT libraries
Apr 21, 2023R Ramesh
Disadvantages of AWT
Uses platform’s native componentsMinimal number of componentsTiming and sequence problems between platforms
Apr 21, 2023R Ramesh
Why Swing?
Pluggable look-and-feelsLightweight componentsOther features Wide variety of components Support for rendering custom Swing
components Support for replacing their insets with
arbitrary concentric borders
Apr 21, 2023R Ramesh
Model View Controller (MVC) Architecture
Design Pattern introduced as a part of Smalltalk-80 version of Smalltalk programming languageBuild systems that made use of multiple, synchronized presentation of same data
Apr 21, 2023R Ramesh
MVC may be used in A graph package that contains
different graphical view of same data
A CAD system, in which portions of design can be viewed at different magnifications, in different windows and at different scales
Apr 21, 2023R Ramesh
Apr 21, 2023R Ramesh
Apr 21, 2023R Ramesh
Model
Represents state and low-level behavior of the componentManages state and conducts transformations on that stateHas no specific knowledge of either its controllers or its views
Apr 21, 2023R Ramesh
View
Manages visual display of the state represented by modelA model can have more than one viewSwing set has one view associated with one model
Apr 21, 2023R Ramesh
Controller
Manages user interaction with the modelHas mechanism by which changes are made to the state of the model
Apr 21, 2023R Ramesh
Benefits of MVC
Clearly defined separation between components of a programProblems in each domain can be solved independentlyBinding between the model and the view is dynamic
Apr 21, 2023R Ramesh
MVC in Swing Components
Apr 21, 2023R Ramesh
The Model
The methods under model can be grouped as Query internal state Manipulate internal state Add and remove event listeners Fire events
Apr 21, 2023R Ramesh
The View and Controller
Responsible for creating visual representation and handling user inputMethods are Paint Return geometric information Handle AWT events
Apr 21, 2023R Ramesh
JComponents and Subclasses
Abstract class extended by all Swing componentsContains properties such as, Background/foreground Enable/Disable Visibility
Apr 21, 2023R Ramesh
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
JComponent’s Ancestry
Apr 21, 2023R Ramesh
Top Level Components
JAppletJDialogJFrameJWindow
derived from their AWT version
Apr 21, 2023R Ramesh
Components Under JComponentJComboBox JLabel JList JMenuBar JPanel JPopupMenu
JScrollPane JTable JTree JInternalFrame JOptionPane
JProgressBar JRootPane JSeparator JSlider JSplitPane
JTabbedPane JToolBar JToolTip JViewport JColorChooser
JFileChooser JLayeredPane JTextComponent
JTextAreaJTextField
JPasswordField
JEditorPane
JTextPane
JDesktopPane
Apr 21, 2023R Ramesh
Components Under JComponent Contd..
JRadioButton
JToggleButton
JButton
JMenuItem
JCheckBox
Abstract Button
JMenu JRadioButtonMenuItemJCheckButtonMenuItem
Apr 21, 2023R Ramesh
What JComponent Provides
Invalidating and repaintingPosition, size and alignmentAdding BordersTooltipsDouble BufferingFocus and Focus Cycle
Apr 21, 2023R Ramesh
JFrame
Standard windowRetains the look and feel of host OSActs as the main window to an application
Apr 21, 2023R Ramesh
JWindow
Floats anywhere on the screenHas no frame around itTypically used for popup menusTo display Splash screens
Apr 21, 2023R Ramesh
JDialog
Floats anywhere on the screenCan be modal or non-modalUsed to display messagesThe border and title bar are defined by the OS
Apr 21, 2023R Ramesh
JMenu
Attached to a menu bar (JMenuBar) or another JMenuItems are added using JMenuItemItems can be a JMenuItem and/or JCheckBoxMenuItem and/or JRadioButtonMenuItem
Apr 21, 2023R Ramesh
JPanel
A container to add components or to draw.A non-abstract version of JComponentCommon use is to group components
Apr 21, 2023R Ramesh
JScrollPane
Helps to scroll around panelsAutomatically adjusts itself
Apr 21, 2023R Ramesh
JSplitPane
A container which can hold two componentsCan be split horizontally or vertically
Apr 21, 2023R Ramesh
JTabbedPane
To display more components in one screenComponents are grouped into categoriesEach tab holds a category of components
Apr 21, 2023R Ramesh
ImageIcon
Load small ImagesUsed when neededUsed on Buttons, Check boxes, Radio buttons etc.
Apr 21, 2023R Ramesh
JToolBar
A series of icon buttonsUsed as shortcuts to tasksA tool tip is associated with each buttonA tool bar can be in a separate window
Apr 21, 2023R Ramesh
JSlider and JProgressBar
A JSlider has minimum, maximum and a current valueUnits on a JSlider can be displayed using tick marks and labelsA JProgressBar is used to display the progress of a task
Apr 21, 2023R Ramesh
JTable
Helps to create spreadsheet like controls that have rows and columnsEditable cellsCell renderers can be used to add components like checkbox into a cell
Apr 21, 2023R Ramesh
JTree
To display data in a hierarchical wayOne root node from which all nodes descendNodes can be collapsed/expanded
Apr 21, 2023R Ramesh
Summary
JFCBetween Swing and AWTMVC ArchitectureJComponent and its sub classes