Designing a User Interface with Swing

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming
Advertisements

JAVA API (GUI) Subject:T0934 / Multimedia Programming Foundation Session:1 Tahun:2009 Versi:1/0.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Understanding SWING Architecture CS 4170 UI Design Hrvoje Benko Oct. 9, 2001.
Lecture 15 Graphical User Interfaces (GUI’s). Objectives Provide a general set of concepts for GUI’s Layout manager GUI components GUI Design Guidelines.
1 GUI Elements in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
GUI Programming in Java Tim McKenna GUI Programming Concepts l conventional programming: sequence of operations is determined by the program.
Graphic User Interfaces Part 1. Typical GUI Screen from Microsoft Word What GUI “components” can you see? –Menus? Buttons? Labels? What else? –Anything.
PROGRAMMING REVIEW Lab 2 EECS 448 Dr Fengjun Li and Meenakshi Mishra.
A.k.a. GUI’s.  If you want to discuss your Lab 2 grade come see me this week. ◦ Office: 436 ERB. One hour prior to class ◦ Open to Appointments MWF 
GUI Programming in Java
Java Programming Chapter 10 Graphical User Interfaces.
Intro to GUIs (Graphical User Interfaces) Section 2.5Intro. to GUIs: a GUI Greeter Section 3.7Graphical/Internet Java: Einstein's Equation.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 13 Creating User.
Applets and Frames CS 21a: Introduction to Computing I First Semester,
Introduction to GUI in Java 1. Graphical User Interface Java is equipped with many powerful,easy to use GUI component such as input and output dialog.
Object Oriented Programming Ders 11: Interfaces Mustafa Emre İlal
MIT AITI 2003 Lecture 17. Swing - Part II. The Java Event Model Up until now, we have focused on GUI's to present information (with one exception) Up.
עקרונות תכנות מונחה עצמים תרגול 4 - GUI. Outline  Introduction to GUI  Swing  Basic components  Event handling.
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
3461A Readings from the Swing Tutorial. 3461A Overview  The follow is the Table of Contents from the trail “Creating a GUI with JFC/Swing” in the “The.
Chapter 9: Visual Programming Basics Object-Oriented Program Development Using Java: A Class-Centered Approach.
Session 27 Swing vs. AWT. AWT (Abstract Window ToolKit) It is a portable GUI library for stand-alone applications and/or applets. The Abstract Window.
GUIs in Java Swing, Events CS2110, SW Development Methods Readings: MSD, Chapter 12 Lab Exercise.
Ch 3-4: GUI Basics Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Coming up: GUI Components.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
1 Graphical User Interfaces AWT and Swing packages Frames and Panels Components Nested Panels Images Reading for this Lecture: L&L, 3.9 – 3.11.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
MSc Workshop - © S. Kamin, U. ReddyLect 3 - GUI -1 Lecture 3 - Graphical User Interfaces r GUI toolkits in Java API r JFrame r GUI components.
ITEC 109 Lecture 27 GUI Interaction. Review GUI basics JFrame JPanel JLabel, JButton, JTextField Layout managers –Flow / Box –Border / Grid.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
GUI Basics. What is GUI? A graphical user interface (GUI) is a type of user interface item that allows people to interact with programs in more ways than.
Creating Windows. How can we use Java to create programs that use windows (GUI applications)? How can we use Java to create programs that use windows.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 15 Creating User.
CHAPTER:07 JAVA IDE PROGRAMMING-II Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Swing / Session1 / 1 of 30 Module Introduction Distributed Computing in Java.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 41 JavaServer Face.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 – Graphical User Interfaces Java Foundations: Introduction to Programming.
GUI Basics. Agenda What GUI How to make in java Creating frames Frequently used GUI components Layout Managers.
Swing. Introduction to Swing What is Swing? “ Swing is a diverse collection of lightweight components that can be used to build sophisticated user interfaces.”
Basics of GUI Programming Chapter 11 and Chapter 22.
Ajmer Singh PGT(IP) JAVA IDE Programming - I. Ajmer Singh PGT(IP) GUI (Graphical User Interface) It is an interface that uses a graphic entities along.
Java Programming, Second Edition Chapter Thirteen Understanding Swing Components.
Computer Science [3] Java Programming II - Laboratory Course Lab 4 -1 : Introduction to Graphical user interface GUI Components Faculty of Engineering.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
Lecture # 6 Graphical User Interface(GUI). Introduction A graphical user interface (GUI) presents a user- friendly mechanism for interacting with an application.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
Swing GUI Components So far, we have written GUI applications which can ‘ draw ’. These applications are simple, yet typical of all Java GUI applications.
5-1 GUIs and Events Rick Mercer. 5-2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces to respond.
CIS 270—Application Development II Chapter 11—GUI Components: Part I.
Designing a User Interface with Swing Assignment Swing: Update code of an earlier program.
Introduction to Swing Mr. Crone. What is Swing? a collection of pre-made Java classes used to create a modern graphical user interface.
Java Programming Fifth Edition Chapter 13 Introduction to Swing Components.
Java Visual Applications CSIS 3701: Advanced Object Oriented Programming.
A Quick Java Swing Tutorial
GUIs and Events Rick Mercer.
Graphical User Interfaces
Welcome To java
Provision for GUIs in Java
Handling User Events with Swing
A First Look at GUI Applications
Advanced User Interfaces
Chapter 8: Writing Graphical User Interfaces
Java Look-and-Feel Design Guidelines
Provision for GUIs in Java
Chap 7. Building Java Graphical User Interfaces
Graphical User Interfaces -- Introduction
Steps to Creating a GUI Interface
Graphical User Interface
Presentation transcript:

