MODEL UPDATES MANIPULATES USER

Similar documents
Swing. By Iqtidar Ali

SD Module-1 Advanced JAVA

Widgets. Overview. Widget. Widgets Widget toolkits Lightweight vs. heavyweight widgets Swing Widget Demo

SD Module-1 Advanced JAVA. Assignment No. 4

China Jiliang University Java. Programming in Java. Java Swing Programming. Java Web Applications, Helmut Dispert

Graphical User Interfaces (GUIs)

Sri Vidya College of Engineering & Technology

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

Graphics programming. COM6516 Object Oriented Programming and Design Adam Funk (originally Kirill Bogdanov & Mark Stevenson)

Widget Toolkits CS MVC

Widgets. Widgets Widget Toolkits. 2.3 Widgets 1

GUI Basics. Object Orientated Programming in Java. Benjamin Kenwright

Introduction p. 1 JFC Architecture p. 5 Introduction to JFC p. 7 The JFC 1.2 Extension p. 8 Swing p. 9 Drag and Drop p. 16 Accessibility p.

Widget. Widget is a generic name for parts of an interface that have their own behaviour. e.g., buttons, progress bars, sliders, drop-down

Widgets. Widgets Widget Toolkits. User Interface Widget

Example: CharCheck. That s It??! What do you imagine happens after main() finishes?

Graphic User Interfaces. - GUI concepts - Swing - AWT

H212 Introduction to Software Systems Honors

Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008

Object-Oriented Programming Design. Topic : Graphics Programming GUI Part I

Introduction to the JAVA UI classes Advanced HCI IAT351

Introduction to Graphical Interface Programming in Java. Introduction to AWT and Swing

Lab 4. D0010E Object-Oriented Programming and Design. Today s lecture. GUI programming in

CS111: PROGRAMMING LANGUAGE II

Introduction to GUIs. Principles of Software Construction: Objects, Design, and Concurrency. Jonathan Aldrich and Charlie Garrod Fall 2014

Lecture 5: Java Graphics

CS415 Human Computer Interaction

BASICS OF GRAPHICAL APPS

CompSci 125 Lecture 17. GUI: Graphics, Check Boxes, Radio Buttons

Starting Out with Java: From Control Structures Through Objects Sixth Edition

Handout 14 Graphical User Interface (GUI) with Swing, Event Handling

Graphical User Interfaces

Example Programs. COSC 3461 User Interfaces. GUI Program Organization. Outline. DemoHelloWorld.java DemoHelloWorld2.java DemoSwing.

GUI Program Organization. Sequential vs. Event-driven Programming. Sequential Programming. Outline

Graphical User Interface (GUI)

Packages: Putting Classes Together

Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing

Chapter 6: Graphical User Interfaces

Chapter 4. Swing 18 marks

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

Review. Designing Interactive Systems II. Introduction. Web 2.0 in keywords GWT Cappuccino HTML5. Cross platform GUI Toolkit

Designing Interactive Systems II

Frames, GUI and events. Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling

GUI Implementation Support

Graphical User Interfaces. Swing. Jose Jesus García Rueda

Systems Programming Graphical User Interfaces

Java Swing. based on slides by: Walter Milner. Java Swing Walter Milner 2005: Slide 1

Swing: Building GUIs in Java

Swing from A to Z Some Simple Components. Preface

Chapter 12 GUI Basics

Swing: Building GUIs in Java

Tool Kits, Swing. Overview. SMD158 Interactive Systems Spring Tool Kits in the Abstract. An overview of Swing/AWT

Swing Programming Example Number 2

CS 4300 Computer Graphics

Graphical interfaces & event-driven programming

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more

Topic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun!

CSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

2110: GUIS: Graphical User Interfaces

Part 3: Graphical User Interface (GUI) & Java Applets


Java Swing Introduction

Graphical Applications

Graphical User Interface (GUI) components in Java Applets. With Abstract Window Toolkit (AWT) we can build an applet that has the basic GUI

Jonathan Aldrich Charlie Garrod

Windows and Events. created originally by Brian Bailey

Window Interfaces Using Swing Objects

Chapter 12 Advanced GUIs and Graphics

(Incomplete) History of GUIs

Java Graphical User Interfaces

Swing from A to Z Using Focus in Swing, Part 2. Preface

Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms.

Window Interfaces Using Swing Objects

Advanced Java Programming. Swing. Introduction to Swing. Swing libraries. Eran Werner, Tel-Aviv University Summer, 2005

Lecture 3: Java Graphics & Events

Chapter 13 Lab Advanced GUI Applications

core 2 Basic Swing GUI Controls in Java 2

core programming Basic Swing GUI Controls in Java Marty Hall, Larry Brown

Introduction to concurrency and GUIs

Lecture 9. Lecture

To gain experience using GUI components and listeners.

In addition to dividing the application into three kinds of components, the Model view controller (MVC) design defines the interactions between them

GUI and its COmponent Textfield, Button & Label. By Iqtidar Ali

Original GUIs. IntroGUI 1

All the Swing components start with J. The hierarchy diagram is shown below. JComponent is the base class.

Graphical User Interfaces in Java Part 2

1.00 Lecture 14. Lecture Preview

Class 14: Introduction to the Swing Toolkit

Unit 6: Graphical User Interface

Java. GUI building with the AWT

navlakhi.com / navlakhi.education / navlakhi.mobi / navlakhi.org 1

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics

Outline. Composite Pattern. Model-View-Controller Pattern Callback Pattern

CS 251 Intermediate Programming GUIs: Components and Layout

EVENTS, EVENT SOURCES AND LISTENERS

