Section 64 - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

Section 64

Description:

Chapter 3 Section 64 Manipulating Data Using Methods Java Swing Chapter Objectives Use Swing components to build the GUI for a Swing program ... – PowerPoint PPT presentation

Number of Views:36
Avg rating:3.0/5.0
Slides: 11
Provided by: Steven894
Category:
Tags: concepts | java | section

less

Transcript and Presenter's Notes

Title: Section 64


1
Chapter 3
  • Section 64
  • Manipulating Data Using Methods Java
    Swing

2
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

3
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

4
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

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

6
Swing Dialog Boxes

7
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

8
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

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

10
Rest of Today
  • Complete the swing version of the Bass Mass
    Calculator
  • Test your results
  • Show me the program when it is complete
Write a Comment
User Comments (0)
About PowerShow.com