Designing a User Interface with Swing Assignment Swing: Update code of an earlier program

Swing: Part of the Java Foundational Classes JDK1.2 Expanded components Better event handling Selectable look & Feel Extends AWT

Benefits of Swing Swing provides for a different Look & Feel Metal is the name of new interface in Java All Components Compatibility (www…) All Components written in Java(not so earlier) import java.awt.swing.*; OR javax.swing in Beta 4 (and up)

An Applications Framework FRAMEWORK.JAVA Just provides a frame (no components) SWINGER.JAVA A button “I receive a disproportionate amount of pleasure from being clicked. Please interact with me.” Jframe NEW term “ an intermediate container called the content pane”

Jframe subdivided into panes Create Jframe Jframe frame = new Swinger( ); Add all components (use add(Component)) pane.add(hotbutton) Make the Jpanel Jpanel pane = new Jpanel( );

Working with Swing NEW TERM icon http://www.prefect.com/java21 http://www.zeldman.com (.gif files added to the icon ImageIcon una = new ImageIcon(“unabom.gif”); http://www.prefect.com/java21

Swing Labels Jlabel(String , int) Buttons “ TextFields JTextArea(int , int) TextAreas “ Check Boxes and Radio Buttons Choice Lists “ Scrollbars JScrollBar( int , int, int, int, int)

SwingColorTest An “old” program revisited & Updated It is the “old” Hue Saturation & Brightness OR R G B All done with Swing

New Swing UI manager A Swing Layout manager/ user-interface manager Windows 95 or NT Look & Feel Motif X-Window, Metal, Swing’s cross platform “ “ try { UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassname( )); } catch(Exception e) { System.err.println(“Can’t set look and feel: + e;}

Keyboard Mnemonics A key Accelerator purpose (without a mouse) - use control keys in combination with other keys to function instead of mouse Jbutton infoButton = new Jbutton(“Info”)’ infoButton.setMnemonic(‘I’); Pressing Alt+ I causes “InfoButton” click

It’s ToolTime with Tim Allen Kidding … ToolTips JScrollBar seed = JScrollBar( ); Speed.setToolTip ( “Move to set animation speed”); limit ToolTip ONLY one line long

Component Descriptions & Names 1. Get AssessibleContext( ) method on the component 2. Call setAcccessibleDescription(String) method on that AccessibleContext object The string argument should be the component’s text description

Standard Dialog Boxes Like Visual BASIC “Windows” that ask a small/simple question, warn, or provide message ConfirmDialog = Y/N Cancel InputDialog = prompt input MessageDialog = message OptionDialog = All of the above

Example Int response; response = JOptionPane.showConfirmDialog(null, “Should I delete all your irreplaceable personal files”); MORE figures/code demo. Use of Dialog Boxes

INFO.JAVA Last example of complete program in chapter. Uses Dialog boxes - Swing