Creating User Interfaces Chapter 13 CSCI 1302. CSCI 1302 – Creating User Interfaces2 Outline Introduction Common Features of Swing GUI Components Buttons.

Slides:



Advertisements
Similar presentations
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 17 Creating User Interfaces.
Advertisements

Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. 1 Chapter 16 JavaFX UI Controls and Multimedia.
1 Chapter 13 Creating User Interfaces. 2 Objectives F To create graphical user interfaces with various user-interface components: JButton, JCheckBox,
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 16 Creating User Interfaces.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 15 Creating User.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L03 (Chapter 15) Creating.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L04 (Chapter 15) Creating.
1 Creating User Interfaces. 2 Motivations A graphical user interface (GUI) makes a system user-friendly and easy to use. Creating a GUI requires creativity.
1 L46 Advanced GUI Component (1). 2 OBJECTIVES  To create and manipulate sliders, and menus,
User Interface Design using jQuery Mobile CIS 136 Building Mobile Apps 1.
Introduction to Java Swing “We are the sultans of swing” – Mark Knopfler.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 13 Creating User.
CIS 068 Welcome to CIS 083 ! Introduction to GUIs: JAVA Swing.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
GUI development with Matlab: GUI Front Panel Components 1 GUI front panel components In this section, we will look at -GUI front panel components -Programming.
GUI Widgets Jeff Offutt SWE 432 Design and Implementation of Software for the Web.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Graphical User Interface Components Chapter What You Will Learn Text Areas Text Areas Sliders Sliders Menus Menus –With frames –Pop up menus Look.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 3 Welcome Application Introduction to Visual Programming.
Java Swing. Swing is a set of classes that provides more powerful and flexible components than are possible with the AWT. In addition to the familiar.
1 Outline 1 Introduction 2 Overview of Swing Components 3 JLabel 4 Event Handling 5 TextFields 6 How Event Handling Works 7 JButton 8 JCheckBox and JRadioButton.
Dale Roberts GUI Programming using Java - GUI Components Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
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.
Visual Basic Programming Introduction VB is one of the High level language VB has evolved from the BASIC language. BASIC stands for Beginners All-purpose.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 – Graphical User Interfaces Java Foundations: Introduction to Programming.
Introduction to Java Chapter 9 - Graphical User Interfaces and Applets1 Chapter 9 Graphical User Interfaces and Applets.
GUI Basics. Agenda What GUI How to make in java Creating frames Frequently used GUI components Layout Managers.
Creating User Interfaces Event-Driven Programming.
GUI Components CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Java Programming, Second Edition Chapter Thirteen Understanding Swing Components.
CMPF114 Computer Literacy Chapter 3 The Visual Basic Environment 1.
Copyright © Curt Hill More Widgets In Abstract Window Toolbox.
Chapter 14: Introduction to Swing Components. Objectives Understand Swing components Use the JFrame class Use the JLabel class Use a layout manager Extend.
Computer Science [3] Java Programming II - Laboratory Course Lab 4 -1 : Introduction to Graphical user interface GUI Components Faculty of Engineering.
CMPF124 Personal Productivity With Information Technology Chapter 1 – Part 2 Introduction to Windows Operating Systems Manipulating Windows GUI CMPF 124.
 Figure illustrates a hierarchy containing many event classes from the package java.awt.event.  Used with both AWT and Swing components.  Additional.
1 Lecture 8: User Interface Components with Swing.
MATLAB and SimulinkLecture 61 To days Outline Graphical User Interface (GUI) Exercise on this days topics.
CIS 270—Application Development II Chapter 11—GUI Components: Part I.
1 Chapter 6: Creating Oracle Data Block Forms. 2 Forms  Application with a graphical user interface that looks like a paper form  Used to insert, update,
Java Programming Fifth Edition Chapter 13 Introduction to Swing Components.
DB Implementation: MS Access Forms. MS Access Forms: Purpose Data entry, editing, & viewing data in Tables Forms are user-friendlier to end-users than.
Chapter 9: Graphical User Interfaces
Christopher Budo, Davis Nygren, spencer franks, Luke miller
Chapter 1: An Introduction to Visual Basic 2015
Chapter Topics 15.1 Graphical User Interfaces
Chapter 16 JavaFX UI Controls and Multimedia
Graphical User Interface (GUI) Components: Part 1 Java How to Program, 9 th Edition Chapter 14.
Chap 7. Building Java Graphical User Interfaces
Chapter 16 JavaFX UI Controls and Multimedia
DB Implementation: MS Access Forms
Graphical User Interfaces -- Introduction
Chapter 7 Creating User Interfaces
Recall: Timeline Class
Chapter 13 Creating User Interfaces
DB Implementation: MS Access Forms
Chapter 15: GUI Applications & Event-Driven Programming
Chapter 17 Creating User Interfaces
Chapter 16 JavaFX UI Controls and Multimedia
Chapter 17 Creating User Interfaces
Chapter 16 JavaFX UI Controls and Multimedia
TA: Nouf Al-Harbi NoufNaief.net :::
Presentation transcript:

