Clicker quiz 11/5/13 CSE 1102 Fall 2013. A. a FlowLayout B. a BorderLayout C. a GridGrouping D. a JSplitPane E. a GridLayout Suppose we want to to lay.

Slides:



Advertisements
Similar presentations
1 Graphical User Interface (GUI) Applications Abstract Windowing Toolkit (AWT) Events Handling Applets.
Advertisements

Java GUI building with the AWT. AWT (Abstract Window Toolkit) Present in all Java implementations Described in (almost) every Java textbook Adequate for.
Graphical User Interfaces
Graphical User Interfaces (Part IV)
Java Software Development Paradigm Lecture # 12. Basics of GUI.
Graphic User Interfaces Layout Managers Event Handling.
F27SB2 Programming Languages
TCU CoSc Programming with Java Handling Events.
CMSC 341 Building Java GUIs. 09/26/2007 CMSC 341 GUI 2 Why Java GUI Development? Course is about Data Structures, not GUIs. We are giving you the opportunity.
Fall 2007CS 225 Graphical User Interfaces Event Handling Appendix C.
Event-Driven Programming Thus far, our programs have been executed one statement after the other However, many programs depend on user actions to dictate.
© The McGraw-Hill Companies, 2006 Chapter 10 Graphics and event- driven programs.
Chapter 13: Advanced GUIs and Graphics J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Scott Grissom, copyright 2006Ch 11: GUI Slide 1 Graphical User Interfaces (Ch 11) Careful design of a graphical user interface is key to a viable software.
Chapter 13 Advanced GUIs and Graphics. Chapter Objectives Learn about applets Explore the class Graphics Learn about the class Font Explore the class.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Java Programming: From Problem Analysis to Program Design, 4e Chapter 12 Advanced GUIs and Graphics.
Introduction to GUI in Java 1. Graphical User Interface Java is equipped with many powerful,easy to use GUI component such as input and output dialog.
Adding Graphics to a Frame Application Applets: Can generate drawings by overriding paint Frame: Do not draw directly on a frame. Draw graphics on a JPanel.
Java Programming: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
By: Stag and Fish; Party Animals.  Radio buttons are a way of letting users choose only one option of a list.
GUI Components and Design Here we add one more component to our programs, JButtons –JButtons can only be inserted into JPanels (or JApplets) –Clicking.
Java GUI’s are event driven, meaning they generate events when the user interacts with the program. Typical events are moving the mouse, clicking a mouse.
Session 11 Border Layout, using Panels, Introduction to PinBallGame.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
1 Outline 1 Introduction 2 Overview of Swing Components 3 JLabel 4 Event Handling 5 TextFields 6 How Event Handling Works 7 JButton 8 JCheckBox and JRadioButton.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
Copyright © 2002, Systems and Computer Engineering, Carleton University c-Gui3.ppt * Object-Oriented Software Development Part 18-c Building.
Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013.
MSc Workshop - © S. Kamin, U. ReddyLect 3 - GUI -1 Lecture 3 - Graphical User Interfaces r GUI toolkits in Java API r JFrame r GUI components.
Chapter 12 1 TOPIC 13B l Buttons and Action Listeners Window Interfaces Using Swing Objects.
Object Oriented programming Instructor: Dr. Essam H. Houssein.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
GUI Programming using NetBeans. RHS – SOC 2 GUI construction We have previously talked about elements in a (simple) GUI –Frames, Panes and Dialogs –Text.
1 / 67 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 14 Programming Fundamentals using Java 1.
CS324e - Elements of Graphics and Visualization Java GUIs - Event Handling.
Lec.10 (Chapter 8 & 9) GUI Jiang (Jen) ZHENG June 27 th, 2005.
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
SEEM3460 Tutorial GUI in Java. Some Basic GUI Terms Component (Control in some languages) the basic GUI unit something visible something that user can.
Introduction to GUI in 1 Graphical User Interface 2 Nouf Almunyif.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
Review_6 AWT, Swing, ActionListener, and Graphics.
1 Event Driven Programs with a Graphical User Interface Rick Mercer.
Creating a GUI Class An example of class design using inheritance and interfaces.
Graphical User Interfaces (GUI). PART ONE About GUI’s.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
Swing GUI Components So far, we have written GUI applications which can ‘ draw ’. These applications are simple, yet typical of all Java GUI applications.
Event Handler Methods Text field Object Responder JAVA AWT Environment: Messages are sent between JAVA Objects Screen Event Notification Press Button.
Introduction to GUI in 1 Graphical User Interface 3 Nouf Almunyif.
Quick topix 11/7/13 CSE 1102 Fall previous statement Execute rest of program Is true? yes no This flowchart illustrates the logic of a _________.
Introduction to GUI Programming in Java: Frames, Simple Components, and Layouts.
5-1 GUIs and Events Rick Mercer. 5-2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces to respond.
Java Programming Fifth Edition Chapter 13 Introduction to Swing Components.
AWT Vs SWING. 2 AWT (Abstract Window Toolkit) Present in all Java implementations Described in most Java textbooks Adequate for many applications Uses.
Clicker quiz 10/22/13 CSE 1102 Fall 2013.
GUIs and Events Rick Mercer.
A First Look at GUI Applications Radio Buttons and Check Boxes
Topics Graphical User Interfaces Using the tkinter Module
A First Look at GUI Applications
“Form Ever Follows Function” Louis Henri Sullivan
Java GUI.
Chap 7. Building Java Graphical User Interfaces
Chapter 13: Advanced GUIs and Graphics
Graphical User Interfaces -- Introduction
PC02 Term 1 Project Basic Messenger. PC02 Term 1 Project Basic Messenger.
Introduction to Computing Using Java
Advanced GUIs and Graphics
Presentation transcript:

