Presentation is loading. Please wait.

Presentation is loading. Please wait.

5-Jan-16 R Ramesh Swing. 5-Jan-16 R Ramesh An Introduction to Java Foundation Classes (JFC) A suite of libraries to assist programmers create enterprise.

Similar presentations


Presentation on theme: "5-Jan-16 R Ramesh Swing. 5-Jan-16 R Ramesh An Introduction to Java Foundation Classes (JFC) A suite of libraries to assist programmers create enterprise."— Presentation transcript:

1 5-Jan-16 R Ramesh Swing

2 5-Jan-16 R 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

3 5-Jan-16 R Ramesh The Five API’s of JFC Abstract window toolkit (AWT) Swing Accessibility Java 2D Drag and Drop

4 5-Jan-16 R Ramesh AWT Basic GUI toolkit New event model Downward compatibility for java versions less than 1.1

5 5-Jan-16 R Ramesh Swing Built on top of the core 1.1 and 1.2 AWT libraries Has twice the number of components as AWT Cleaner design throughout Depends on event handling mechanism of AWT 1.1

6 5-Jan-16 R Ramesh Accessibility Assistance to users who have trouble with traditional user interfaces Used in conjunction with devices such as audible text readers or braille keyboards

7 5-Jan-16 R Ramesh Java 2D Classes for implementing various painting styles, complex shapes, fonts and colors Based on APIs that were licensed from IBM’s Taligent division Not a part of Swing

8 5-Jan-16 R Ramesh Drag and Drop Moving objects in and out of window or frame with predictable results Can be used to transfer information between Java applications and native applications Not a part of Swing

9 5-Jan-16 R Ramesh The Five API’s of JFC

10 5-Jan-16 R Ramesh Why Swing and Why Not AWT? AWT provided minimum functionality necessary to create a windowing application Swing is not a replacement for AWT but built on top of core AWT libraries

11 5-Jan-16 R Ramesh Disadvantages of AWT Uses platform’s native components Minimal number of components Timing and sequence problems between platforms

12 5-Jan-16 R Ramesh Why Swing? Pluggable look-and-feels Lightweight components Other features Wide variety of components Support for rendering custom Swing components Support for replacing their insets with arbitrary concentric borders

13 5-Jan-16 R Ramesh Model View Controller (MVC) Architecture Design Pattern introduced as a part of Smalltalk-80 version of Smalltalk programming language Build systems that made use of multiple, synchronized presentation of same data

14 5-Jan-16 R 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

15 5-Jan-16 R Ramesh

16 5-Jan-16 R Ramesh

17 5-Jan-16 R Ramesh Model Represents state and low-level behavior of the component Manages state and conducts transformations on that state Has no specific knowledge of either its controllers or its views

18 5-Jan-16 R Ramesh View Manages visual display of the state represented by model A model can have more than one view Swing set has one view associated with one model

19 5-Jan-16 R Ramesh Controller Manages user interaction with the model Has mechanism by which changes are made to the state of the model

20 5-Jan-16 R Ramesh Benefits of MVC Clearly defined separation between components of a program Problems in each domain can be solved independently Binding between the model and the view is dynamic

21 5-Jan-16 R Ramesh MVC in Swing Components

22 5-Jan-16 R Ramesh The Model The methods under model can be grouped as Query internal state Manipulate internal state Add and remove event listeners Fire events

23 5-Jan-16 R Ramesh The View and Controller Responsible for creating visual representation and handling user input Methods are Paint Return geometric information Handle AWT events

24 5-Jan-16 R Ramesh JComponents and Subclasses Abstract class extended by all Swing components Contains properties such as, Background/foreground Enable/Disable Visibility

25 5-Jan-16 R Ramesh java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent JComponent’s Ancestry

26 5-Jan-16 R Ramesh Top Level Components JApplet JDialog JFrame JWindow derived from their AWT version

27 5-Jan-16 R Ramesh Components Under JComponent JComboBox JLabel JList JMenuBar JPanel JPopupMenu JScrollPane JTable JTree JInternalFrame JOptionPane JProgressBar JRootPane JSeparator JSlider JSplitPane JTabbedPane JToolBar JToolTip JViewport JColorChooser JFileChooser JLayeredPane JTextComponent JTextArea JTextField JPasswordField JEditorPane JTextPane JDesktopPane

28 5-Jan-16 R Ramesh Components Under JComponent Contd.. JRadioButton JToggleButton JButton JMenuItem JCheckBox Abstract Button JMenu JRadioButtonMenuItemJCheckButtonMenuItem

29 5-Jan-16 R Ramesh What JComponent Provides Invalidating and repainting Position, size and alignment Adding Borders Tooltips Double Buffering Focus and Focus Cycle

30 5-Jan-16 R Ramesh JFrame Standard window Retains the look and feel of host OS Acts as the main window to an application

31 5-Jan-16 R Ramesh JWindow Floats anywhere on the screen Has no frame around it Typically used for popup menus To display Splash screens

32 5-Jan-16 R Ramesh JDialog Floats anywhere on the screen Can be modal or non-modal Used to display messages The border and title bar are defined by the OS

33 5-Jan-16 R Ramesh JMenu Attached to a menu bar (JMenuBar) or another JMenu Items are added using JMenuItem Items can be a JMenuItem and/or JCheckBoxMenuItem and/or JRadioButtonMenuItem

34 5-Jan-16 R Ramesh JPanel A container to add components or to draw. A non-abstract version of JComponent Common use is to group components

35 5-Jan-16 R Ramesh JScrollPane Helps to scroll around panels Automatically adjusts itself

36 5-Jan-16 R Ramesh JSplitPane A container which can hold two components Can be split horizontally or vertically

37 5-Jan-16 R Ramesh JTabbedPane To display more components in one screen Components are grouped into categories Each tab holds a category of components

38 5-Jan-16 R Ramesh ImageIcon Load small Images Used when needed Used on Buttons, Check boxes, Radio buttons etc.

39 5-Jan-16 R Ramesh JToolBar A series of icon buttons Used as shortcuts to tasks A tool tip is associated with each button A tool bar can be in a separate window

40 5-Jan-16 R Ramesh JSlider and JProgressBar A JSlider has minimum, maximum and a current value Units on a JSlider can be displayed using tick marks and labels A JProgressBar is used to display the progress of a task

41 5-Jan-16 R Ramesh JTable Helps to create spreadsheet like controls that have rows and columns Editable cells Cell renderers can be used to add components like checkbox into a cell

42 5-Jan-16 R Ramesh JTree To display data in a hierarchical way One root node from which all nodes descend Nodes can be collapsed/expanded

43 5-Jan-16 R Ramesh Summary JFC Between Swing and AWT MVC Architecture JComponent and its sub classes


Download ppt "5-Jan-16 R Ramesh Swing. 5-Jan-16 R Ramesh An Introduction to Java Foundation Classes (JFC) A suite of libraries to assist programmers create enterprise."

Similar presentations


Ads by Google