CMPE212 – Reminders Assignment 5, a JavaFX GUI, due next Friday.

Slides:



Advertisements
Similar presentations
Tutorial 6 Creating a Web Form
Advertisements

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.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Written by Liron Blecher
8 Copyright © 2004, Oracle. All rights reserved. Creating LOVs and Editors.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
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.
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 --
GUI development with Matlab: GUI Front Panel Components 1 GUI front panel components In this section, we will look at -GUI front panel components -Programming.
3461A Readings from the Swing Tutorial. 3461A Overview  The follow is the Table of Contents from the trail “Creating a GUI with JFC/Swing” in the “The.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Copyright 2007, Information Builders. Slide 1 Understanding Basic HTML Amanda Regan Technical Director June, 2008.
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.
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
SEEM3460 Tutorial GUI in Java. Some Basic GUI Terms Component (Control in some languages) the basic GUI unit something visible something that user can.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
Object-Oriented Application Development Using VB.NET 1 Chapter 10 VB.NET GUI Components Overview.
Integrating Components and Dynamic Text Boxes with the Animated Map– Lesson 101 Integrating Components and Dynamic Text Boxes with the Animated Map Lesson.
Tutorial 6 Creating a Web 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 3: I Need a Tour Guide (Introduction to Visual Basic 2012)
Java FX: Scene Builder.
Lecture 8:Event Driven Programming
Topics Graphical User Interfaces Using the tkinter Module
Creating LOVs and Editors
Chapter 1: An Introduction to Visual Basic 2015
CSCI 3328 Object Oriented Programming in C# Chapter 2: Introduction to Visual C# Programming UTPA – Fall 2012 This set of slides is revised from lecture.
Single Sample Registration
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.
Graphical User Interfaces -- Introduction
Fundamentals of Python: From First Programs Through Data Structures
CMPE212 – Stuff… Assn 3 sample solution is posted.
Winter 2018 CMPE212 11/12/2018 CMPE212 – Stuff…
Recall: Timeline Class
The University of Texas – Pan American
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.
CISC101 Reminders Quiz 2 graded. Assn 2 sample solution is posted.
CISC124 Last Quiz next week. Topics listed in Tuesday’s lecture.
Using Cascading Style Sheets (CSS)
CISC124 Assignment 4 on Inheritance due next Friday.
CISC124 Quiz 3 marking underway. Assn 5 due Friday. Fall 2018
CISC124 Assignment 3 sample solution will be posted tonight after 7pm.
CMPE212 – Reminders Assignment 2 sample solution is posted.
CMPE212 – Reminders Assignment 3 due next Friday.
Winter 2019 CMPE212 4/20/2019 CMPE212 – Reminders
Visual C# - GUI and controls - 1
CMPE212 – Reminders Quiz 1 marking done. Assignment 2 due next Friday.
CMPE212 – Reminders Assignment 2 due today, 7pm.
Winter 2019 CMPE212 5/25/2019 CMPE212 – Reminders
CMPE212 – Reminders Assignment 5, a JavaFX GUI, due this Friday.
CMPE212 – Reminders Assignment 2 due next Friday.
TA: Nouf Al-Harbi NoufNaief.net :::
Presentation transcript:

CMPE212 – Reminders Assignment 5, a JavaFX GUI, due next Friday. Winter 2019 CMPE212 6/6/2019 CMPE212 – Reminders Assignment 5, a JavaFX GUI, due next Friday. Quiz 3 (the last one!) this week. Topics listed in last Wednesday’s lecture. JavaFX Panes on Quiz: Border, Anchor, Flow, GridPane, HBox, VBox. CSS stylesheet use is *not* on the quiz. Remember to use [ ] instead of < > for generics. Winter 2019 CMPE212 - Prof. McLeod Prof. Alan McLeod

