JList. Displays a series of items The user can select one or more items Class JList extends directly class Jcomponent Class Jlist supports

Similar documents
CS111: PROGRAMMING LANGUAGE II

12/22/11. Copyright by Pearson Education, Inc. All Rights Reserved.

JAVA NOTES GRAPHICAL USER INTERFACES

Chapter 17 Creating User Interfaces

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

Swing. Component overview. Java UI, summer semester 2017/2018 1

JAVA NOTES GRAPHICAL USER INTERFACES

11/27/2007 TOPICS CHAPTER TOPICS LISTS READ ONLY TEXT FIELDS. Advanced GUI Applications. This module discusses the following main topics:

8/23/2014. Chapter Topics. Chapter Topics. Lists. Read Only Text Fields. Chapter 13: Advanced GUI Applications

9/19/2018 Programming Data Structures. Polymorphism And Abstract

Advanced Swing GUI Applications

GUI Event Handlers (Part II)

Goals. Lecture 7 More GUI programming. The application. The application D&D 12. CompSci 230: Semester JFrame subclass: ListOWords

Programming: You will have 6 files all need to be located in the dir. named PA4:

Programming graphics

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class

Graphical User Interfaces. Comp 152

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

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

Chapter 12 Advanced GUIs and Graphics

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

Intro to Computer Science II. Exceptions

Datenbank-Praktikum. Universität zu Lübeck Sommersemester 2006 Lecture: Swing. Ho Ngoc Duc 1

Summary. Section 14.1 Introduction. Section 14.2 Java s New Nimbus Look-and-Feel. 618 Chapter 14 GUI Components: Part 1

Uppsala University. Assignment 3. Separation into Model-View TableModel ListModel ( multiple inheritance or adapter) Renderer (delegation)

Java Swing. Lists Trees Tables Styled Text Components Progress Indicators Component Organizers

Overview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008

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!

Page 1 of 7. public class EmployeeAryAppletEx extends JApplet

CS 2340 Objects and Design

Custom Data Models and Cell Renderers

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

Basics of programming 3. Java GUI and SWING

Cork Institute of Technology. Spring 2006 GUI/Mobile/Web (Time: 3 Hours)

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

Probing Questions. Chapter Accessor Methods

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

Introduction to the JAVA UI classes Advanced HCI IAT351

Block I Unit 2. Basic Constructs in Java. AOU Beirut Computer Science M301 Block I, unit 2 1

Index SELF-STUDY. Symbols

2110: GUIS: Graphical User Interfaces

CoSc Lab # 5 (The Controller)

Window Interfaces Using Swing Objects

CS 209 Spring, 2006 Lab 8: GUI Development Instructor: J.G. Neal

BASICS OF OBJECT ORIENTED PROGRAMMING

Chapter 13 Lab Advanced GUI Applications

A set, collection, group, or configuration containing members regarded as having certain attributes or traits in common.

Inheritance, and Polymorphism.

Chapter 4. Swing 18 marks

CS-140 Fall 2017 Test 1 Version Practice Practice for Nov. 20, Name:

Window Interfaces Using Swing Objects

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

Graphical interfaces & event-driven programming

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

Unit 6: Graphical User Interface

More Swing. Chapter 14. Chapter 14 1

AP CS Unit 11: Graphics and Events

Programming Project: Game of Life

Topic 7: Algebraic Data Types

Swing. By Iqtidar Ali

Contents Chapter 1 Introduction to Programming and the Java Language

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

1. Position your mouse over the column line in the column heading so that the white cross becomes a double arrow.

Graphical User Interface (GUI)

Object-Oriented Programming Design. Topic : User Interface Components with Swing GUI Part III

Chapter 8 Objects and Classes

Implementing Graphical User Interfaces


Chapter 13 Lab Advanced GUI Applications Lab Objectives. Introduction. Task #1 Creating a Menu with Submenus

1. Write code to answer each of the following questions. For this question, it is not necessary for you to define constants or write comments.

Dr. Hikmat A. M. AbdelJaber

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

Graphical User Interfaces in Java - SWING

First Name: AITI 2004: Exam 2 July 19, 2004

Lecture 6: Components. CS480: Graphical User Interfaces. Dario Salvucci, Drexel University.

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

Chapter 8 Objects and Classes Part 1

Graphical User Interface

Constants are named in ALL_CAPS, using upper case letters and underscores in their names.

CMSC 150 Lab 8, Part II: Little PhotoShop of Horrors, Part Deux 10 Nov 2015

CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM

GUI Design. Overview of Part 1 of the Course. Overview of Java GUI Programming

Dr. Hikmat A. M. AbdelJaber