Clicker quiz 11/5/13 CSE 1102 Fall 2013

A. a FlowLayout B. a BorderLayout C. a GridGrouping D. a JSplitPane E. a GridLayout Suppose we want to to lay things out in a Frame such that there is panel in the center, with other panels to the right, below, and to the left. The most straightforward way to do this it to use:

A. the event source B. the event listener C. the event responder D. it doesn’t fit this model E. it doesn’t use events Suppose we add a slider to our program using a JSlider. To make it useful, we need to deal with events associated with that slider. Using our “standard” source-listener-responder event handling model, the JSlider is

A. a group of buttons that will be contiguous on the screen B. a group of buttons that allows at most one to be selected C. a group of buttons that can only have a single listener D. all of the above E. none of the above One of the API classes introduced in Chapter 8 was ButtonGroup, a class that will be associated with a group of (surprise, surprise) Buttons. The ButtonGroup can be used to set up

Clicker questions 11/5/13 CSE 1102 Fall 2013

A. Four pairs, and it’s obvious. B. Two sets of four, and it’s obvious. C. It’s not obvious, but it is consistent. D. The groupings could be completely arbitrary. E. It’s always OK to just try them out. How do you imagine the buttons are grouped?

A. They will be on the bottom, one over another B. They will be on the left side, one over another; C. They will be on the bottom in a single row; D. They will not show up on the screen E. None of the above is true 1.public ColorButtonPanel extends javax.swing.JPanel { 2.private JRadioButton _redButton; 3. private JRadioButton _blueButton; 4. private JRadioButton _greenButton; 5.public ColorButtonPanel(){ 6. _redButton = new JRadioButton("red",true); 7. _blueButton = new JRadioButton("blue"); 8. _greenButton = new JRadioButton("green"); 9. } } Suppose we add a ColorButtonPanel to JFrame _myFrame using _myFrame.add(new ColorButtonPanel(), "South"); Assuming we added something else to the Center of _myFrame, where will the buttons show up on the screen?

A. Neither button is seen as selected (filled circle) B. The red button is seen as selected, the blue not; C. The blue button is seen as selected, the red not selected D. Both buttons will be selected E. The buttons will not be changed no matter where I click 1.public class ColorButtonPanel extends javax.swing.JPanel { 2.private JRadioButton _redButton; 3. private JRadioButton _blueButton; 4.public ColorButtonPanel(){ 5. _redButton = new JRadioButton("red",true); 6. _blueButton = new JRadioButton("blue"); 7. this.add(_redButton); 8. this.add(_blueButton); 9. } } Suppose we add a ColorButtonPanel to JFrame _myFrame using _myFrame.add(new ColorButtonPanel, "South"); What happens when I click on the Button labeled "blue"?

