1 / 12

COMP 172 Event-driven programing and GUI

COMP 172 Event-driven programing and GUI. Sequential programming. Control Step-by-step under control of the program More like a conversation between program and user Presentation Console text messages, keyboard text input. Event-driven programming. Control Shared between user and program

willa
Download Presentation

COMP 172 Event-driven programing and GUI

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COMP 172Event-driven programing and GUI

  2. Sequential programming • Control • Step-by-step under control of the program • More like a conversation between program and user • Presentation • Console text messages, keyboard text input

  3. Event-driven programming • Control • Shared between user and program • Based on what the user does (events) • Presentation • Graphical, icons, buttons, textfields radio buttons, etc

  4. Event- driven programming • Each component may have one or more associated events • Mouse click, mouse entered, item selected etc • Event listeners are attached to these components and "listen" for the event to occur

  5. Event- driven programming When a listeners detects an event, it calls the associated Event handler Code within each event handler uses application classes to solve the underlying problem Called the Model-View-Controller paradigm.

  6. Structure of software Translation Event handlers take information from the GUI and translate it as needed, then send to application Controller Take what comes back and format it for GUI display Graphical user interface components View This is what the user sees and interacts with Application The classes and methods that solve the problem Model Send info back

  7. Example Application Dog class Translation Button event handler GUI for Dog Feeding

  8. Structure of GUI in Java • Applet • Runs inside browser • Browser is root or primary "window" • Application • Runs independently • JFrame substitutes for main class/method • Acts as the root or primary "window"

  9. Components • To give the user limited choices • Menus • Radio buttons (only one selected) • Checkboxes (multiple selections) • Combo boxes

  10. Components • To allow the user to enter any input • Text fields • Text areas • To make something happen • Buttons (using mouse) • Mouse input (enter, scroll, down/up)

More Related