CISC124 Quiz 3 marking underway. Assn 5 due Friday. Fall 2018

Slides:



Advertisements
Similar presentations
What is a Dialog box? A Dialog box is a window or “form” that contains other child windows or “controls” that have a specific appearances and pre-defined.
Advertisements

1. Chapter 29 Creating Forms 3 Understanding Forms Word enables you to create fill-in forms to eliminate the need for storing pre-printed forms. Add.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. 1 Chapter 16 JavaFX UI Controls and Multimedia.
C# Programming: From Problem Analysis to Program Design1 Programming Based on Events C# Programming: From Problem Analysis to Program Design 3 rd Edition.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
8 Copyright © 2004, Oracle. All rights reserved. Creating LOVs and Editors.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
Lab 9 – User Forms Design. User Forms What are user forms? –Known as dialog boxes –Major ways for getting user input An example of using user forms: Monthly.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
Chapter 12: Using Controls. Examining the IDE’s Automatically Generated Code A new Windows Forms project has been started and given the name FormWithALabelAndAButton.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Chapter 8 Collecting Data with Forms. Chapter 8 Lessons Introduction 1.Plan and create a form 2.Edit and format a form 3.Work with form objects 4.Test.
 Whether using paper forms or forms on the web, forms are used for gathering information. User enter information into designated areas, or fields. Forms.
Dreamweaver MX. 2 Overview of Templates n Forms enable you to collect data from ______. n A form contains ________ such as text fields, radio buttons,
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Topics Introduction Scene Graphs
Win32 Controls & ActiveX Integration In this presentation… –Introduction to the new Win32 controls. What they are? How they are enabled? Potential uses.
Object-Oriented Application Development Using VB.NET 1 Chapter 10 VB.NET GUI Components Overview.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
MATLAB and SimulinkLecture 61 To days Outline Graphical User Interface (GUI) Exercise on this days topics.
Customizing Menus and Toolbars CHAPTER 12 Customizing Menus and Toolbars.
PowerBuilder Window Window Controls Window Properties Window Types
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Notices Assn 3 is posted – due tomorrow. Quiz marking underway (still – sigh…). Alternate solution code was added on Tuesday to the assignment 3 statement.
Notices Assn 4 posted. Due last day of class. Last quiz this week in Moodle, in the lab. Would the student doing the USATS please get them from Emily Crawford.
Chapter 5 Validating Form Data with JavaScript
Graphical User Interface
Java FX: Scene Builder.
Computing with C# and the .NET Framework
Topics Graphical User Interfaces Using the tkinter Module
Creating LOVs and Editors
Chapter 1: An Introduction to Visual Basic 2015
Chapter 16 JavaFX UI Controls and Multimedia
3.01 Apply Controls Associated With Visual Studio Form
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
3.01 Apply Controls Associated With Visual Studio Form
Microsoft Windows XP Inside Out Second Edition
Using Procedures and Exception Handling
CISC124 Quiz 2 grading underway.
Chap 7. Building Java Graphical User Interfaces
CMPE212 – Stuff… Assn 3 due and Quiz 2 in the lab next week.
Chapter 16 JavaFX UI Controls and Multimedia
Graphical User Interfaces -- Introduction
CMPE212 – Stuff… Assn 3 sample solution is posted.
Recall: Timeline Class
CISC124 Last Quiz this week. Topics listed in last Tuesday’s lecture.
CISC124 Last Quiz this week. Topics listed in last Tuesday’s lecture.
CISC124 Last Quiz this week. Topics listed in last Tuesday’s lecture.
CMPE212 – Stuff… Assignment 4 due March 23 – this Friday.
CISC124 Last Quiz next week. Topics listed in Tuesday’s lecture.
CISC124 Assignment 4 on Inheritance due next Friday.
CISC124 Assignment 3 sample solution will be posted tonight after 7pm.
CMPE212 – Reminders Assignment 3 due next Friday.
Visual C# - GUI and controls - 1
Chapter 16 JavaFX UI Controls and Multimedia
CMPE212 – Reminders Assignment 5, a JavaFX GUI, due this Friday.
Creating Additional Input Items
CMPE212 – Reminders Assignment 5, a JavaFX GUI, due next Friday.
Presentation transcript:

