Section 64 – Manipulating Data Using Methods – Java Swing

Slides:



Advertisements
Similar presentations
Chapter 8 Improving the User Interface
Advertisements

Java Programming, 3e Concepts and Techniques Chapter 3 Section 63 – Manipulating Data Using Methods – Day 2.
Java Programming, 3e Concepts and Techniques Chapter 4 Decision Making and Repetition with Reusable Objects.
Chapter 2 - Introduction to Java Applications
Dialogs. Displaying Text in a Dialog Box Windows and dialog boxes –Up to this our output has been to the screen –Many Java applications use these to display.
Using JOptionPanes for graphical communication with our programs. Pages Horstmann 139.
Chapter 5: Keyboard I/O & Simple GUI’s Copyright 2002, Matthew Evett. These slides are based on slides copyrighted by John Lewis and William Loftus, 2002,
Java Programming, 3e Concepts and Techniques Chapter 3 Manipulating Data Using Methods.
Introduction to Computers and Programming Lecture 3: Variables and Input Professor: Evan Korth New York University.
School of Computing Science CMT1000 Ed Currie © Middlesex University Lecture 4: 1 CMT1000: Introduction to Programming Ed Currie Lecture 5a: Input and.
Chapter 2 - Introduction to Java Applications
Chapter 11: Handling Exceptions and Events J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Fourth.
1 Class 8. 2 Chapter Objectives Use Swing components to build the GUI for a Swing program Implement an ActionListener to handle events Add interface components.
JOptionPane class. Dialog Boxes A dialog box is a small graphical window that displays a message to the user or requests input. A variety of dialog boxes.
Java Programming, 2E Introductory Concepts and Techniques Chapter 3 Manipulating Data Using Methods.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 62 – Manipulating Data Using Methods – Day 1.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
Intro to GUIs (Graphical User Interfaces) Section 2.5Intro. to GUIs: a GUI Greeter Section 3.7Graphical/Internet Java: Einstein's Equation.
Java Programming, Second Edition Chapter Five Input and Selection.
Visual Basic.NET BASICS Lesson 5 Exponentiation, Order of Operations, and Error Handling.
 2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 2 - Introduction to Java Applications Outline 2.1Introduction 2.2A Simple Program: Printing a.
1 Java Programming 1 Introduction to Basic GUI Lesson 4.
1 COMP 241: Object-Oriented Programming with Java Fall 2004 Lecture 1 September 27, 2004 Serdar Taşıran.
Chapter 12 Handling Exceptions and Events. Chapter Objectives Learn what an exception is Become aware of the hierarchy of exception classes Learn about.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 – Graphical User Interfaces Java Foundations: Introduction to Programming.
Dialog Boxes.
GUI Graphical User Interface Each onscreen component and window is an object Object interaction makes communication and scoping challenging Event-driven.
Java Programming, 2E Introductory Concepts and Techniques Chapter 4 Decision Making and Repetition with Reusable Objects.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 11 Handling Exceptions and Events.
1 Class 6. 2 Objectives Objectives Identify, declare, and use primitive data types Use the System class to create data streams Use the Scanner class of.
Exceptions. Exception  Abnormal event occurring during program execution  Examples Manipulate nonexistent files FileReader in = new FileReader("mumbers.txt“);
Files and console applications Chapter 17 This chapter explains: What a file is How to read and write to files How to manipulate folder paths and file.
SE-1020 Dr. Mark L. Hornick 1 Graphical User Interfaces.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
Creating and Using Dialogs ● A dialog is a box that pops up and prompts the user for a value or informs them of something ● One way: directly create objects.
Introduction to GUI in 1 Graphical User Interface Nouf Almunyif.
AP Java 10/1/2015. public class Rolling { public static void main( String [] args) public static void main( String [] args) { int roll; int roll; for.
5.01 Understand Different Types of Programming Errors
Topics Graphical User Interfaces Using the tkinter Module
3 Introduction to Classes and Objects.
OBJECT ORIENTED PROGRAMMING I LECTURE 7 GEORGE KOUTSOGIANNAKIS
“Form Ever Follows Function” Louis Henri Sullivan
Chapter Topics 15.1 Graphical User Interfaces
Objectives You should be able to describe: Interactive Keyboard Input
AP Java 10/4/2016.
How to Fi
2.5 Another Java Application: Adding Integers
Message, Input, Confirm, and Specialized Dialogs
Objectives Learn about Function procedures (functions), Sub procedures (subroutines), and modules Review and modify an existing subroutine in an event.
5.01 Understand Different Types of Programming Errors
OBJECT ORIENTED PROGRAMMING I LECTURE 7 GEORGE KOUTSOGIANNAKIS
CS18000: Problem Solving and Object-Oriented Programming
Chapter 2 - Introduction to Java Applications
Applets.
AP Java 10/4/2016.
Message, Input, and Confirm Dialogs
Chapter 15: GUI Applications & Event-Driven Programming
Constructors, GUI’s(Using Swing) and ActionListner
Chapter 5 Processing Input with Applets
Basic Lessons 5 & 6 Mr. Kalmes.
Exceptions.
Running a Java Program using Blue Jay.
JOptionPane class.
F II 2. Simple Java Programs Objectives
Exceptions.
Java Programming: From Problem Analysis to Program Design, 4e
Chapter 2: Java Fundamentals cont’d
Tutorial 11 Using and Writing Visual Basic for Applications Code
Presentation transcript:

Section 64 – Manipulating Data Using Methods – Java Swing Chapter 3 Section 64 – Manipulating Data Using Methods – Java Swing

Chapter Objectives Use Swing components to build the GUI for a Swing program Use the exit() method to close a Swing program Implement an ActionListener to handle events

Using Swing Components Make a copy of your BodyMass.java program. Right click on BodyMass.java and select copy Paste a copy – Right click on bodymasscalculator

Using Swing Components Import the javax.swing.JOptionPane class Contains methods to create dialog boxes for input, confirmation, and messages Delete the IOException and BufferedReader code The swing dialog boxes buffer data from the user and handle IO errors

Swing Dialog Boxes Dialog boxes are created with the JOptionPane “show” methods The showInputDialog() and showConfirmDialog return a String containing the user input

Swing Dialog Boxes

Closing Programs that use Swing System.exit() terminates an application that displays a GUI The command prompt window closes when this method is called System.exit accepts an integer argument that serves as a status code 0 indicates successful termination 1 indicates abnormal termination

Saving, Compiling, and Running the Swing Version Compile the source code Test with the same sample data for all versions to compare output results If incorrect or unrealistic data is entered by the user, errors will occur Errors and exception handling will be discussed in a later chapter

Summary Java Swing code allows the programmer to easily display pop up windows to get input and to display output.

Rest of Today Complete the swing version of the Bass Mass Calculator Test your results Show me the program when it is complete