Field Trip #31 CrossWord Puzzle By Keith Lynn. JApplet A JApplet is a top-level container in Java We will use the JApplet to contain two Jpanels The first.

Slides:



Advertisements
Similar presentations
Chapter 18 Building the user interface. This chapter discusses n Javas graphical user interface. n Swing: an enhancement of a library called the Abstract.
Advertisements

Graphic User Interfaces Layout Managers Event Handling.
Programming and Problem Solving With Java Copyright 1999, James M. Slack Applets What is an Applet? Applet Parameters Graphics in Applets Other Applet.
Lecture 24 Applets. Introduction to Applets Applets should NOT have main method but rather init, stop, paint etc They should be run through javac compiler.
COMP 14 Introduction to Programming Miguel A. Otaduy June 8, 2004.
Lecture 15 Graphical User Interfaces (GUI’s). Objectives Provide a general set of concepts for GUI’s Layout manager GUI components GUI Design Guidelines.
Graphical User Interfaces (GUIs) GUI: An application that uses graphical objects to interact with users GUI applications consist of: –Events: A user or.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 21, 2005.
Chapter 14 Applets. 2 Knowledge Goals Understand the differing roles of applications and applets Understand how a browser operates Understand the role.
Slides prepared by Rose Williams, Binghamton University Chapter 17 Swing I.
Chapter 13: Advanced GUIs and Graphics J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
CPSC150 Week 12 Graphical User Interfaces Chapter 11.
Chapter 6: Graphical User Interface (GUI) and Object-Oriented Design (OOD) J ava P rogramming: Program Design Including Data Structures Program Design.
Java Programming Chapter 10 Graphical User Interfaces.
Chapter 9: Applets Jim Burns Fall Outline Learn about applets Learn about applets Write an HTML doc to host an applet Write an HTML doc to host.
Chapter 13 Advanced GUIs and Graphics. Chapter Objectives Learn about applets Explore the class Graphics Learn about the class Font Explore the class.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
Forms Sangeetha Parthasarathy 02/05/2001. Introduction to Forms A form makes it possible to transform your web pages from text to graphics to interactive.
Visual Basic Games: Prepare for Hangman
Field Trip #26 Create a Find a Word Puzzle in Java By Keith Lynn.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 12 Advanced GUIs and Graphics.
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.
Field Trip # 21 Creating PDFs with Java By Keith Lynn.
Java Programming: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
GUI Components and Design Here we add one more component to our programs, JButtons –JButtons can only be inserted into JPanels (or JApplets) –Clicking.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
GUIs in Java Swing, Events CS2110, SW Development Methods Readings: MSD, Chapter 12 Lab Exercise.
Field Trip #19 Animations with Java By Keith Lynn.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
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.
Timer class and inner classes. Processing timer events Timer is part of javax.swing helps manage activity over time Use it to set up a timer to generate.
Alice in Action with Java Chapter 14 Events and GUIs.
Object Oriented Programming Engr. M. Fahad Khan Lecturer, Software Engineering Department University of Engineering & Technology, Taxila.
Chapter 12Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Announcements/Reminders l Next week: »No Lectures »No Labs »Recitation.
Applets and Frames. Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L14: GUI Slide 2 Applets Usually.
CS Fall 2012, Lab 09 Haohan Zhu. Boston University Slideshow Title Goes Here CS Fall 2012, Lab /20/2015 GUI - Graphical User Interface.
Java Programming Applets. Topics Write an HTML document to host an applet Understand simple applets Use Labels with simple AWT applets Write a simple.
Field Trip #28 Securing a VNC Connection with Java By Keith Lynn.
Field Trip #22 Creating an Excel Spreadsheet with Java By Keith Lynn.
Field Trip #25 Creating a Client/Server By Keith Lynn.
Field Trip #23 Hangman By Keith Lynn. JApplet A JApplet is a top-level container An applet is a small Java program that is executed by another program.
Java Programming: From Problem Analysis to Program Design, 3e Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Introduction to Java Chapter 9 - Graphical User Interfaces and Applets1 Chapter 9 Graphical User Interfaces and Applets.
Java Programming: From Problem Analysis to Program Design, Second Edition1 Lecture 5 Objectives  Learn about basic GUI components.  Explore how the GUI.
HTML IMAGES. CONTENTS IMG Tag Alt Attribute Setting Width and Height Of An Image Summary Exercise.
Applets Java code is compiled into byte code instead of machine language –Languages like C, C++, Pascal and others are compiled into machine language so.
Field Trip #27 Using Java to Download Images and Sounds By Keith Lynn.
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.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
User Interface Components. Layout Placement of UI components in a window – Size & Position Each component occupies a rectangular region in the window.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Field Trip #34 Creating and Reading Zip Files in Java By Keith Lynn.
Jozef Goetz Credits: Copyright  Pearson Education, Inc. All rights reserved. expanded by J. Goetz, 2016.
Applets. 9/04/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L12: Applets Slide 2 Applets Usually.
Introduction to GUI in 1 Graphical User Interface 3 Nouf Almunyif.
1 Organizing Information in Tables A table is information arranged in horizontal rows and vertical columns When you first insert a table into a document,
Introduction to GUI Programming in Java: Frames, Simple Components, and Layouts.
Field Trip #30 A Memory Game By Keith Lynn. View A View is the basic building block of an app Some Views hold other views An example of this is GridLayout.
CIS 270—Application Development II Chapter 11—GUI Components: Part I.
GUIs & Event-Driven Programming Chapter 11 Review.
Field Trip #29 Creating an Event Calendar with Java By Keith Lynn.
Lecture 09 Applets.
CHAPTER 7 & 8 REVIEW QUESTIONS
Graphical User Interface (pronounced "gooey")
Creation of an Android App By Keith Lynn
Java Programming: From Problem Analysis to Program Design,
Chap 7. Building Java Graphical User Interfaces
Chapter 13: Advanced GUIs and Graphics
Advanced GUIs and Graphics
Presentation transcript:

Field Trip #31 CrossWord Puzzle By Keith Lynn

JApplet A JApplet is a top-level container in Java We will use the JApplet to contain two Jpanels The first JPanel will contain letters The second JPanel will contain words In order to load a JApplet, we create an HTML document The HTML document must contain an applet tag The applet tag must contain the applet's name, width, and height

Appletviewer An alternative to using a browser is to use the appletviewer program that is included in the JDK In order to use the appletviewer program, we create an HTML document where we include an applet tag The applet tag must contain the name of the class, the width and height

LayoutManager A LayoutManager defines how components will be placed onto a screen There are built-in layout managers in Java FlowLayout will put components in a row GridLayout will put components in a grid In this app, we will create a Jpanel to hold letters in buttons and put the buttons in a grid

String A String is a collection of individual characters We can obtain the character at a certain position in a String with the method charAt(int) The first character in a String is at position 0 We can determine the length of the String with the length() method We can concatenate characters to String with the += operator We can compare the content of two Strings with the equals or equalsIgnoreCase methods

Characters A character is a single character There is a special relationship between chars and ints in Java If you treat a char like an int, it is converted to its ASCII equivalent

JComboBox A JComboBox is a selection list It will contain a list of items In this app, we will create many JComboBoxes that contain the letters of the alphabet

JButton A JButton is a component that can be placed on a container The JButton can contain text or an image In this app, we will provide the user with button to give up

Events We can detect events and act on them by creating an event listener An event listener we can use with a button is the ActionListener ActionListener is an interface which contains the method actionPerformed If an ActionListener is registered with a button, then when the button is clicked, actionPerformed is called

Events, cont'd The event listener we will use with the JComboBoxes is the ItemListener The ItemListener interface contains the method itemStateChanged We can determine whether the state change was ItemEvent.SELECTED or ItemEvent.DESELECTED by using the method getStateChange Note that selecting an item in a JComboBox causes both a deselection and a selection event

Arrays Arrays are a collection of elements of the same type In our app, we will use a 2 dimensional array Java doesn't directly support 2 dimensional arrays But we can create an array of arrays We write a 2 dimensional array of 20 x 20 containing JcomboBoxes However, we will black out some boxes

Filling in Words We choose beforehand to black out certain boxes leaving only 26 positions to be filled with words Some of those words overlap We will load from a text file a list of words and definitions and choose 26 words randomly We make sure that we choose words that have the correct letters if the words overlap

The Game After the list of words and clues are loaded and we have chosen the words, we will display the clue for the word in a JComboBox The JComboBoxes corresponding to the word that goes with the clue will be highlighted in red If the user correctly chooses the letters, then the JComboBoxes are highlighted in green If the user gives up, then all of the words are displayed and all JComboBoxes that contains letters of words are highlighted in green