Adding Buttons to StyleOptions.java

Summary Chapter 25 GUI Components: Part 2

Programming Language Concepts: Lecture 8

Marcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science

INTRODUCTION TO (GUIS)

Transcription:

1) What do you mean by MVC architecture? Explain its role in modern applications and list its advantages(may-2013,jan-2013,nov-2011). In addition to dividing the application into three kinds of components, the Model view controller (MVC) design defines the interactions between them MODEL UPDATES MANIPULATES VIEW CONTROLLER SEES USES USER A controller can send commands to the model to update the model's state (e.g., editing a document). It can also send commands to its associated view to change the view's presentation of the model (e.g., by scrolling through a document). A model notifies its associated views and controllers when there has been a change in its state. This notification allows the views to produce updated output, and the controllers to change the available set of commands. A passive implementation of MVC omits these notifications, because the application does not require them or the software platform does not support them. A view requests information from the model that it needs for generating an output representation to the user For example, in case of a checkbox, The Model contains a field that indicates if the box is checked or unchecked. The View determines how the component is displayed on the screen. The Controller determines how the component reacts to the user. Advantages 1. Multiple Views Using the Same Model. Representation the some model data in several views because the view and model are separated in MVC architecture 2. Efficient Modularity Allows developing view and model in different environment. 3. Easier Support for New Types of Clients Allows developing separated view and controller for new type of client and then integrating them the existing enterprise model. Disadvantages Increase Complexity/Effort Arjun V. Bala Page 1

2) Compare the AWT and Swing.(May-2013,June-2012) AWT AWT stands for Abstract windows toolkit. AWT components are called Heavyweight component. Swing Swing is also called as JFC s (Java Foundation classes). Swings are called light weight component because swing components sits on the top of AWT components and do the work. AWT components require java.awt package. Swing components require javax.swing package. AWT components are platform dependent. This feature is not supported in AWT. These feature is not available in AWT. Swing components are made in purely java and they are platform independent. We can have different look and feel in Swing. Swing has many advanced features like JTabel, Jtabbed pane which is not available in AWT. Also. Swing components are called "lightweight" because they do not require a native OS object to implement their functionality. JDialog and JFrame are heavyweight, because they do have a peer. So components like JButton, JTextArea, etc., are lightweight because they do not have an OS peer. With AWT, you have 21 "peers" (one for each control and one for the dialog itself). A "peer" is a widget provided by the operating system, such as a button object or an entry field object. With Swing, you would have only one peer, the operating system's window object. All of the buttons, entry fields, etc. are drawn by the Swing package on the drawing surface provided by the window object. This is the reason that Swing has more code. It has to draw the button or other control and implement its behavior instead of relying on the host operating system to perform those functions. AWT is a thin layer of code on top of the OS. Using AWT, you have to implement a lot of things yourself. Swing is much larger. Swing also has very much richer functionality. Swing has them built in. Arjun V. Bala Page 2

3) What is pluggable look and feel? How do you set the look and feel of the components? (June-2012) Swing provides programmer the facility to change the look and feel of components being displayed on any system, This is called plaf (pluggable look and feel). Look refers to the appearance of the component on the screen. Feel represents how the user can interact with the component. There are 3 types of Look & Feel available in Swing Metal Look & Feel Motif Look & Feel Windows Look & Feel By default, Swing programmer use metal look and feel. We can set any of the following look & feel using UIManager. We need to use setlookandfeel() method of the UIManager to set the Look & Feel. As an argument to above method we can pass either of the following string. javax.swing.metal.metallookandfeel com.sun.java.swing.plaf.motif.motiflookandfeel com.sun.java.swing.plaf.windows.windowslookandfeel The content of the content pane are updated using the updatecomponenttreeui() method. //Changing the look and feel of components import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.plaf.*; class LookFeel extends JFrame implements ItemListener //vars JButton b; JCheckBox cb;jk JTextField t; JRadioButton r1, r2, r3; ButtonGroup bg; Container c; LookFeel() //create content pane c = this.getcontentpane(); //set flow layout to c c.setlayout(null); //create components b = new JButton("Button"); cb = new JCheckBox("CheckBox"); t = new JTextField("TextField", 15); r1 = new JRadioButton("Metal"); r2 = new JRadioButton("Motif"); r3 = new JRadioButton("Windows"); Arjun V. Bala Page 3

//create ButtonGroup object and add radio buttons to specify //that they belong to same group bg = new ButtonGroup(); bg.add(r1); bg.add(r2); bg.add(r3); //set the location of components in content pane b.setbounds(100,50,75,40); cb.setbounds(100,100,100,40); t.setbounds(100,150,100,40); r1.setbounds(50,250,100,30); r2.setbounds(150,250,100,30); r3.setbounds(250,250,100,30); //add the components to content pane c.add(b); c.add(cb); c.add(t); c.add(r1); c.add(r2); c.add(r3); //add item listeners to radio buttons r1.additemlistener(this); r2.additemlistener(this); r3.additemlistener(this); //close the frame this.setdefaultcloseoperation(jframe.exit_on_close); public void itemstatechanged(itemevent ie) try //know which radio button is selected and accordingly change //the look and feel if(r1.getmodel().isselected()) UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); if(r2.getmodel().isselected()) UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); if(r3.getmodel().isselected()) UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); //change the look and feel in the content pane SwingUtilities.updateComponentTreeUI(c); catch(exception e) Arjun V. Bala Page 4

public static void main(string args[]) //create the frame LookFeel lf = new LookFeel(); lf.setsize(400,400); lf.settitle("look and Feel"); lf.setvisible(true); Arjun V. Bala Page 5