Course Status Networking GUI Wrap-up. CS Java. Introduction to Java. Andy Mroczkowski

Packages: Putting Classes Together

Chapter 12 GUI Basics

CSC 161 SPRING 17 LAB 2-1 BORDERLAYOUT, GRIDLAYOUT, AND EVENT HANDLING

First Name: AITI 2004: Exam 2 July 19, 2004

Display, Overflow, White Space, and Cursor Karl Kasischke WCC INP 150 Winter

CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming

CoSc Lab # 6 (The Model) Due Date: Part I, Experiment classtime, Tuesday, Nov 6 th, 2018.

CSC324 Principles of Programming Languages

Administrivia. CSSS Movie Night: Zombieland & Iron Man Date: Thurs., Mar 11 Time: 6 10 pm Location: DMP 310 Free pop & popcorn for every attendee!

ENCAPSULATION. private, public, scope and visibility rules. packages and package level access.

SSJ User s Guide. Package stat Tools for Collecting Statistics. Version: December 21, 2006

Static Detection of Brittle Parameter Typing

More Skills 12 Create Web Queries and Clear Hyperlinks

PIC 20A GUI with swing

Programming Languages 2nd edition Tucker and Noonan"

Transcription:

GUI Component - 4

JList Displays a series of items The user can select one or more items Class JList extends directly class Jcomponent Class Jlist supports Single-selection lists: one item to be selected at a time Multiple-selection lists: any number of items can be selected(ctrl,shift)

Jlist - event ListSelectionEvent Handled by ListSelectionListener that should implement the method valuechanged

JList Does not provide a scrollbar??!! The scrollbar can be provided using JScrollPane where the scrollbar appears at the right side of Jlist The scrollbar appears only when the number of items in the list exceeds the number of visible items. To register add the method: addlistselectionlistener

Constructors JList() Constructs an empty list Jlist(object[] listdata) Constructs a list that contains the data in listdata Example: private String size[]={ 12, 14, 16, 18, 20, 22 }; list1= new Jlist(size);

Methods void setvisiblerowcount(int visiblerowcount) Sets the number of rows that can be visible void setselectionmode(int selectionmode) Determines whether single or multiple items can be selected: ListSelectionModel.SINGLE_SELECTION Only one list index can be selected at a time. ListSelectionModel.SINGLE_INTERVAL_SELECTION One contiguous index interval can be selected at a time. ListSelectionModel.MULTIPLE_INTERVAL_SELECTION In this mode, there's no restriction on what can be selected. int getselectionindex() Returns the first selected index, -1 if nothing is selected void setfixedcellhieght(int height) Sets the heights of every cell in the list (in pixels) void setfixedcellwidth(int width) Sets the width of every cell in the list

Methods void setselectedindex(int x) Sets the selected index to x void setlistdata(object[] listdata) Constructs a ListModel from an array of objects object getselectedvalue() Returns the first selected value, null if no selection object getselectedvalues() Returns an array of the values for the selected cells void valuchanged(listselectionevent e) Called whenever the value of the selection changed

NOTE There are no events to indicate that a user has made multiple selections in a multipleselection list. Another GUI componenet should be used to specify when the multiple selection should be processed (known as external event)

JTextArea Area to manipulate multiple lines of text Subclass of JTextComponent No action event: an external event indicates when to process the text. No scrollbar No wrap lines.

Constructors JTextArea() JTextArea (int rows, int cols) New empty text area with the specified number of row and columns JTextArea(String text) New text area with the specified text JTextArea(String text, int rows, int cols) New text area with specified text and no. of cols and rows.

Methods void setlinewrap(boolean wrap) String getselectedtext() void settext(string text) void setreditable(boolean b) String gettext() void append(string s)

JComboBox List of items from which the user can make a single selection Also called a drop-down list JComboBox provides a scrollbar that allow the user to scroll through all the elements For each item selected from a JcomboBox, another item is unselected

Constructor JComboBox(object[] items) Creates a JComboBox that contains the elements in the specified array.

Methods void additemlistener(itemlistener a) void setmaximumrowcount(int count) Sets the maximum number of rows. int getselectedindex() Returns the first item in the list that matches the given item object getselecteditem() Return the current selected item int getstatechange() Returns the type of change (selected or not)

Quiz 10 min If you read this before the class you can solve the quiz and bring the solution to the class tomorrow. Write java statements that are needed to do the following: Constructs a list that contains: A, B, C, D, E, F, G For the previous list write a statement to: Determine that the number of item to be showed is 4 Allow the user to select any number of items Add scrollbar Show how the action will be performed when the user select more than one item