CISC124 Quiz 3 marking underway. Assn 5 due Friday. Fall 2018 Fall 2018 CISC124 2/16/2019 CISC124 Quiz 3 marking underway. Assn 5 due Friday. Fall 2018 CISC124 - Prof. McLeod Prof. Alan McLeod

Today Review order of window construction and display. Event Handlers. Input Nodes. Focus on Assn 5. Change Event Listeners. Fall 2018 CISC124 - Prof. McLeod

Order of Operations: The order is critical, especially if you have to interpret errors: The application invokes main, which invokes launch, which invokes start, supplying it with the Stage object. The start() method in Main.java identifies and then starts loading the fxml file as part of the creation of the root object. The *.css file is located (listed in fxml) and loaded. The controller class is located (listed in fxml). Fall 2018 CISC124 - Prof. McLeod

Order of Operations, Cont. The rest of the fxml file is processed, creating and configuring the controls. Stylesheet changes are applied. The controller class is instantiated. All controls with a fx:id are injected into the instance of the controller class everywhere there is an @FXML annotation. Events are attached to controls, if the fxml contains event tags. Fall 2018 CISC124 - Prof. McLeod

Order of Operations, Cont. When the injection process is complete the initialize() method in the controller class is invoked. Back in the start method, the root object has been created and now contains the scene graph for the window. The scene object is added to the Stage object. The Stage object is shown. Now containers and controls will have their actual sizes. Fall 2018 CISC124 - Prof. McLeod

Attaching an Event to a Node From last time: There are two simple ways of doing this: In initialize(), use a lambda function in the .setOnAction() or .addListener() mutators. Allow Scenebuilder to create a method skeleton for you, fill it in. The method will be attached to the node by the fxml file. Fall 2018 CISC124 - Prof. McLeod

Event Handlers In the initialize() method in the controller class, assuming the fx:id is “myButton”: myButton.setOnAction(event -> { if (myLabel.getText().equals("Hello!")) myLabel.setText("Goodbye!"); else myLabel.setText("Hello!"); }); Fall 2018 CISC124 - Prof. McLeod

Event Handlers, Cont. You can also attach a handler to a control in the fxml file. Using SceneBuilder with the control of interest: Choose one of the possible events of interest and type in a name for the handler. “On Action” is the general purpose handler often used with buttons. Fall 2018 CISC124 - Prof. McLeod

Event Hanlders, Cont. This adds “onAction="#myButtonAction" to the fxml tag for the button. Look in the controller “skeleton” for: @FXML void myButtonAction(ActionEvent event) { } Add this to your controller class and fill it in: Fall 2018 CISC124 - Prof. McLeod

Event Hanlders, Cont. @FXML void myButtonAction(ActionEvent event) { if (myLabel.getText().equals("Hello!")) myLabel.setText("Goodbye!"); else myLabel.setText("Hello!"); } The code in controller is now outside initialize() and is even simpler than the lambda version. See Project11LambdaFXML. Fall 2018 CISC124 - Prof. McLeod

SceneBuilder Links Using SceneBuilder in eclipse: https://docs.oracle.com/javase/8/scene-builder-2/work-with-java-ides/sb-with-eclipse.htm Another example: http://docs.oracle.com/javase/8/scene-builder-2/get-started-tutorial/jfxsb-get_started.htm#JSBGS101 User’s Guide: http://docs.oracle.com/javase/8/scene-builder-2/user-guide/index.html Fall 2018 CISC124 - Prof. McLeod

Input Nodes Lots of controls accept input from the user: Button, RadioButton, ToggleButton, CheckBox, ChoiceBox, TextField, TextArea, PasswordField, ListView, TableView, TreeView, TreeTableView, ComboBox, Slider, Menu, Spinner, … You can even use a dialog which opens a separate window. See: http://docs.oracle.com/javase/8/javafx/user-interface-tutorial/ui_controls.htm Fall 2018 CISC124 - Prof. McLeod

RadioButton, ToggleButton, ChoiceBox, CheckBox ??? Best Input for Assn 5? Pizza choices are very limited and the user cannot add a new choice (like quadruple cheese!). And, the user makes just a single choice per item. Which ones would be best?: RadioButton, ToggleButton, ChoiceBox, CheckBox ??? A Slider or Spinner would work, but would be overkill. See RadioProject for the use of RadioButtons. Fall 2018 CISC124 - Prof. McLeod

