03_gui - Graphical User Interface (GUI) and Object-Oriented...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
A comment on these PPT slides These slides are being used to teach, not to give a business-style presentation. On the whole, there will be less text than in a Word document, but there will also be much more in the way of ‘visuals’. Still, I will frequently have “busy” slides in the same way that lecture notes in Word format have lots of information. In other words, I’m not going to even try to stick to the “6x6” rule commonly emphasized for giving presentations in Powerpoint format.
Background image of page 2
‘Getting’ GUIs Some of this material – particularly when we talk about “Event Handling” will be confusing initially. The way to learn and be able to design and use your GUIs comes with practice. Be sure that you type out every example on your own . Each time you type an example, try to modify it a little bit. Be sure to review these concepts. That is, even once you pretty much ‘get’ or can replicate a certain technique, come back to it a few times over the next week. This will help immensely. So, in this lecture particularly in “Event Handling” : 1) Type it out on your own 2) Repeat 3) Experiment 4) Return to the material a few times over the week
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Chapter Objectives Learn about basic GUI components Explore how the GUI components JFrame , JLabel , JTextField , and JButton work Become familiar with the concept of “event-driven” programming through the use of events and their corresponding event handlers
Background image of page 4
Rectangle Calculator See file: RectangleConsole.java Uses the console (command window) Solution: A better interface The best interfaces are typically graphical in nature (compare DOS v.s. Windows) Some graphical interfaces are better (much!) than others
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Better Rectangle Calculator See file: Rectangle.java Uses JOptionPane methods (showInputDialog, showMessageDialog) to read input and output results Could easily do the same with Scanner class Limitations: Windows show up one at a time Can’t go back to a previous window if you make a mistake Solution: Continue to improve the interface
Background image of page 6
Graphical User Interface (GUI) Here is an improved version of the Rectangle calculator using a much better GUI View inputs and outputs simultaneously One graphical window Input values in any order Change input values in window Click on buttons to get output
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Creating a Java GUI Java comes prepackaged with many classes that allow you to create GUIs. Currently, the favorite way of doing this is by instantiating a series of GUI objects These objects will be instantiated from a series of classes from a package called javax.swing You’ve already seen one of them: The JOptionPane class is from the Swing package So we will now have to get in the habit of importing this package: import javax.swing.*; There are classes to create buttons (class JButton ), labels (class
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 71

03_gui - Graphical User Interface (GUI) and Object-Oriented...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online