Building a GUI in Java With Swing - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

Building a GUI in Java With Swing

Description:

By Marc Loy, Robert Eckstein, Dave Wood, James Elliott, ... Slider. Progress Bar. 12/19/09. Swing for PRG. 13. G51PRG-Sem2. A Dialog Box. 12/19/09. Swing for PRG ... – PowerPoint PPT presentation

Number of Views:277
Avg rating:3.0/5.0
Slides: 23
Provided by: daveel1
Category:
Tags: gui | building | java | slider | spinner | swing

less

Transcript and Presenter's Notes

Title: Building a GUI in Java With Swing


1
Building a GUI in Java With Swing
  • Dave Elliman

2
Useful References
  • Suns Swing tutorial
  • http//java.sun.com/docs/books/tutorial/uiswing/in
    dex.html

Java Swing, 2nd Edition By Marc Loy,
Robert Eckstein, Dave Wood, James Elliott,
Brian Cole2nd Edition November 2002 ISBN
0-596-00408-71278 pages, 38.95 UK
3
Event-driven Programming
  • So far you have a model of a program which starts
    at main() and continues until the end of the
    program.
  • Event-driven programming is rather different. We
    start with main() and build the GUI and then
    await events.

4
What Events?
  • Mouse clicks or double clicks
  • Menu selections
  • Text entered
  • Several more possibilities
  • Window closing (click on the little x in the
    corner)

5
What Sort of Objects Might We Need?
  • Labels (fixed text)
  • TextAreas (enter some text)
  • Buttons
  • Check boxes
  • Radio buttons
  • Tables
  • Menus toolbars etc

6
The Building Blocks
A JFrame
Images taken from the Sun Swing Tutorial
7
JTextField and JLabel
8
Buttons
Toolbar
9
JList and JComboBox
10
A Menu
11
Panels and Panes
Tabbed Pane
Split Pane
Scroll Pane
12
Various Indicators
Spinner
Slider
Progress Bar
13
A Dialog Box
14
JFileChooser
15
Colour Chooser
16
Jtable
17
JTree
18
Various Text Fields
19
All These Are COMPONENTS
  • You can add LISTENERS which will respond to the
    appropriate events.
  • An Event is an object that was introduced in an
    earlier Java set of GUI classes known as AWT.

20
Events and Listeners
  • User clicks a button, presses Return while
    typing in a text field, or chooses a menu item
    ActionListener
  • User closes a frame (main window) WindowListener
  • User presses a mouse button while the cursor is
    over a component MouseListener or User moves the
    mouse over a component MouseMotionListener

21
(No Transcript)
22
For Better Examples
http//java.sun.com/products/jfc/tsc/sightings/
Lets do it for real.
Write a Comment
User Comments (0)
About PowerShow.com