Java GUI Elements: Components, Containers, Layout, and Events - Prof. Nelson Padua-Perez, Study notes of Computer Science

An overview of java gui elements, including components (labels, text areas, buttons, etc.), containers (windows, menus, toolbars), layout (arrangement of widgets), and events (mouse clicks, keyboard input, menu selections). It also covers java gui classes (awt and swing), layout managers (gridlayout, borderlayout, cardlayout, gridbaglayout), and examples of creating jframe, jtextfield, jlabel, buttons, jlist, jcombobox, menus, panels, and dialog boxes.

Typology: Study notes

Pre 2010

Uploaded on 07/30/2009

koofers-user-dab
koofers-user-dab 🇺🇸

9 documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
1
GUI Elements in Java
Nelson Padua-Perez
Chau-Wen Tseng
Department of Computer Science
University of Maryland, College Park
2
GUI Elements
Component items displayed (widgets)
Container region containing widgets
Layout arrangement of container
Event interactions for GUI
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Java GUI Elements: Components, Containers, Layout, and Events - Prof. Nelson Padua-Perez and more Study notes Computer Science in PDF only on Docsity!

1

GUI Elements in Java

Nelson Padua-Perez

Chau-Wen Tseng

Department of Computer Science

University of Maryland, College Park

2

GUI Elements

Component ⇒ items displayed (widgets)

Container ⇒ region containing widgets

Layout ⇒ arrangement of container

Event ⇒ interactions for GUI

3

GUI Elements – Component

Definition

Actual items (widgets) user sees in GUI

Examples

Labels (fixed text) Text areas (for entering text) Buttons Checkboxes Tables Menus Toolbars Etc…

4

GUI Elements – Container

Definition

Abstractions occupying space in GUI

Properties

Usually contain one or more widgets Can be nested in other containers

Example

Window containing 1 menu (component) 3 buttons (component) 2 windows (container)

7

GUI Elements – Events

Definition

Action or condition occurring outside normal flow of control of program

Examples

Mouse clicks Keyboard input Menu selections Window actions

8

Java GUI Classes

AWT (Abstract Window Toolkit) (java.awt.*)

Old GUI framework for Java (Java 1.1) Some reliance on native code counterparts Platform independence problems

Swing (javax.swing.*)

New GUI framework first introduced in Java 1. Includes AWT features plus many enhancements Pure Java components (no reliance on native code) Pluggable look and feel architecture

9

JFrame Hierarchy

Several super classes and well as implemented interfaces

Many, many member methods including inherited methods that allow for operations such as resizing, setting properties, adding components, etc.

Other top level containers JDialog (dialog boxes) JApplet (web applets) JWindow (stripped down JFrame, no title bar or window buttons)

Object

Component

Container

Window

Frame

JFrame

10

Java GUI Components

Examples JFrame JTextfield Jlabel Button JList JComboBox Menu Combo

Panes Indicators Dialog boxes JFileChooser Color chooser JTable JTree

13

JFrame

14

JTextField and JLabel

15

Buttons

Toolbar

16

JList and JComboBox

19

Various Indicators

Spinner

Slider

Progress Bar

20

A Dialog Box

21

JFileChooser

22

Color Chooser