Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

GUI - Introduction to Programming in Java - Lecture Slides, Slides of Network security

The key points are:Gui Features, Reminder, Painting With Jpanel, Final Imageviewer, Listener Interfaces, Mouse Example, Doodle, Adapter Classes, More Information, Swingset Examples

Typology: Slides

2012/2013

Uploaded on 04/22/2013

sathaye
sathaye 🇮🇳

4.8

(8)

106 documents

1 / 63

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Objectives
describe some of the GUI controls and their
listeners; more appear in part 13
12. GUI Examples I
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f

Partial preview of the text

Download GUI - Introduction to Programming in Java - Lecture Slides and more Slides Network security in PDF only on Docsity!

Objectives

  • describe some of the GUI controls and their listeners; more appear in part 13 12. GUI Examples I

Contents

1. Three Step GUI

2. Swing GUI Overview

3. Swing Hierarchy

4. Listener Interfaces

5. Button Example

6. TextField Example

7. Check Boxes Example

8. Radio Buttons Example

9. Combo Box Example

2. Swing GUI Overview

  • The Swing GUI has six categories:
    • basic components
    • uneditable displays
    • interactive displays of highly formatted info
    • general-purpose containers
    • top-level containers
    • special-purpose containers

We will look at code examples using the GUI components listed in bold.

2.1. Basic Components

  • Component Swing Class Name
    • button JButton , JCheckBox , JRadioButton
    • combo box JComboBox
    • list JList
    • menu JMenu, JMenuBar, JMenuItem
    • slider JSlider
    • text field JTextField , JPasswordField

2.2. Uneditable Displays

  • Display Swing Class Name
    • label JLabel
    • Tooltip JToolTip
    • Progress bar JProgressBar

2. 3. Interactive Displays

  • Display Swing Class Name
    • table JTable
    • text JTextPane, JTextArea, JEditorPane
    • tree JColorChooser
    • file chooser JFileChooser
    1. General Purpose Containers
  • Container Swing Class Name
    • panel JPanel
    • scroll pane JScrollPane , JScrollBar
    • split pane JSplitPane
    • tabbed pane JTabbedPane
    • toolbar JToolbar

2. 6. Special-Purpose Containers

  • Container Swing Class Name
    • internal frame JInternalFrame
    • layered pane JLayeredPane
    • root pane JRootPane

indirectly used by top-level containers to gain access to the content pane and other 'layers' of a container

3. Swing Hierarchy (partial)

java.lang.Object

java.awt.Component (abstract)

java.awt.Container

javax.swing.JComponent (abstract)

continued

extends

Swing uses a AWT component to draw the blank window area.

The GUI in the window is drawn by Swing.

AbstractButton (abstract)

JMenuItem JMenu

JToggleButton JRadioButton

JButton^ JCheckBox

JTextComponent (abstract)

JEditorPane

JTextField

JTextArea

JLabel

JPanel

JScrollPane

GUI controls inherit many methods.

JToolTip

Not the whole hierarchy

extends

4. Listener Interfaces

  • I'll look at 4 listener interfaces that can

handle events from different GUI

components

  • ActionListener
  • ItemListener
  • MouseListener
  • MouseMotionListener
  • There are several other listener interfaces.

I'll use these two in this part

in part 13

4.1. ActionListener

  • ActionListener can deal with events from:
    • JButton (most common)
    • JMenu, JMenuItem, JRadioButton, JCheckBox
      • when pressed
    • JTextField
      • when is typed
  • The interface has one method:

public void actionPerformed(ActionEvent e)