A. You need to add an ActionListener to the ButtonGroup B. You need to add an ActionListener to ColorButtonPanel C. You need to add a ItemListener to the ColorButtonPanel D. You need to add an ActionListener to each JRadioButton E. More than one of the solutions above would work 1.public class ColorButtonPanel extends javax.swing.JPanel { 2.private JRadioButton _redButton; 3. private JRadioButton _blueButton; 4. private ButtonGroup _myGroup; 5.public ColorButtonPanel(){ 6. _redButton = new JRadioButton("red",true); 7. _blueButton = new JRadioButton("blue"); 8. _myGroup = new ButtonGroup(); 9. this.add(_redButton); 10. this.add(_blueButton); 11. _myGroup.add(_redButton); 12. _myGroup.add(_blueButton); 13. } } What code do I need so that something happens in my program (not just to the appearance of the buttons) when I click on one of them?

A. this.addMouseListener(new MouseStuff(this)); B. this.addMouseListener(this); C. this.addMouseAdapter(new MouseStuff(this)); D. this.addMouseAdapter(this); E. None of the above 1.public class MickeyPanel extends javax.swing.JPanel { 2. public MickeyPanel(){ ???? 5. } 6. private class MouseStuff extends MouseAdapter { 7. private JPanel _myPanel; 8. public MouseStuff(JPanel panel){ 9. _myPanel = panel; 10. } 11. public void mouseClicked(MouseEvent e) { 12. _myPanel.doSomething(); 13. } 14. }} What code do I need in line 4 that would install a MouseStuff as a MouseListener for MickeyPanel?

A. this.addMouseListener(new MouseStuff(this)); B. this.addMouseListener(this); C. this.addMouseAdapter(new MouseStuff(this)); D. this.addMouseAdapter(this); E. None of the above 1.public class MickeyPanel extends javax.swing.JPanel { 2. public MickeyPanel(){ } 6. public void addListener{Object anObject} 7. { } What code do I need in line 4 that would install a MouseStuff as a MouseListener for MickeyPanel?

Suppose it was desired to build a GUI offering the user a choice between a slider, or a numeric entry field to enter data to be entered into the same variable. Which answer best describes the consequences this has for sources, listeners and responders? A. It follows our “standard pattern”: Each responder class includes a private class for its listener. An instance of that listener is to be registered with the class that contains it. A method in the private class is called upon user activation of that affordance. This method sends a message to the responder object(s). B. The slider and the numeric entry field have to be peer objects. C. It is probably efficient of code to have both affordances sharing a container. D. It’s not possible to code this. E. The standard pattern’s meaning now includes that GUI components (sources) get updated even when the user has not “touched” them.

Suppose it was desired to build a GUI showing the user radio buttons whose groupings changed in response to user choices. Which answer best describes the consequences this has for layout, grouping, sources, listeners and responders? A. It follows our “standard pattern”: Each responder class includes a private class for its listener. An instance of that listener is to be registered with the class that contains it. A method in the private class is called upon user activation of that affordance. This method sends a message to the responder object(s). B. All of the buttons have to be peer objects. C. It is probably efficient of code to have all the buttons sharing a container. D. It’s not possible to code this. E. The group affiliation of buttons can be dynamic: New groups can be made.

Suppose it was desired to build a GUI showing the user radio buttons whose groupings changed in response to user choices. How do we know the old groupings are removed in time for the next user action? A.We can invoke the garbage collector. B. If there are no pointers to the old groups, the garbage collector will remove them. C. Removing a common container will remove the groups because these form a composite. D. It’s not possible to code this. E. None of the above is adequate, so ButtonGroup has a remove method.

Development system software exists that can create Java code for GUIs, automatically, when presented correctly with the desired user interface widgets. Which reason below best captures why students need to know how to write this Java themselves? A.The automatically generated code might contain bugs. B. The system automatically generating the code might be too limiting. C. When employing a combination of several technologies, it can be necessary to examine how they work together, which can require inspecting the code. D. There is no such automatic code generation. E. You may want to mesh some new idea into what is automatically created, and that will involve working with the automatically generated code.

A. You are already using the desired listener as an ActionListener for something else B. You want to associate the button actions with becoming deselected C. You want to reduce the number of messages sent to the listeners D. You want actions to be associated with both becoming selected and deselected E. All of the above are circumstances where ItemListener is a better choice If I add an ItemListener to a Button in a ButtonGroup, it will invoke itemStateChangeditemStateChanged(ItemEvent) in that listener whenever the button changes from selected to deselected or vice-versa.ItemEvent This might be preferable to using an ActionListener in some circumstances. Which of the following is not one of these circumstances?