Composite Pattern Diagram. Explanation. JavaFX Subclass Hierarchy, cont. JavaFX: Node. JavaFX Layout Classes. Top-Level Containers 10/12/2018

Size: px
Start display at page:

Download "Composite Pattern Diagram. Explanation. JavaFX Subclass Hierarchy, cont. JavaFX: Node. JavaFX Layout Classes. Top-Level Containers 10/12/2018"

Transcription

1 Explanation Component has Operation( ), which is a method that applies to all components, whether composite or leaf. There are generally many operations. Component also has composite methods: Add( ), Remove( ), and GetChild( ). Note that in all cases a Component is passed. Component itself just throws an exception for these methods. Leaf implements the operations. Does nothing on Component methods, which just return. Composite implements the composite methods. Also implements the operations, by invoking the operation on each of its children in succession. Composite Pattern Diagram The composite pattern lets us treat an object (the Component) as if it could be a Leaf (contains no children) or a Composite, made up of a number of leaves and/or composites. JavaFX: Node Node is something that goes in a Parent Since a Parent isa Node, you get a hierarchy Some functionality the Node class provides to its descendants: Painting (how an object is displayed), borders Application-wide pluggable look and feel Support for layout (where in the container does it go?) Support for accessibility (mouse and keyboard) Some example descendants of Node are: (many kinds of) Pane, Button, ListView, Label, and many more. JavaFX Subclass Hierarchy, cont. Object Parent Pane getchildren() GridPane FlowPane VBox BorderPane HBox JavaFX Layout Classes Top-Level Containers To appear onscreen, every GUI component must be added to a top-level container. The top-level container corresponds to what you think of as a window or application on your computer. A containment (has-a) hierarchy for a simple GUI: Stage Scene Parent top-level container components GridPane Label Menu MenuItem 1

2 Event-Driven Programming A style of coding where a program's overall flow of execution is dictated by events: The program loads The program waits for the user to generate input Each event causes some particular code to respond Need an event handler The overall flow of what code is determined by the user generating a series of events Event-Driven Programming We contrast this with the types of programs that we have been producing so far, which we might term: prompt-and-wait style programs Event-Driven Programming The main body of the program is an event loop The main algorithm abstractly: do { e = getnextevent(); processevent(e); while (e!= quit); Kinds of Events Different events that can occur in an event-driven program with a GUI Mouse move/drag/click, mouse button press/release Keyboard: key press/release Touchscreen finger tap/drag Joystick, drawing tablet, other device inputs Window resize/minimize/restore/close Network activity or file I/O (start, done, error) Timer interrupt Move a scroll bar Chose a menu selection Media finishes handle(event) Java s Event Model Java and the operating system work together to detect user interaction Button objects are notified when clicked Send a handle(actionevent) message to registered ActionEvent handlers TextField objects are notified when the user presses Enter A handle(actionevent) message is sent to registered event handlers When the mouse is clicked, the node under the curser is notified Send a handle(mouseevent) message to registered Mouse event handlers When a key is pressed Send a handle(keyevent) message to registered KeyEvent handlers Example: ActionEvent The button and textfield do not yet perform any action Let s make something happen when The button is clicked The user presses enters into the textfield 2