Creating User Interfaces Chapter 13 CSCI 1302

CSCI 1302 – Creating User Interfaces2 Outline Introduction Common Features of Swing GUI Components Buttons –Icons –Alignments –Text Positions Check Boxes Radio Buttons

CSCI 1302 – Creating User Interfaces3 Outline Labels Text Fields Text Areas Combo Boxes Lists Scroll Bars Sliders Creating Multiple Windows

CSCI 1302 – Creating User Interfaces4 Introduction GUI components make up the user interfaces that you see and use Java provides many components that provide a wide variety of functionality

CSCI 1302 – Creating User Interfaces5 Common Features All but a few components are subclasses of JComponent They share a lot of the same features and methods, making it easy to learn and use these items See Figure 13.2 for a list of common features See TestSwingCommonFeatures.java

CSCI 1302 – Creating User Interfaces6 Buttons Triggers an action event when clicked Includes regular buttons, toggle buttons, check box buttons, and radio buttons Common button features are represented in the parent class javax.swing.AbstractButton Regular buttons are JButton s

CSCI 1302 – Creating User Interfaces7 Icons Small, fixed-size pictures used to decorate components Use the ImageIcon class to create icons from image files: Icon i = new ImageIcon(“photo.gif”); Three button icon states: default, pressed, and rollover See TestButtonIcons.java

CSCI 1302 – Creating User Interfaces8 Alignments Horizontal alignment specifies horizontally placement on the button Use setHorizontalAlignment(int) with the constants LEADING, LEFT, CENTER, RIGHT, TRAILING Vertical alignment specifies vertical placement on the button Use setVerticalAlignment(int) with the constants TOP, CENTER, BOTTOM See Figures 13.7 and 13.8

CSCI 1302 – Creating User Interfaces9 Text Positions Specifies text position relative to the icon Use setHorizontalTextPosition(int) with the constants LEADING, LEFT, CENTER, RIGHT, TRAILING Use setVerticalTextPosition(int) with the constants TOP, CENTER, BOTTOM See note about SwingConstants See Figures 13.9 and and ButtonDemo.java

CSCI 1302 – Creating User Interfaces10 Check Boxes Toggle button is a two-state button like a light switch Often used to toggle choices on or off Many options available through constructors, see Figure Fires ItemEvent s Use isSelected() to query selected state See CheckBoxDemo.java

CSCI 1302 – Creating User Interfaces11 Radio Buttons Enable the user to choose a single choice out of a group of choices Must use a ButtonGroup to create groups of individual radio buttons Fires ItemEvent, then an ActionEvent Use isSelected() to query selected state See RadioButtonDemo.java

CSCI 1302 – Creating User Interfaces12 Labels Display area for short text, images, or both See Figure for constructors and methods Already used in TVFrame.java

CSCI 1302 – Creating User Interfaces13 Text Fields Can be used to enter or display a string Like other components, has many properties that can be set Can be editable or not See TextFieldDemo.java

CSCI 1302 – Creating User Interfaces14 Text Areas Used to enter multiple lines of text as opposed to using multiple text fields See Figure for constructors and methods Does not scroll automatically, but can be contained in a JScrollPane See TextAreaDemo.java

CSCI 1302 – Creating User Interfaces15 Combo Boxes Known as choice or drop-down lists A list of items from which the user can choose Limit’s range of choices, helps input validation See Figure for constructors and methods Can generate ActionEvent and ItemEvent See ComboBoxDemo.java

CSCI 1302 – Creating User Interfaces16 Lists Performs same functions as a combo box, but enables the user to select both single and multiple values See Figure for constructors and methods Three selection modes: Single, single- interval, and multiple-interval Do not scroll automatically Fires ListSelectionEvent

CSCI 1302 – Creating User Interfaces17 Scroll Bars

CSCI 1302 – Creating User Interfaces18 Scroll Bars orientation – describes if the scroll bar is displayed horizontally or vertically maximum – maximum value minimum – minimum value visibleAmount (extent) – Relative width of the scroll bar’s bubble value – current value of scroll bar blockIncrement – used in block areas unitIncrement – used in unit areas

CSCI 1302 – Creating User Interfaces19 Scroll Bars When value is changed, fires an AdjustmentEvent to all registered listeners Objects notified of changes to the scroll bar’s value must implement the adjustmentValueChanged method in the AdjustmentListener interface See ScrollBarDemo.java

CSCI 1302 – Creating User Interfaces20 Sliders Similar to scrollbar but more versatile See Figure for constructors and methods User can graphically select a value by sliding a knob within a bounded interval Fires a ChangeEvent which is passed to registered listeners who must implement stateChanged in ChangeListener interface See SliderBarDemo.java

CSCI 1302 – Creating User Interfaces21 Creating Multiple Windows Subwindows can be opened during the lifetime of a “main” window Can create an instance of a new window and make it visible See MultipleWindowsDemo.java