1 / 7

Chapter 12

Chapter 12. A Very Graphic Story. Overview. Simple GUI Getting User Input Creating a Listener ActionEvents Displaying Graphics Drawing Multiple Buttons Animation Example. Simple GUI. Java using 'swing' for GUIs

dick
Download Presentation

Chapter 12

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. Chapter 12 A Very Graphic Story

  2. Overview • Simple GUI • Getting User Input • Creating a Listener • ActionEvents • Displaying Graphics • Drawing • Multiple Buttons • Animation • Example

  3. Simple GUI • Java using 'swing' for GUIs • To display a GUI, you need to 'draw' a window, add content, and display the window • Example Chapter12

  4. Getting User Input • User input is uncertain • You don't want to wait all day for the user • Creating a 'listener' helps handle this • Listeners can be used for all type of input • Serial • Keyboard • Mouse

  5. ActionEvents • We use the ActionEvents class to make listeners • We need to re configure our code to handle this • Then we will • Create an Action Listener object • Link it to a button • Make something happen when the Action Listener reports on the button.

  6. Multiple Buttons (Chapter 13) • Java uses layout managers to place drawing objects • Common ones are: • BorderLayout • FlowLayout • BoxLayout • Lets start with FlowLayout

  7. Multiple Listeners • A simple way is to check the options in a single Listener. • This is not always the best way, but will work for now • Example

More Related