3 How to Handle Events Add a private inner class that will handle the event that the component generates This class must implement an interface to guarantee that it has the expected method such as public void handle(actionevent ae) Register the event handler so the component can later send the correct message to that event handler Events occur anytime in the future--the event handler is waiting for user generated events such as clicking button Send this message to the GUI component: button.setonaction(handler); Using an Inner Class Have a private inner class that implements EventHandler <ActionEvent>: EventHandler<ActionEvent> handler = new ButtonHandler(); button.setonaction(handler); private class ButtonHandler implements EventHandler<ActionEvent> public void handle(actionevent event) { button.settext(textfield.gettext()); Using a Lambda JavaFX Input: Inversion Of Control EventHandler<ActionEvent> handler = new ButtonHandler(); button.setonaction((event) -> { button.settext(textfield.gettext()); ); Using Blocking/Polling: Application calls a method and waits (blocks) for input from the user: // Waits for user input, polling... inputstring = myscanner.nextline(); Using Callbacks: the programmer indicates what methods, specified in EventHandlers and other event listener classes) are to be called passed certain input events (or ActionEvents). These methods are called callbacks because the application is telling JavaFX to call it back should a given event occur JavaFX is in control and delegates control, based on input, to the application code. Hence the term Inversion Of Control. Observer Design Pattern Observer Design Pattern Observer is a software design pattern in which the model maintains a list of its observers, and notifies them automatically of any state changes It is the heart of MVC This is what we will use to have multiple views (ButtonView, TextAreaView, DrawingView) observe the model and change when the model changes Both views must be added as "Observers" The model is the "Observable" A specific message from an interface is sent to all observers in these methods of Patterns in TTT TicTacGame() startnewgame() choose(int row, int col) Observer is used so frequently that Java supplies A class to be extended: Observable An interface to be implemented by many classes: Observer 3

4 Observer Design Pattern The Model's Responsibilities /** Use a Pane to implement this interface so the Pane can show a view of the model and allow user input */ public class ButtonView extends BorderPane implements Observer // This method is called by Observable's notifyobservers() public void update(observable observable, Object message) { thegame = (TicTacToeGame) observable; updatebuttons(); if (thegame.didwin('x')) statebutton.settext("x wins"); else if (thegame.didwin('o')) statebutton.settext("o wins"); else if (thegame.tied()) statebutton.settext("tie"); else statebutton.settext(clickmessage); Provide access to the state of the model didwin(char), getat(int, int), Provide access to the system's functionality startnewgame(), setcomputerplayerstrategy(tictactoestrategy) Notify the view(s) that the model's state has changed /** * This is called from humanmove when not testing */ public void computermove(int row, int col) { if (board[row][col]!= '_') return; board[row][col] = 'O'; setchanged(); //Java needs this or notifyobservers does nothing notifyobservers(); //Send update messages to all Observers The Controller Responsibilities Full MVC Architecture Respond to user input (when an event occurs) Button click in ButtonView or enter integers in the TextArea with a button click (a view that you are asked to implement) Send makemove() messages to the model our TicTacToeGame), that sends notifyobservers() messages to the Observable (TicTacToeGame) that sends update messages to the observers In JavaFX, our EventHandlers are controllers Notifies upon user interaction View Controller Model Updates Triggers changes in The Canvas Node Drawing Text JavaFX added a Canvas Node to mimic HTML5's Canvas Add a Canvas object to a Pane allows a portion of our application to be viewed as an image We can the draw shapes and images Canvas objects have a width and height public void start(stage stage) { BorderPane pane = new BorderPane(); Canvas canvas = new Canvas(200, 100); pane.setcenter(canvas); GraphicsContext gc = canvas.getgraphicscontext2d(); // This string will be drawn 20 pixels right, // 40 pixels down as the lower left corner. // All other shapes point is the upper left gc.filltext("i'm in a Canvas", 20, 40); Need to draw onto the GraphicsContext object of the Canvas object (see code on the next slide) Scene scene = new Scene(pane, 200, 100); stage.setscene(scene); stage.show(); 4

5 The Coordinate System The Coordinate System A simple two-dimensional coordinate system exists for each graphics context, or drawing surface <0, 0> x X Each point on the coordinate system represents a pixel y <x, y> Top left corner of the area is coordinate <0, 0> // This string will be drawn 20 pixels right, // 40 pixels down as the lower left corner. gc.filltext("i'm in a Canvas", 20, 40); A drawing surface has a width and height Anything drawn outside of that area is not visible When drawing shapes first position is at the top left corner Y <width-1, height-1> How to Draw on a Canvas Drawing Lines public void start(stage stage) { BorderPane window = new BorderPane(); Canvas canvas = new Canvas(150, 150); window.setcenter(canvas); GraphicsContext gc = canvas.getgraphicscontext2d(); gc.setfill(color.red); gc.setstroke(color.blue); gc.strokeoval(20, 20, 40, 40); gc.filloval(70, 20, 40, 40); gc.fillrect(20, 80, 40, 40); gc.strokerect(70, 80, 40, 40); Scene scene = new Scene(window, 150, 150); stage.setscene(scene); stage.show(); strokeline(leftx, lefty, rightx, righty) Change the thickness with setlinewidth gc.strokeline(0, 150, 150, 0); gc.setlinewidth(3); gc.setstroke(color.gold); for (int fromtop = 10; fromtop <= 150; fromtop += 10) { gc.strokeline(0, 0, 150, fromtop); Text Object, No Canvas Needed public void start(stage stage) { stage.settitle("graphics in JavaFX"); Group root = new Group(); Scene scene = new Scene(root, 300, 100, Color.WHITE); Text text = new Text(20, scene.getheight() / 1.8, "Hello CSC 335!"); text.setfont(font.font("serif", FontWeight.EXTRA_BOLD, FontPosture.REGULAR, 40)); text.setfill(color.red); text.setfontsmoothingtype(fontsmoothingtype.lcd); text.setstroke(color.darkred); root.getchildren().add(text); The Color class is used to define and manage the color in which shapes are drawn Can set the color for stroke and fill with setfill(color) and setstroke(color) javafx.scene.paint.color has many, many colors from Color.ALICEBLUE to Color.YELLOWGREEN stage.setscene(scene); stage.show(); 5

6 Color Colors can also be defined with an RGB value (0-255), to set the relative contribution of the primary colors red, green, blue Color color = new Color.rgb(80, 210, 110); gc.setfill(color); gc.setstroke(color); gc.setlinewidth(4); // width set to 4 pixels gc.strokeoval(20, 20, 40, 40); gc.filloval(70, 20, 40, 40); Clear" the Canvas Consider a view that draws a circle from from 1 to public void update(observable themodel, Object o) { SimpleModel model = (SimpleModel) themodel; gc.setfill(color.pink); gc.fillrect(0, 0, canvas.getwidth(), canvas.getheight()); gc.setfill(color.aqua); Clearing the Canvas Also a clearrect() method that fills the specified region with the current transparent (background) color class Image public Image(String url, boolean backgroundloading) Construct a new Image with the specified parameters. Parameters: url: the string representing the URL when fetching the pixel data backgroundloading = false which indicates build image fully before moving on, almost always want this. Image hunter = new Image("file:images/TheHunter.png", false); Image wumpus = new Image("file:images/wumpus.png", false); drawimage public void drawimage(image img, double x, double y) public void drawimage(image img, double x, double y, int width, int height) Draws an image at the given x, y position using the width and height of the given image. Parameters: img: the image to be drawn or null. x: the X coordinate of the upper left of image y: the Y coordinate on the upper left of image gc.drawimage(hunter, 50, 110); gc.drawimage(wumpus, 90, 70); 6

Event-Driven Programming with GUIs. Slides derived (or copied) from slides created by Rick Mercer for CSc 335

Event-Driven Programming with GUIs. Slides derived (or copied) from slides created by Rick Mercer for CSc 335 Event-Driven Programming with GUIs Slides derived (or copied) from slides created by Rick Mercer for CSc 335 Event Driven GUIs A Graphical User Interface (GUI) presents a graphical view of an application

More information

GUI Output. Adapted from slides by Michelle Strout with some slides from Rick Mercer. CSc 210

GUI Output. Adapted from slides by Michelle Strout with some slides from Rick Mercer. CSc 210 GUI Output Adapted from slides by Michelle Strout with some slides from Rick Mercer CSc 210 GUI (Graphical User Interface) We all use GUI s every day Text interfaces great for testing and debugging Infants

More information

C30c: Model-View-Controller and Writing Larger JavaFX Apps

C30c: Model-View-Controller and Writing Larger JavaFX Apps CISC 3120 C30c: Model-View-Controller and Writing Larger JavaFX Apps Hui Chen Department of Computer & Information Science CUNY Brooklyn College 12/6/2018 CUNY Brooklyn College 1 Outline Model-View-Controller

More information

https://www.eclipse.org/efxclipse/install.html#for-the-lazy

https://www.eclipse.org/efxclipse/install.html#for-the-lazy CSC40232: SOFTWARE ENGINEERING Professor: Jane Cleland Huang Lecture 4: Getting Started with Java FX Wednesday, January 30 th and February 1 st sarec.nd.edu/courses/se2017 Department of Computer Science

More information

Java FX. Properties and Bindings

Java FX. Properties and Bindings Java FX Properties and Bindings Properties : something that holds data data can be simple like an int or complex like a list data structure this data can be used to update other things when it changes

More information

Week 5: Images & Graphics. Programming of Interactive Systems. JavaFX Images. images. Anastasia Bezerianos. Anastasia Bezerianos

Week 5: Images & Graphics. Programming of Interactive Systems. JavaFX Images. images. Anastasia Bezerianos. Anastasia Bezerianos Programming of Interactive Systems Week 5: Images & Graphics Anastasia Bezerianos introduction.prog.is@gmail.com Anastasia Bezerianos introduction.prog.is@gmail.com!2 1 2 JavaFX Images images In JavaFX

More information

CSE 331 Software Design & Implementation

CSE 331 Software Design & Implementation CSE 331 Software Design & Implementation Hal Perkins Spring 2017 GUI Event-Driven Programming 1 The plan User events and callbacks Event objects Event listeners Registering listeners to handle events Anonymous

More information

Lecture 19 GUI Events

Lecture 19 GUI Events CSE 331 Software Design and Implementation Lecture 19 GUI Events The plan User events and callbacks Event objects Event listeners Registering listeners to handle events Anonymous inner classes Proper interaction

More information

Java Foundations. 9-1 Introduction to JavaFX. Copyright 2014, Oracle and/or its affiliates. All rights reserved.

Java Foundations. 9-1 Introduction to JavaFX. Copyright 2014, Oracle and/or its affiliates. All rights reserved. Java Foundations 9-1 Copyright 2014, Oracle and/or its affiliates. All rights reserved. Objectives This lesson covers the following objectives: Create a JavaFX project Explain the components of the default

More information

@Override public void start(stage primarystage) throws Exception { Group root = new Group(); Scene scene = new Scene(root);

@Override public void start(stage primarystage) throws Exception { Group root = new Group(); Scene scene = new Scene(root); Intro to Drawing Graphics To draw some simple graphics, we first need to create a window. The easiest way to do this in the current version of Java is to create a JavaFX application. Previous versions

More information

CSE 331 Software Design and Implementation. Lecture 19 GUI Events

CSE 331 Software Design and Implementation. Lecture 19 GUI Events CSE 331 Software Design and Implementation Lecture 19 GUI Events Leah Perlmutter / Summer 2018 Announcements Announcements Quiz 7 due Thursday 8/9 Homework 8 due Thursday 8/9 HW8 has a regression testing

More information

C12: JavaFX Scene Graph, Events, and UI Components

C12: JavaFX Scene Graph, Events, and UI Components CISC 3120 C12: JavaFX Scene Graph, Events, and UI Components Hui Chen Department of Computer & Information Science CUNY Brooklyn College 3/12/2018 CUNY Brooklyn College 1 Outline Recap and issues JavaFX

More information

IT In the News. Login tokens have been reset for those affected and vulnerabilities have been fixed. o Vulnerabilities existed since July 2017

IT In the News. Login tokens have been reset for those affected and vulnerabilities have been fixed. o Vulnerabilities existed since July 2017 IT In the News 50 million Facebook accounts were affected by a security breach two weeks ago Attacks exploited bugs in Facebook s View As feature (built to give users more privacy) and a feature that allowed

More information

CSCI-142 Exam 2 Review September 25, 2016 Presented by the RIT Computer Science Community

CSCI-142 Exam 2 Review September 25, 2016 Presented by the RIT Computer Science Community CSCI-142 Exam 2 Review September 25, 2016 Presented by the RIT Computer Science Community http://csc.cs.rit.edu 1. Suppose we are talking about the depth-first search (DFS) algorithm. Nodes are added to

More information

Event Handling in JavaFX

Event Handling in JavaFX Event Handling in JavaFX Event Driven Programming Graphics applications use events. An event dispatcher receives events and notifies interested objects. Event Listener Event EventQueue 1. ActionEvent 2.

More information

CST141 JavaFX Events and Animation Page 1

CST141 JavaFX Events and Animation Page 1 CST141 JavaFX Events and Animation Page 1 1 2 3 4 5 6 7 JavaFX Events and Animation CST141 Event Handling GUI components generate events when users interact with controls Typical events include: Clicking

More information

event driven programming user input Week 2 : c. JavaFX user input Programming of Interactive Systems

event driven programming user input Week 2 : c. JavaFX user input Programming of Interactive Systems Programming of Interactive Systems Week 2 : c. JavaFX user input Anastasia.Bezerianos@lri.fr Anastasia.Bezerianos@lri.fr (part of this class is based on previous classes from Anastasia, and of T. Tsandilas,

More information

Multimedia-Programmierung Übung 3

Multimedia-Programmierung Übung 3 Multimedia-Programmierung Übung 3 Ludwig-Maximilians-Universität München Sommersemester 2015 JavaFX Version 8 What is JavaFX? Recommended UI-Toolkit for Java 8 Applications (like e.g.: Swing, AWT) Current

More information

Java Programming. Events and Listeners

Java Programming. Events and Listeners Java Programming Events and Listeners Alice E. Fischer April 19, 2015 Java Programming - Events and Listenersldots 1/12 Events and Listeners An event is generated when The user clicks a GUI button or CheckBox

More information

Beautiful User Interfaces with JavaFX

Beautiful User Interfaces with JavaFX Beautiful User Interfaces with JavaFX Systémes d acquisition 3EIB S. Reynal September 20, 2017 The current document is dedicated to giving you a small and quick insight into the JavaFX API, an extra Java

More information

CS 112 Programming 2. Lecture 14. Event-Driven Programming & Animations (1) Chapter 15 Event-Driven Programming and Animations

CS 112 Programming 2. Lecture 14. Event-Driven Programming & Animations (1) Chapter 15 Event-Driven Programming and Animations CS 112 Programming 2 Lecture 14 Event-Driven Programming & Animations (1) Chapter 15 Event-Driven Programming and Animations rights reserved. 2 Motivations Suppose you want to write a GUI program that

More information

Event-Driven Programming

Event-Driven Programming Lecture 10 1 Recall: JavaFX Basics So far we ve learned about some of the basic GUI classes (e.g. shapes, buttons) and how to arrange them in window(s) A big missing piece: interaction To have a GUI interact

More information

COMP6700/2140 Scene Graph, Layout and Styles

COMP6700/2140 Scene Graph, Layout and Styles COMP6700/2140 Scene Graph, Layout and Styles Alexei B Khorev and Josh Milthorpe Research School of Computer Science, ANU May 2017 Alexei B Khorev and Josh Milthorpe (RSCS, ANU) COMP6700/2140 Scene Graph,

More information

Graphical User Interface (GUI)

Graphical User Interface (GUI) Graphical User Interface (GUI) An example of Inheritance and Sub-Typing 1 Java GUI Portability Problem Java loves the idea that your code produces the same results on any machine The underlying hardware

More information

CSC 161 LAB 3-1 JAVA FX CALCULATOR

CSC 161 LAB 3-1 JAVA FX CALCULATOR CSC 161 LAB 3-1 JAVA FX CALCULATOR PROFESSOR GODFREY MUGANDA 1. Introduction and Overview In this lab, you are going to use JavaFX to create a calculator that can add, subtract, divide, multiply, and find

More information

Graphical User Interface (GUI)

Graphical User Interface (GUI) Graphical User Interface (GUI) An example of Inheritance and Sub-Typing 1 Java GUI Portability Problem Java loves the idea that your code produces the same results on any machine The underlying hardware

More information

C16a: Model-View-Controller and JavaFX Styling

C16a: Model-View-Controller and JavaFX Styling CISC 3120 C16a: Model-View-Controller and JavaFX Styling Hui Chen Department of Computer & Information Science CUNY Brooklyn College 3/28/2018 CUNY Brooklyn College 1 Outline Recap and issues Model-View-Controller

More information

JavaFX. Working with the JavaFX Scene Graph Release 8 E March 2014 Learn about the concept of a scene graph and how it is used in JavaFX.

JavaFX. Working with the JavaFX Scene Graph Release 8 E March 2014 Learn about the concept of a scene graph and how it is used in JavaFX. JavaFX Working with the JavaFX Scene Graph Release 8 E50683-01 March 2014 Learn about the concept of a scene graph and how it is used in JavaFX. JavaFX Working with the JavaFX Scene Graph Release 8 E50683-01

More information

interactive systems graphical interfaces Week 2 : a. Intro to JavaFX Programming of Interactive Systems

interactive systems graphical interfaces Week 2 : a. Intro to JavaFX Programming of Interactive Systems Programming of Interactive Systems Anastasia.Bezerianos@lri.fr Week 2 : a. Intro to JavaFX Anastasia.Bezerianos@lri.fr (part of this class is based on previous classes from Anastasia, and of T. Tsandilas,

More information

Throughout the exam, write concisely and underline key words or phrases. Have fun! Exam 2. Week 7 (Winter 2013). Dr. Yoder. Sec 031.

Throughout the exam, write concisely and underline key words or phrases. Have fun! Exam 2. Week 7 (Winter 2013). Dr. Yoder. Sec 031. SE1021 Exam 2 Name: You may have an 8.5x11 note sheet for this exam. No calculators or other study aids on this exam. Write your initials at the tops of the following pages and read through the exam before

More information

//Create BorderPane layout manager. layout = new BorderPane(); //This is the "root node".

//Create BorderPane layout manager. layout = new BorderPane(); //This is the root node. package ui.layouts.gridpane; import javafx.application.application; import javafx.event.actionevent; import javafx.event.eventhandler; import javafx.geometry.hpos; import javafx.geometry.pos; import javafx.geometry.rectangle2d;

More information

Come organizzare gli ascoltatori/osservatori

Come organizzare gli ascoltatori/osservatori Come organizzare gli ascoltatori/osservatori Listener Esterno public class AppWithEvents extends Application { Text text=null; Button btn = new Button(); Listener a=new Listener(this); btn.addeventhandler(actionevent.action,

More information

Event-driven Programming: GUIs

Event-driven Programming: GUIs Dr. Sarah Abraham University of Texas at Austin Computer Science Department Event-driven Programming: GUIs Elements of Graphics CS324e Spring 2018 Event-driven Programming Programming model where code

More information

Event-driven Programming, Separation of Concerns, the Observer pattern and the JavaFX Event Infrastructure

Event-driven Programming, Separation of Concerns, the Observer pattern and the JavaFX Event Infrastructure Java GUIs in JavaFX Event-driven Programming, Separation of Concerns, the Observer pattern and the JavaFX Event Infrastructure 1 GUIs process inputs and deliver outputs for a computing system Inputs Click

More information

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created. + Inheritance + Inheritance Classes that we design in Java can be used to model some concept in our program. For example: Pokemon a = new Pokemon(); Pokemon b = new Pokemon() Sometimes we need to create

More information

C14: JavaFX: Overview and Programming User Interface

C14: JavaFX: Overview and Programming User Interface CISC 3120 C14: JavaFX: Overview and Programming User Interface Hui Chen Department of Computer & Information Science CUNY Brooklyn College 10/10/2017 CUNY Brooklyn College 1 Outline Recap and issues Architecture

More information

JavaFX a Crash Course. Tecniche di Programmazione A.A. 2016/2017

JavaFX a Crash Course. Tecniche di Programmazione A.A. 2016/2017 JavaFX a Crash Course Tecniche di Programmazione Key concepts in JavaFX Stage: where the application will be displayed (e.g., a Windows window) Scene: one container of Nodes that compose one page of your

More information

JavaFX a Crash Course. Tecniche di Programmazione A.A. 2015/2016

JavaFX a Crash Course. Tecniche di Programmazione A.A. 2015/2016 JavaFX a Crash Course Tecniche di Programmazione Key concepts in JavaFX Stage: where the application will be displayed (e.g., a Windows window) Scene: one container of Nodes that compose one page of your

More information

CST141 JavaFX Basics Page 1

CST141 JavaFX Basics Page 1 CST141 JavaFX Basics Page 1 1 2 5 6 7 8 9 10 JavaFX Basics CST141 Console vs. Window Programs In Java there is no distinction between console programs and window programs Java applications can mix (combine)

More information

46 Advanced Java for Bioinformatics, WS 17/18, D. Huson, December 21, 2017

46 Advanced Java for Bioinformatics, WS 17/18, D. Huson, December 21, 2017 46 Advanced Java for Bioinformatics, WS 17/18, D. Huson, December 21, 2017 11 FXML and CSS A program intended for interactive use may provide a large number of user interface (UI) components, as shown

More information

CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM

CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM Objectives The objectives of this assignment are: to get your first experience with Java to become familiar with Eclipse Java

More information

JavaFX Technology Building GUI Applications With JavaFX - Tutorial Overview

JavaFX Technology Building GUI Applications With JavaFX - Tutorial Overview avafx Tutorial Develop Applications for Desktop and Mobile Java FX 2/10/09 3:35 PM Sun Java Solaris Communities My SDN Account Join SDN SDN Home > Java Technology > JavaFX Technology > JavaFX Technology

More information

Week 12 Thursday. For milestone #2 and #3, also submit a screenshot of your GUI once it is launched.

Week 12 Thursday. For milestone #2 and #3, also submit a screenshot of your GUI once it is launched. Week 12 Thursday D-Teams have been created Create your A-Team by Friday, or let me know to assign you earlier. Team Project: Tournament-Bracket (D-Team 30 pts) Milestone #1: due before 10pm THIS Friday,

More information

CON Visualising GC with JavaFX Ben Evans James Gough

CON Visualising GC with JavaFX Ben Evans James Gough CON6265 - Visualising GC with JavaFX Ben Evans (@kittylyst) James Gough (@javajimlondon) Who are these guys anyway? Beginnings This story, as with so many others, starts with beer... Beginnings It was

More information

Chapter 6, Case Study: BallWorld

Chapter 6, Case Study: BallWorld Chapter 6, Case Study: BallWorld John M. Morrison December 24, 2016 Contents 0 Introduction 1 1 Making our first big app: BallWorld 2 2 Putting Menus in the Window and Getting Started 4 3 Introducing Canvas

More information

Chapter 15 Event-Driven Programming and Animations

Chapter 15 Event-Driven Programming and Animations Chapter 15 Event-Driven Programming and Animations 1 Motivations Suppose you want to write a GUI program that lets the user enter a loan amount, annual interest rate, and number of years and click the

More information

Java FX. Threads, Workers and Tasks

Java FX. Threads, Workers and Tasks Java FX Threads, Workers and Tasks Threads and related topics Lecture Overview...but first lets take a look at a good example of Model - View - Controler set up This and most of the lecture is taken from

More information

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

Graphics. Lecture 18 COP 3252 Summer June 6, 2017 Graphics Lecture 18 COP 3252 Summer 2017 June 6, 2017 Graphics classes In the original version of Java, graphics components were in the AWT library (Abstract Windows Toolkit) Was okay for developing simple

More information

CSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction

CSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction CSC 160 LAB 8-1 DIGITAL PICTURE FRAME PROFESSOR GODFREY MUGANDA DEPARTMENT OF COMPUTER SCIENCE 1. Introduction Download and unzip the images folder from the course website. The folder contains 28 images

More information

Java Programming Layout

Java Programming Layout Java Programming Layout Alice E. Fischer Feb 22, 2013 Java Programming - Layout... 1/14 Application-Stage-Scene-Pane Basic GUI Construction Java Programming - Layout... 2/14 Application-Stage-Scene Application

More information

Chapter 14 JavaFX Basics. Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved.

Chapter 14 JavaFX Basics. Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. Chapter 14 JavaFX Basics 1 Motivations JavaFX is a new framework for developing Java GUI programs. The JavaFX API is an excellent example of how the object-oriented principle is applied. This chapter serves

More information

Introduction: Game. Key Design Points

Introduction: Game. Key Design Points Introduction: Game This project is an introduction to two dimensional game design using an animation timer and an event handler processing up and down keys. Although the structure of the software is simplistic

More information

CISC 1600 Lecture 3.1 Introduction to Processing

CISC 1600 Lecture 3.1 Introduction to Processing CISC 1600 Lecture 3.1 Introduction to Processing Topics: Example sketches Drawing functions in Processing Colors in Processing General Processing syntax Processing is for sketching Designed to allow artists

More information

Posizionamento automa-co: Layouts di base. h5p://docs.oracle.com/javafx/2/ layout/jfxpub- layout.htm

Posizionamento automa-co: Layouts di base. h5p://docs.oracle.com/javafx/2/ layout/jfxpub- layout.htm Posizionamento automa-co: Layouts di base h5p://docs.oracle.com/javafx/2/ layout/jfxpub- layout.htm Layout: HBox public class Layout1 extends Application { Pane layout=new HBox(); layout.getchildren().add(new

More information

c 2017 All rights reserved. This work may be distributed or shared at no cost, but may not be modified.

c 2017 All rights reserved. This work may be distributed or shared at no cost, but may not be modified. Introduction to JavaFX for Beginner Programmers Robert Ball, Ph.D. August 16, 2017 Version 0.1.4 c 2017 All rights reserved. This work may be distributed or shared at no cost, but may not be modified.

More information

Sri Vidya College of Engineering & Technology

Sri Vidya College of Engineering & Technology UNIT-V TWO MARKS QUESTION & ANSWER 1. What is the difference between the Font and FontMetrics class? Font class is used to set or retrieve the screen fonts.the Font class maps the characters of the language

More information

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7 PROGRAMMING DESIGN USING JAVA (ITT 303) Graphical User Interface Unit 7 Learning Objectives At the end of this unit students should be able to: Build graphical user interfaces Create and manipulate buttons,

More information

Window Interfaces Using Swing Objects

Window Interfaces Using Swing Objects Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs

More information

Graphical User Interfaces

Graphical User Interfaces Graphical User Interfaces CSC 1051 Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: http://www.csc.villanova.edu/~map/1051/

More information

JavaFX a Crash Course. Tecniche di Programmazione A.A. 2017/2018

JavaFX a Crash Course. Tecniche di Programmazione A.A. 2017/2018 JavaFX a Crash Course Tecniche di Programmazione JavaFX applications 2 Application structure Stage: where the application will be displayed (e.g., a Windows window) Scene: one container of Nodes that compose

More information

Windows and Events. created originally by Brian Bailey

Windows and Events. created originally by Brian Bailey Windows and Events created originally by Brian Bailey Announcements Review next time Midterm next Friday UI Architecture Applications UI Builders and Runtimes Frameworks Toolkits Windowing System Operating

More information

Essential JavaFX. Using layouts. Panes in JavaFX. Layouts. Tobias Andersson Gidlund LAYOUTS

Essential JavaFX. Using layouts. Panes in JavaFX. Layouts. Tobias Andersson Gidlund LAYOUTS Essential JavaFX Tobias Andersson Gidlund tobias.andersson.gidlund@lnu.se November 15, 2012 Essential JavaFX 1(36) LAYOUTS Essential JavaFX 2(36) Using layouts Since JavaFX still is Java, the use of layout

More information

Graphical User Interfaces

Graphical User Interfaces Graphical User Interfaces CSC 1051 Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: http://www.csc.villanova.edu/~map/1051/

More information

JavaFX fundamentals. Tecniche di Programmazione A.A. 2012/2013

JavaFX fundamentals. Tecniche di Programmazione A.A. 2012/2013 JavaFX fundamentals Tecniche di Programmazione Summary 1. Application structure 2. The Scene Graph 3. Events 4. Properties and Bindings 2 Application structure Introduction to JavaFX 4 Separation of concerns

More information

canoo Engineering AG

canoo Engineering AG Gerrit Grunwald canoo Engineering AG Twitter: @hansolo_ blog: harmonic-code.org Agenda history controls scene graph css Java API WebView properties JFXPanel Bindings charts Some History Roadmap What Java

More information

Window Interfaces Using Swing Objects

Window Interfaces Using Swing Objects Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs

More information

Building Graphical user interface using JavaFX

Building Graphical user interface using JavaFX CS244 Advanced programming Applications Building Graphical user interface using JavaFX Dr Walid M. Aly Lecture 6 JavaFX vs Swing and AWT When Java was introduced, the GUI classes were bundled in a library

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Exam Paper CMPE212, WINTER TERM, 2016 FINAL EXAMINATION 9am to 12pm, 19 APRIL 2016 Instructor: Alan McLeod If the instructor is unavailable

More information

1. (5 points) In your own words, describe what an instance is.

1. (5 points) In your own words, describe what an instance is. SE1021 Exam 2 Name: 1. (5 points) In your own words, describe what an instance is. 2. (5 points) Consider the Apple class in the UML diagram on the right. Write a couple lines of code to call the instance

More information

Command-Line Applications. GUI Libraries GUI-related classes are defined primarily in the java.awt and the javax.swing packages.

Command-Line Applications. GUI Libraries GUI-related classes are defined primarily in the java.awt and the javax.swing packages. 1 CS257 Computer Science I Kevin Sahr, PhD Lecture 14: Graphical User Interfaces Command-Line Applications 2 The programs we've explored thus far have been text-based applications A Java application is

More information

Java - Applets. C&G criteria: 1.2.2, 1.2.3, 1.2.4, 1.3.4, 1.2.4, 1.3.4, 1.3.5, 2.2.5, 2.4.5, 5.1.2, 5.2.1,

Java - Applets. C&G criteria: 1.2.2, 1.2.3, 1.2.4, 1.3.4, 1.2.4, 1.3.4, 1.3.5, 2.2.5, 2.4.5, 5.1.2, 5.2.1, Java - Applets C&G criteria: 1.2.2, 1.2.3, 1.2.4, 1.3.4, 1.2.4, 1.3.4, 1.3.5, 2.2.5, 2.4.5, 5.1.2, 5.2.1, 5.3.2. Java is not confined to a DOS environment. It can run with buttons and boxes in a Windows

More information

UI Elements. If you are not working in 2D mode, you need to change the texture type to Sprite (2D and UI)

UI Elements. If you are not working in 2D mode, you need to change the texture type to Sprite (2D and UI) UI Elements 1 2D Sprites If you are not working in 2D mode, you need to change the texture type to Sprite (2D and UI) Change Sprite Mode based on how many images are contained in your texture If you are

More information

Ges$one di base degli even$

Ges$one di base degli even$ Ges$one di base degli even$ Mul$Listener public class Event0 extends Application { Olistener o=new OListener(); Elistener e=new EListener(); btn.addeventhandler(actionevent.action, o); btn.addeventhandler(actionevent.action,

More information

Implementing Graphical User Interfaces

Implementing Graphical User Interfaces Chapter 6 Implementing Graphical User Interfaces 6.1 Introduction To see aggregation and inheritance in action, we implement a graphical user interface (GUI for short). This chapter is not about GUIs,

More information

Java - Applets. public class Buttons extends Applet implements ActionListener

Java - Applets. public class Buttons extends Applet implements ActionListener Java - Applets Java code here will not use swing but will support the 1.1 event model. Legacy code from the 1.0 event model will not be used. This code sets up a button to be pushed: import java.applet.*;

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CISC124, FALL TERM, 2015 FINAL EXAMINATION 7pm to 10pm, 15 DECEMBER 2015 Instructor: Alan McLeod If the instructor

More information

C15: JavaFX: Styling, FXML, and MVC

C15: JavaFX: Styling, FXML, and MVC CISC 3120 C15: JavaFX: Styling, FXML, and MVC Hui Chen Department of Computer & Information Science CUNY Brooklyn College 10/19/2017 CUNY Brooklyn College 1 Outline Recap and issues Styling user interface

More information

Advanced Java for Bioinformatics Winter 2017/18. Prof. Daniel Huson

Advanced Java for Bioinformatics Winter 2017/18. Prof. Daniel Huson Advanced Java for Bioinformatics, WS 17/18, D. Huson, November 8, 2017 1 1 Introduction Advanced Java for Bioinformatics Winter 2017/18 Prof. Daniel Huson Office hours: Thursdays 17-18h (Sand 14, C310a)

More information

GUI Components: Part 1

GUI Components: Part 1 1 2 11 GUI Components: Part 1 Do you think I can listen all day to such stuff? Lewis Carroll Even a minor event in the life of a child is an event of that child s world and thus a world event. Gaston Bachelard

More information

Graphical User Interfaces

Graphical User Interfaces Graphical User Interfaces CSC 1051 Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Outline Pixels & bits & colors JavaFX Introduction

More information

CS 2110 Fall Instructions. 1 Installing the code. Homework 4 Paint Program. 0.1 Grading, Partners, Academic Integrity, Help

CS 2110 Fall Instructions. 1 Installing the code. Homework 4 Paint Program. 0.1 Grading, Partners, Academic Integrity, Help CS 2110 Fall 2012 Homework 4 Paint Program Due: Wednesday, 12 November, 11:59PM In this assignment, you will write parts of a simple paint program. Some of the functionality you will implement is: 1. Freehand

More information

CSC207H: Software Design Lecture 11

CSC207H: Software Design Lecture 11 CSC207H: Software Design Lecture 11 Wael Aboelsaadat wael@cs.toronto.edu http://ccnet.utoronto.ca/20075/csc207h1y/ Office: BA 4261 Office hours: R 5-7 Acknowledgement: These slides are based on material

More information

JavaFX. Getting Started with JavaFX Scene Builder Release 1.1 E

JavaFX. Getting Started with JavaFX Scene Builder Release 1.1 E JavaFX Getting Started with JavaFX Scene Builder Release 1.1 E25448-03 October 2013 JavaFX Getting Started with JavaFX Scene Builder, Release 1.1 E25448-03 Copyright 2012, 2013 Oracle and/or its affiliates.

More information

JavaFX Basics. Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. 1.

JavaFX Basics. Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. 1. JavaFX Basics rights reserved. 1 Motivations JavaFX is a new framework for developing Java GUI programs. The JavaFX API is an excellent example of how the object-oriented principle is applied. This chapter

More information

Introduction to the JAVA UI classes Advanced HCI IAT351

Introduction to the JAVA UI classes Advanced HCI IAT351 Introduction to the JAVA UI classes Advanced HCI IAT351 Week 3 Lecture 1 17.09.2012 Lyn Bartram lyn@sfu.ca About JFC and Swing JFC Java TM Foundation Classes Encompass a group of features for constructing

More information

Building a Java First-Person Shooter

Building a Java First-Person Shooter Building a Java First-Person Shooter Episode 4 How Rendering Works [Last updated 5/02/2017] URL https://www.youtube.com/watch?v=6doiju7--jg&index=5&list=pl656dade0da25adbb Objectives This is a very short

More information

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS Glossary of Terms 2-4 Step by Step Instructions 4-7 HWApp 8 HWFrame 9 Never trust a computer

More information

Computational Expression

Computational Expression Computational Expression Graphics Janyl Jumadinova 6 February, 2019 Janyl Jumadinova Computational Expression 6 February, 2019 1 / 11 Java Graphics Graphics can be simple or complex, but they are just

More information

GUI Event Handlers (Part I)

GUI Event Handlers (Part I) GUI Event Handlers (Part I) 188230 Advanced Computer Programming Asst. Prof. Dr. Kanda Runapongsa Saikaew (krunapon@kku.ac.th) Department of Computer Engineering Khon Kaen University 1 Agenda General event

More information

Programming graphics

Programming graphics Programming graphics Need a window javax.swing.jframe Several essential steps to use (necessary plumbing ): Set the size width and height in pixels Set a title (optional), and a close operation Make it

More information

GUI DYNAMICS Lecture July 26 CS2110 Summer 2011

GUI DYNAMICS Lecture July 26 CS2110 Summer 2011 GUI DYNAMICS Lecture July 26 CS2110 Summer 2011 GUI Statics and GUI Dynamics 2 Statics: what s drawn on the screen Components buttons, labels, lists, sliders, menus,... Containers: components that contain

More information

CS 160: Interactive Programming

CS 160: Interactive Programming CS 160: Interactive Programming Professor John Canny 3/8/2006 1 Outline Callbacks and Delegates Multi-threaded programming Model-view controller 3/8/2006 2 Callbacks Your code Myclass data method1 method2

More information

CISC 1600, Lab 2.1: Processing

CISC 1600, Lab 2.1: Processing CISC 1600, Lab 2.1: Processing Prof Michael Mandel 1 Getting set up For this lab, we will be using Sketchpad, a site for building processing sketches online using processing.js. 1.1. Go to http://cisc1600.sketchpad.cc

More information

JavaFX. Using Image Ops Release 2.2 E

JavaFX. Using Image Ops Release 2.2 E JavaFX Using Image Ops Release 2.2 E38237-02 June 2013 JavaFX/Using Image Ops, Release 2.2 E38237-02 Copyright 2012, 2013 Oracle and/or its affiliates. All rights reserved. Primary Author: Scott Hommel

More information

Final Assignment for CS-0401

Final Assignment for CS-0401 Final Assignment for CS-0401 1 Introduction In this assignment you will create a program with an Graphical User Interface that will help customers to decide what car and car features that they want. In

More information

CS 170 Java Programming 1. Week 9: Learning about Loops

CS 170 Java Programming 1. Week 9: Learning about Loops CS 170 Java Programming 1 Week 9: Learning about Loops What s the Plan? Topic 1: A Little Review ACM GUI Apps, Buttons, Text and Events Topic 2: Learning about Loops Different kinds of loops Using loops

More information

CS 160: Lecture 10. Professor John Canny Spring 2004 Feb 25 2/25/2004 1

CS 160: Lecture 10. Professor John Canny Spring 2004 Feb 25 2/25/2004 1 CS 160: Lecture 10 Professor John Canny Spring 2004 Feb 25 2/25/2004 1 Administrivia In-class midterm on Friday * Closed book (no calcs or laptops) * Material up to last Friday Lo-Fi Prototype assignment

More information

Case studies: Outline Case Study: Noughts and Crosses

Case studies: Outline Case Study: Noughts and Crosses I. Automated Banking System Case studies: Outline Case Study: Noughts and Crosses II. III. Library Noughts and Crosses Definition of the problem Game played on a 3x3 square board between two players. The

More information

Real World. static methods and Console & JavaFX App Intros. Lecture 16. Go ahead and PULL Lecture Materials & Sign-in on PollEv

Real World. static methods and Console & JavaFX App Intros. Lecture 16. Go ahead and PULL Lecture Materials & Sign-in on PollEv Go ahead and PULL Lecture Materials & Sign-in on PollEv Poll Everywhere: pollev.com/comp110 Lecture 16 static methods and Console & JavaFX App Intros Real World Spring 2016 Today Our first apps without

More information

Java Programming Lecture 7

Java Programming Lecture 7 Java Programming Lecture 7 Alice E. Fischer Feb 16, 2015 Java Programming - L7... 1/16 Class Derivation Interfaces Examples Java Programming - L7... 2/16 Purpose of Derivation Class derivation is used

More information