1 / 7

Announcements & Review

Read Ch GU1 & GU2 Cohoon & Davidson Ch 14 Reges & Stepp Lab 10 set game due 4/26 Exam 2 Wed 5/2 5:30-7:30. Last week: Array Lists Linked Lists Searching with Boyer/Moore Next two weeks: GUI - graphical user interfaces. Announcements & Review. Graphical User Interface (GUI).

ivy
Download Presentation

Announcements & Review

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. Read Ch GU1 & GU2 Cohoon & Davidson Ch 14 Reges & Stepp Lab 10 set game due 4/26 Exam 2 Wed 5/2 5:30-7:30 Last week: Array Lists Linked Lists Searching with Boyer/Moore Next two weeks: GUI - graphical user interfaces Announcements & Review Lecture 32: Graphical User Interface (GUI)

  2. Graphical User Interface (GUI) • Java was in part designed for web applications • Previously the OS provided all the GUI • Library philosophy: grow widely reused and desirable functionality in libraries • libraries are separate from the language • examples: collections, file input, Color • some programmer went on from 305j to write Java library routines ;-) • GUI library makes it easier to write interactive applications Lecture 32: Graphical User Interface (GUI)

  3. GUI Basics • Graphical input/output using JFrames • a JFrame contains on screen components • e.g., buttons, labels, text, scroll bars, images, ... • Layout • arranges components in a Frame • Events • detecting and acting on user input Lecture 32: Graphical User Interface (GUI)

  4. GUI Code Structure • GUI structure differs substantially from our programming model so far • model so far • main has a bunch of statements Java does in order, • when we get to the end, we are finished • GUI model • main creates a GUI object & that’s it!? • The class GUI constructor registers a “listener” method with an event (e.g., a button selection) • When that event occurs, Java calls the “listener” method • “listener” gathers the user input and acts on it Lecture 32: Graphical User Interface (GUI)

  5. GUI Interface Remember: an interface is not a class, but a partial definition of what needs to be in a class 1. Cannot specify method implementations 2. All methods in an interface are public 3. All variables are public, final, and static 4. A class can implement multiple interfaces public interface ActionListener { // constants // method declarations public void actionPerformed (ActionEvent e) } public class QuestionGUI implementsActionListener {...} Lecture 32: Graphical User Interface (GUI)

  6. A Basic GUI public class QuestionGUI implementsActionListener { // window instance variables private JFrame window = new JFrame(“Review Questions”); public QuestionGUI() { // constructor that creates the GUI window, text, etc. window.add(...); } public void actionPerformed (ActionEvent e) { // grabs user input out of GUI and acts on it } public static void main (String[] args) { QuestionGUI qgui = new QuestionGUI(); } } Lecture 32: Graphical User Interface (GUI)

  7. A Basic GUI • Let’s go work with the code Lecture 32: Graphical User Interface (GUI)

More Related