Today Using Scenebuilder, Cont. Winter 2019 CMPE212 6/6/2019 Today Using Scenebuilder, Cont. Go over the project structure that “we” built yesterday. List the sequence of steps that are taken to build the window. Start Input Nodes. Winter 2019 CMPE212 - Prof. McLeod Prof. Alan McLeod

JavaFX Project: Using the FXML File Let’s review the structure of the project we just built in class and have another look at the contents of the FXML file. This will help you figure out why your project does not run – where the problem(s) could arise. Winter 2019 CMPE212 - Prof. McLeod

Using the FXML File: Some Questions Note how the button is shifting back and forth as the size of the label changes – what is causing this and how can you fix it? How can you change the default size of the window? Can you fix the window borders so it cannot be re-sized? Why would you want to do so? Where do you make changes to the window and not to the GridPane? Do you still need to process the *.css file in Main.java? What is the purpose of the @FXML annotation in the controller class? Do they have to be there? What happens if you instantiate the node attributes in the controller class, not just declare them? Winter 2019 CMPE212 - Prof. McLeod

Using the FXML File: Question, Cont. How can you increase the font size of the window title? How can you customize the window title bar? It turns out that, by default, you are given a “decorated” window by JavaFX. The title bar design is fixed to system (Windows) chosen defaults. To change this you need to build an “undecorated” window. For example, see: https://arnaudnouard.wordpress.com/2013/02/02/undecorator-add-a-better-look-to-your-javafx-stages-part-i/ Winter 2019 CMPE212 - Prof. McLeod

Using the FXML File: Don’t Forget: In your Main.java file replace the declaration of “root” with (assuming you are using GridPane): GridPane root = (GridPane) FXMLLoader.load(getClass().getResource("Project11.fxml")); You don’t need any control instantiations in Main.java or any of the code to do with the controls. No more layout or style code in Main.java!! Winter 2019 CMPE212 - 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). The rest of the fxml file is processed, creating and configuring the controls. Stylesheet changes are applied. Winter 2019 CMPE212 - Prof. McLeod

Order of Operations, Cont. 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. 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. Winter 2019 CMPE212 - 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 Winter 2019 CMPE212 - 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 (this is a very useful page): http://docs.oracle.com/javase/8/javafx/user-interface-tutorial/ui_controls.htm Winter 2019 CMPE212 - Prof. McLeod

RadioButton, ToggleButton, ChoiceBox ??? 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 ??? A Slider or Spinner would work, but would be overkill. See RadioProject for the use of RadioButtons. Winter 2019 CMPE212 - 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() Winter 2019 CMPE212 - Prof. McLeod

Change Event Listeners How to add these in the fxml file?... (You can’t) In the initialize() method, using a lambda function: radioGroup.selectedToggleProperty().addListener((ov, old_toggle, new_toggle) -> { selectedText.setText(((RadioButton)new_toggle).getId()); }); Controls have many properties to which you can add listeners. This is the easiest way to do it. Winter 2019 CMPE212 - Prof. McLeod

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

Best Input for Assn 5?, Cont. See ToggleProject. Very similar to the use of RadioButtons. As with the RadioButton node, the “ID” property should not be confused with the fx:id properly. Also note use of a new window icon through an Image object coded in Main.java. This was also done in RadioProject. Winter 2019 CMPE212 - 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”). And you have to instantiate the attribute in the controller class. Create an ObservableList collection to hold the choices: private ObservableList<String> choiceList = FXCollections.observableArrayList( "Choice 1", "Choice 2", "Choice 3", "Choice 4", "Choice 5"); Winter 2019 CMPE212 - Prof. McLeod

ChoiceBox Project, Cont. In initialize(), using the ChoiceBox instance: Invoke .setItems() to add the ObservableList to the instance. Then invoke .setValue() to set the initial value shown. Add a ChangeListener to the property returned by the .valueProperty() method. Winter 2019 CMPE212 - 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. Winter 2019 CMPE212 - 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. Winter 2019 CMPE212 - Prof. McLeod