EE 422C Java FX.

Slides:



Advertisements
Similar presentations
Graphic User Interfaces Layout Managers Event Handling.
Advertisements

Things to mention public static void main(String [] args) –The starting point for a free-standing Java application (i.e. one not run from the DrJava interactions.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Review of Java Applets Vijayan Sugumaran Decision and Information Sciences Oakland University.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 16 Applets.
Written by Liron Blecher
ACM/JETT Workshop - August 4-5, ExceptionHandling and User Interfaces (Event Delegation, Inner classes) using Swing.
1 Event Driven Programming wirh Graphical User Interfaces (GUIs) A Crash Course © Rick Mercer.
Java Programming: From Problem Analysis to Program Design, Second Edition1  Learn about basic GUI components.  Explore how the GUI components JFrame,
Lesson 27: Introduction to the Java GUI. // helloworldbutton.java import java.awt.*; import javax.swing.*; class HelloButton{ public static void main.
CompSci 230 S Software Construction Frameworks & GUI Programming.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
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,
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Event Driven Programming, The.
GUIs in Java Swing, Events CS2110, SW Development Methods Readings: MSD, Chapter 12 Lab Exercise.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
– Advanced Programming P ROGRAMMING IN Lecture 21 Introduction to Swing.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
CS Lecture 00 Swing overview and introduction Lynda Thomas
Chapter 12 1 TOPIC 13B l Buttons and Action Listeners Window Interfaces Using Swing Objects.
Creating a GUI with JFC/Swing. What are the JFC and Swing? JFC –Java Foundation Classes –a group of features to help people build graphical user interfaces.
(1) Introduction to Java GUIs Philip Johnson Collaborative Software Development Laboratory Information and Computer Sciences University of Hawaii Honolulu.
CIS Intro to JAVA Lecture Notes Set 8 9-June-05.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. 1 Chapter 15 Event-Driven Programming and.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. 1 Chapter 15 Event-Driven Programming and.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
Lesson 28: More on the GUI button, frame and actions.
5-1 GUIs and Events Rick Mercer. 5-2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces to respond.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. 1 Chapter 14 JavaFX Basics.
Lecture 7:Introduction to JavaFX Michael Hsu CSULA.
12-Jun-16 Event loops. 2 Programming in prehistoric times Earliest programs were all “batch” processing There was no interaction with the user Input Output.
Event Driven (Asynchronous) Programming. Event handling in Unity Subclass a class that contains event handling methods, and then override those methods.
Lecture 7:Introduction to JavaFX Michael Hsu CSULA.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 7 Event-Driven Programming and Basic GUI Objects.
GUIs and Events Rick Mercer.
CSC 205 Programming II Lecture 5 AWT - I.
Java FX: Scene Builder.
Chapter 15 Event-Driven Programming and Animations
Event Loops and GUI Intro2CS – weeks
CompSci 230 S Software Construction
Lecture 7:Introduction to JavaFX
Event-driven programming
Event loops 16-Jun-18.
Java FX.
CISC124 Quiz 2 grading underway.
CSE 331 Software Design and Implementation
Ellen Walker Hiram College
Miscellaneous Topics #6: Polygons GUI Components and Event Handlers
PC02 Term 1 Project Basic Messenger. PC02 Term 1 Project Basic Messenger.
Event Driven Programming
Chapter 14 JavaFX Basics Dr. Clincy - Lecture.
Chapter 15 Event-Driven Programming and Animations
Introduction to Computing Using Java
Chapter 15 Event-Driven Programming and Animations
CSE 331 Software Design and Implementation
Event loops.
CISC124 Last Quiz next week. Topics listed in Tuesday’s lecture.
Event loops 17-Jan-19.
Event loops 17-Jan-19.
Lecture 9 GUI and Event Driven CSE /16/2019.
Events, Event Handlers, and Threads
Constructors, GUI’s(Using Swing) and ActionListner
Event loops 8-Apr-19.
Tonga Institute of Higher Education
Chapter 5 Processing Input with Applets
Model, View, Controller design pattern
Event loops.
Chapter 15 Event-Driven Programming and Animations Part 1
Event loops.
Event loops 19-Aug-19.
Presentation transcript:

EE 422C Java FX

What is JavaFX? Framework for developing GUI programs Replaced Java Swing Similar conceptually to other graphics libraries EE 422C

Why this JavaFX project? Learn how to use a large library without detailed instructions. Learn about event-driven software. Demonstrate the value of the MVC design pattern. Make a nice self-contained demo-able program to show off. EE 422C

How to run a JavaFX program Eclipse Command Line EE 422C

Basic Structure The main class for a JavaFX application extends the javafx.application.Application class. The start() method is the main entry point for all JavaFX applications (not main(), like in other Java applications). The launch(args) in main() does nothing usually. http://docs.oracle.com/javafx/2/get_started/hello_world.htm EE 422C

EE 422C

EE 422C

Stage, Scene, Node A JavaFX application defines the user interface container by means of a stage and a scene. The JavaFX Stage class is the top-level JavaFX container. Think of it as a stage on which a play is enacted. It is a window on our screen. The JavaFX Scene class is the container for all content. Think of it as a scene in a play. Nodes are the actors to perform in the scene. EE 422C

JavaFX Scene graph EE 422C

Java FX Scene The Main class is an extension of the javafx.application.Application class. Its start method is overridden and receives a Stage object (a top-level GUI container) as its only parameter. The root node (in this case, an instance of the javafx.scene.Stackpane class) is created and passed to the scene's constructor, along with the scene's width, and height. The stage's title, scene, and visibility are all set. EE 422C

From Introduction to Java Programming by Daniel Liang EE 422C

Coordinates The Origin is at the top left in JavaFX

Layout Panes JavaFX provides many types of panes for organizing nodes in a container.

Event-Driven Programming A paradigm where the flow of the program is driven by events such as: User actions (buttons, mouse clicks, etc.) Sensor input Network traffic Messages from other programs or threads Very common in software with graphical user interfaces EE 422C

Event Handler event handler is a callback subroutine that handles inputs received in a program (called a listener in Java). Each event is a piece of application-level information from the underlying framework, typically the GUI toolkit. GUI events include key presses, mouse movement, action selections, and timers expiring. Event handlers are a central concept in event-driven programming. EE 422C

Event Handler EventHandler is a class that implements void handle(T event) Invoked when a specific event of the type for which this handler is registered happens. btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { newScreen(stage); //action for button } }); //We will look at a more concise version later EE 422C

Java FX program snippet class Main extends Application {} Add method start(Stage primaryStage) that works like main (String[] args) to Main Add a Scene to the primaryStage in start() Add a JavaFX Node object (such as a grid) to the Scene Add button to the Node object Add onAction code (event Handler) to the button Display the primaryStage on the computer display EE 422C