DOC PREVIEW
TRINITY CSCI 1321 - Lecture Notes

This preview shows page 1-2 out of 7 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 71GUIs and Events2-18-20102Opening Discussion■Let's look at solutions to the interclass problem.■Do you have any questions about the assignment?■Benefits of immutable.■How did you get user input in C? Will this work for a GUI?3Our GUI■Let's write a little GUI. I want a JTree on the left side of the frame with buttons above and/or below that say “Add” and “Remove”, a panel in the middle, and on the right I want a GUI that might be used for setting properties on a rectangle. At the least I'd like to set a width, height, and color.■Let's give the frame a menu bar. For now we can just add a “File” menu and have an “Exit” selection in it.4Event Handling■So far we have only talked about how we set up our GUIs. They don't really do anything though because we have not learned how to make them interact with the user.■In Java 1.1 the method of dealing with “events” in GUIs was changed to use event listeners. These are classes that sit around and wait for something to happen. When it happens the listeners are notified.■This is very different from the way you got user input in C. It has to be because the C model doesn't make sense. The C model only handles one source of input and blocks.5Listeners and Events■The foundations of event handling in Java are listeners and events. Each component has appropriate add methods that let you add listeners for the various things that component can do.■The simplest example is a button where basically all you can do is click it. To have Java tell us about the click on a button we would use an ActionListener.■The ActionListener has a method, actionPerformed, that is passed an ActionEvent. This tells us information about the event.■Let's go look in java.awt.event at some listeners and events.6Coding■We want to fill out our drawing application some. We want to focus some on the GUI elements and making them interact with the user.■There is also a fair bit of design work that goes into this. Let's talk a bit about what I want our drawing program to do then try to write some of the component to make it happen.7Minute Essay■Do you have any questions about how our “drawing” program is going to work? Is Java becoming more natural to you? What aspects of Java, if any, hang you up some?■Assignment #2 is due today.■Interclass problem – Put some listeners on your GUI so that pressing the buttons changes the display. Don't try to go for full calculator functionality


View Full Document

TRINITY CSCI 1321 - Lecture Notes

Documents in this Course
Recursion

Recursion

11 pages

Iterators

Iterators

10 pages

Actors

Actors

9 pages

Recursion

Recursion

15 pages

Recursion

Recursion

10 pages

Threads

Threads

7 pages

Trees

Trees

11 pages

Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?