Graphical User Interfaces

19
Graphical User Interfaces Tonga Institute of Higher Education

description

Graphical User Interfaces. Tonga Institute of Higher Education. Graphical User Interfaces. Graphical User Interface – A program that displays program information using windows. GUI Objects. Control Classes used to implement user interface components Message Box / Dialog Box - PowerPoint PPT Presentation

Transcript of Graphical User Interfaces

Page 1: Graphical User Interfaces

Graphical User Interfaces

Tonga Institute of Higher Education

Page 2: Graphical User Interfaces

Graphical User Interfaces

Graphical User Interface – A program that displays program information using windows

Page 3: Graphical User Interfaces

GUI Objects Control

Classes used to implement user interface components

Message Box / Dialog Box An attention getter Displays information to the user Forces user to do something click before continuing Use JOptionPane class

Frames / Windows Frame – Is a container for other GUI elements. Use JFrame class Allows user to see a window Contains other controls

Page 4: Graphical User Interfaces

UI Objects / Controls - 1 Control

Discussed earlier Frame

Discussed earlier Label

Adds text to the window Text Box

Allows user to enter text

Text Box

Label

Frame

Page 5: Graphical User Interfaces

UI Objects / Controls - 2 Combo Box

Allows user to select one option from a list of options The user may see the options when they click on the control

Radio Button Allows user to select an option from a group of options Only one option may be selected at a time Lets users see options

Check Box Allows user to turn one option on or off (True or False)

Combo Box

Radio Button

Check Box

Page 6: Graphical User Interfaces

UI Objects / Controls - 3 Button

Initiates code when clicked

Button

Page 7: Graphical User Interfaces

Packages for GUIs

Abstract Windowing Toolkit (AWT)Older packageStill useful

Swing Very popular

Page 8: Graphical User Interfaces

A Simple Form Tells the class thatIt is a frame

Constructor

PackageNeeded

Settings for the framego in the constructor

Page 9: Graphical User Interfaces

Demonstration

Simple Form

GUIDemo1

Page 10: Graphical User Interfaces

Layouts

FlowLayout Arranges controls in a left-to-right flow. Similar to a paragraph Each line is centered

GridLayout Arranges controls in a rectangular grid Each control is divided into equal-sized rectangles

BorderLayout Arranges controls to fit in 5 regions

NORTH SOUTH WEST EAST CENTER

Only 1 object may be in each region

Page 11: Graphical User Interfaces

Coding LayoutsConstructor

Additional Code Follows

You must includethese steps whenyou set up a layout

Can beFlowLayout,GridLayout, Or BorderLayout

Page 12: Graphical User Interfaces

Demonstration

Layouts

GUIDemo2

Page 13: Graphical User Interfaces

Absolute Positioning

Constructor

Used to put controls exactly in a place that you give coordinates for.

Used to set the exact size of a control.

Set location withx and y coordinates Set size with width

and height values

You must includethese steps!

Page 14: Graphical User Interfaces

Demonstration

Absolute Positioning

GUIDemo3

Page 15: Graphical User Interfaces

Other Controls

Most controlswork the sameway!

Page 16: Graphical User Interfaces

Demonstration

Other Controls

GUIDemo4

Page 17: Graphical User Interfaces

Radio Buttons

Radio Groupscontain Radio Buttons

Page 18: Graphical User Interfaces

Demonstration

Radio Buttons

GUIDemo5

Page 19: Graphical User Interfaces

Code Conventions

Different companies use different prefixes to identify controls Button – btn, cmd Check Box – chk Combo Box – cbo Frame – frm Label – lbl Radio Button – rad, rdo, opt Text Box – txt

Use the ones you like. Be consistent!