RadioGroup.selectedToggleProperty() RadioButton, Cont. Note how the radio buttons have all been added to the same group, “RadioGroup” an object of type ToggleGroup, – this way only one can be chosen in the group. The window needs to respond to a selection change in the radio buttons. To do this you need to create a Change Listener and add it to the the relevant Property. In this case the Property is returned by: RadioGroup.selectedToggleProperty() Fall 2018 CISC124 - Prof. McLeod

Change Event Listeners How to add these in the fxml file?... In the initialize() method, using a lambda function: text3.textProperty().addListener((observableValue, oldText, newText) -> { System.out.println(newText); }); Controls have many properties to which you can add listeners. This is the easiest way to do it. Fall 2018 CISC124 - Prof. McLeod

Change Event Listeners Use to monitor: Window or container size changes. Text box changes. Slider and spinner changes. ChoiceBox selection changes. CheckBox changes. Etc. See how you can use this to restrict input in a text field, for example. (Later). Fall 2018 CISC124 - Prof. McLeod

Best Input for Assn 5?, Cont. See ToggleProject. Very similar to the use of RadioButtons. (Also note use of a new window icon through an Image object coded in Main.java.) Fall 2018 CISC124 - Prof. McLeod

ChoiceBox Project More involved than the toggle buttons. Note that both ChoiceBox and ObservableList objects are Generic – so you have to specify the type being stored (like “String”). Create an ObservableList collection to hold the choices: private ObservableList<String> choiceList = FXCollections.observableArrayList( "Choice 1", "Choice 2", "Choice 3", "Choice 4", "Choice 5"); Fall 2018 CISC124 - Prof. McLeod

ChoiceBox Project, Cont. In initialize(), using the ChoiceBox instance: Invoke .setValue() first to set the initial value shown. This is a bit strange, but it works this way. Invoke .setItems() to add the ObservableList to the instance. Add a ChangeListener to the object returned by the .valueProperty() method. Fall 2018 CISC124 - Prof. McLeod

Two Choice Boxes How to have one choice box changing or limiting the contents of the other choice box?: See FXTwoChoiceBoxes. (Also shows two techniques for changing the mouse cursor.) Fall 2018 CISC124 - Prof. McLeod

ChoiceBox vs. ComboBox vs. ListBox ChoiceBox is simple and will not provide a scroll bar. Single choices only. A ListBox allows multiple selections and is better suited to a larger number of choices. A ComboBox is a combination of a TextField and a ChoiceBox when you set it to “editable”. Will also show a scroll bar. Both ListBoxes and ComboBoxes can use cell factories which can be used to customize the appearance of the choices. Fall 2018 CISC124 - Prof. McLeod

CheckBox These are very simple to use. Suited for binary choices – “On” or “Off”. (There is a third choice, which is “Undefined”). You cannot group them together, so they won’t act like toggles. The .isSelected() accessor returns a true or false. Use the .setSelected(boolean) mutator to set the box checked or not. Use .selectedProperty() to provide the property for a change listener. Fall 2018 CISC124 - Prof. McLeod

Text Input Use TextField, TextArea, PasswordField controls. See FXTextInput. Note: Default Button, Cancel Button. Default text. Prompt text (don’t need a label!). Multi-line input – and scroll bar appearance. Obtaining the text. Clearing the fields. Change events. Restricting input. Fall 2018 CISC124 - Prof. McLeod

Other TextField Properties Did you see the effect of pressing <enter> and <esc>? Did you see the difference between “Prompt Text” and “Text”? Test the effect of “Editable”, “Disable” and “Focus Traversable” properties. Fall 2018 CISC124 - Prof. McLeod

Aside – The Tab Order Also called the “Focus Traversal Policy”… When using keyboard navigation, pressing <tab> moves you “forward” from node to node, providing the nodes accept the focus (they are “focus traversable”). <shift><tab> moves you “backwards”. How do you change the Tab Order of your nodes? Move the nodes around in the Scenebuilder hierarchy tab or move them around in the fxml file. Fall 2018 CISC124 - Prof. McLeod