Building Graphical user interface using JavaFX

Size: px
Start display at page:

Download "Building Graphical user interface using JavaFX"

Transcription

1 CS244 Advanced programming Applications Building Graphical user interface using JavaFX Dr Walid M. Aly Lecture 6

2 JavaFX vs Swing and AWT When Java was introduced, the GUI classes were bundled in a library known as the Abstract Windows Toolkit (AWT). The AWT user-interface components were replaced by a more robust, versatile, and flexible library known as Swing components. With the release of Java 8, Swing is replaced by a completely new GUI platform known as JavaFX. 2

3 Basic Structure of JavaFX Every JavaFX program is defined in a class that extends javafx.application.application A JavaFX program can run stand-alone or from a Web browser Application Override the start(stage primarystage) method Stage, Scene, and Nodes Stage Scene Button 3

4 import javafx.application.application; import javafx.scene.scene; import javafx.scene.control.button; import javafx.stage.stage; public class MyJavaFX extends Application { public void start(stage primarystage) { Button btok = new Button("OK"); Scene scene = new Scene(btOK, 200, 250); primarystage.settitle("myjavafx"); // Set the stage title primarystage.setscene(scene); // Place the scene in the stage primarystage.show( ); // Display the stage } public static void main(string[] args) { launch(args); } } MyJavaFX 4

5 Notes on MyJavaFX.java The launch method (line 22) is a static method defined in the Application class for launching a stand-alone JavaFX application. The main method (lines 21 23) is not needed if you run the program from the command line. It may be needed to launch a JavaFX program from an IDE with a limitedjavafx support. When you run a JavaFX application without a main method, JVM automatically invokes the launch method to run the application. public static void main(string[] args) { launch(args); } 5

6 Notes on MyJavaFX.java The main class overrides the start method defined in javafx.application.application After a JavaFX application is launched:- the JVM constructs an instance of the class using its no-arg constructor and invokes itsstart method. The start method normally places UI controls in a scene and displays the scene in a stage public void start(stage primarystage) { // Create a button and place it in the scene Button btok = new Button("OK"); Scene scene = new Scene(btOK, 200, 250); primarystage.settitle("myjavafx"); // Set the stage title primarystage.setscene(scene); // Place the scene in the stag,,stage dimensions will adapt to scene primarystage.show(); // Display the stage } 6

7 Stage-Scene A Stage object is a window. A Stage object called primary stage is automatically created by the JVM when the application is launched You can create additional stages if needed Class Button is subclass of class Parent javafx.stage.stage public final void setscene(scene value) Specify the scene to be used on this stage. Stage ( ) Creates a new instance of decorated Stage. public final void show() show this Window by setting visibility to true javafx.scene.scene Scene(Parent root, double width, double height) Creates a Scene for a specific root Node with a specific size. 7

8 Example:Multiple Stages public void start(stage primarystage) { // Create a scene and place a button in the scene Scene scene = new Scene(new Button("OK"), 200, 250); primarystage.settitle("myjavafx"); // Set the stage title primarystage.setscene(scene); // Place the scene in the stage primarystage.show(); // Display the stage Stage stage = new Stage(); // Create a new stage stage.settitle("second Stage"); // Set the stage title // Set a scene with a button in the stage stage.setscene(new Scene(new Button("New Stage"), 100, 100)); stage.show(); // Display the stage } MultipleStageDemo 8

9 Panes, UI Controls, and Shapes When you run MyJavaFX, The button is always centered in the scene and occupies the entire window no matter how you resize it. You can fix the problem by setting the position and size properties of a button. a better approach is to use container classes, called panes, for automatically laying out the nodes in a desired location and size. You place nodes inside a pane and then place the pane into a scene. 9

10 Panes, UI Controls, and Shapes qa node is a visual component such as a shape, an image view, a UI control, or a pane. q A shape refers to a text, line, circle, ellipse, rectangle, arc, polygon, polyline, etc. q A UI control refers to a label, button, check box, radio button, text field, text area, etc. q A node can be placed only in one pane. Otherwise an exception is thrown q a pane is a node. So a pane can be added into another pane. 10

11 Panes, UI Controls, and Shapes Stage can have only one Scene but will own solely its reference Scene can have only one Parent but will own solely its reference Pane can have many nodes, but will own solely each reference of them 11

12 Panes, UI Controls, and Shapes 12

13 javafx.scene.layout.pane public class Pane extends Region This class may be used directly in cases where absolute positioning of children is required since it does not perform layout beyond resizing resizable children to their preferred sizes. It is the application's responsibility to position the children since the pane leaves the positions alone during layout Pane pane = new Pane(); pane.getchildren().add(new Button(" ")); pane.getchildren().add(new Button("Hello World")); pane.getchildren().add(new Button("W")); Pane( ) Creates a Pane layout javafx.scene.layout.pane protected ObservableList<Node> getchildren( ) Gets the list of children of this Parent. javafx.collections. ObservableList<E> boolean add(e e) Appends the specified element to the end of this list 13

14 javafx.scene.layout.stackpane javafx.scene.layout.stackpane StackPane( ) Creates a StackPane layout with default CENTER alignment. protected ObservableList<Node> getchildren( ) Gets the list of children of this Parent. Ø StackPane lays out its children in a back-to-front stack. The StackPane respects a node s preferred size Ø A StackPane places the nodes in the center and nodes are placed on top of each other Ø The z-order of the children is defined by the order of the children list with the 0th child being the bottom and last child on top Ø Alignment property, :defaults to Pos.CENTER. 14

15 Example:using StackPane import javafx.application.application; import javafx.scene.scene; import javafx.scene.control.button; import javafx.scene.layout.stackpane; import javafx.stage.stage; public class ButtonInPane extends Application { public void start(stage primarystage) { // Create a scene and place a button in the scene StackPane pane = new StackPane(); pane.getchildren().add(new Button("Hello World")); pane.getchildren().add(new Button("OK..")); pane.getchildren().add(new Button("H")); Scene scene = new Scene(pane, 200, 200); primarystage.settitle("buttons in a stack pane"); // Set the stage title primarystage.setscene(scene); // Place the scene in the stage primarystage.show( ); // Display the stage } public static void main(string[] args) { launch(args); } } ButtonInPane 15

16 Display a Shape This example displays a circle in the center of the pane. x (0, 0) X Axis Y Axis y Y Axis (x, y) Java Coordinate System Conventional Coordinate System (0, 0) X Axis ShowCircle (a) A circle is displayed in the center of the scene. (b) Using Pane,the circle is not centered after the window is resized.

17 Display a Shape.. If the pane was of type StackPane, the circle will be centered will the pane is resized, Stack pane automatically places nodes in the center of the pane public void start(stage primarystage) { // Create a circle and set its properties Circle circle = new Circle(); circle.setcenterx(100); circle.setcentery(100); circle.setradius(50); circle.setstroke(color.black); circle.setfill(null); // Create a pane to hold the circle Pane pane = new StackPane(); pane.getchildren().add(circle); // Create a scene and place it in the stage Scene scene = new Scene(pane, 200, 200); primarystage.settitle("showcircle in Stacked Pane"); primarystage.setscene(scene); // Place the scene in the stage primarystage.show(); // Display the stage ShowCircleInStackPane.java 17

18 Common Properties and Methods for Nodes style: set a JavaFX CSS style The syntax for setting a style is stylename:value. Multiple style properties for a node can be set together separated by semicolon (;). For example, the following statement circle.setstyle("-fx-stroke: black; -fx-fill: red;"); sets two JavaFX CSS properties for a circle. This statement is equivalent to the following two statements. circle.setstroke(color.black); circle.setfill(color.red); rotate: Rotate a node javafx.scene.node public final void setstyle(java.lang.string value) A string representation of the CSS style associated with this specific Node. This is analogous to the "style" attribute of an HTML element NodeStyleRotateDemo 18

19 The Color Class 19

20 The Font Class 20

21 Label label = new Label("JavaFX"); label.setfont(font.font("times New Roman",FontWeight.BOLD, FontPosture.ITALIC, 20)); pane.getchildren( ).add(label); FontDemo 21

22 The Image and ImageView Classes the ImageView class can be used to display an image. The javafx.scene.image.image class represents a graphical image and is used for loading an image from a specified filename or a URL. new Image("image/us.gif") new Image(" 22

23 The ImageView Class 23

24 Example:Using ImageView import javafx.application.application;. public class ShowImage extends Application { public void start(stage primarystage) { Pane pane = new HBox(10); pane.setpadding(new Insets(5, 5, 5, 5)); Image image = new Image("image/us.gif"); pane.getchildren().add(new ImageView(image)); ImageView imageview2 = new ImageView(image); imageview2.setfitheight(100); imageview2.setfitwidth(100); pane.getchildren().add(imageview2); ImageView imageview3 = new ImageView(image); imageview3.setrotate(90); pane.getchildren().add(imageview3); Scene scene = new Scene(pane); primarystage.settitle("showimage"); // Set the stage title primarystage.setscene(scene); // Place the scene in the stage primarystage.show(); // Display the stage }.. } The padding property can be set to manage the distance between the nodes and the edges of thehbox pane ShowImage 24

25 Notes on previous program The program creates an HBox (line 14). An HBox is a pane that places all nodes horizontally in one row. The setrotate method is defined in the Node class and can be used for any node. an Image object can be shared by multiple nodes. In this case, it is shared by three ImageView. However, a node such as ImageView cannot be shared. You cannot place an ImageView multiple times into a pane or scene. Note that you must place the image file in the same directory as the class file, as shown in the following figure. 25

26 References pub-get_started.htm

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 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.

More information

Graphical User Interfaces JavaFX GUI Basics. CSE114, Computer Science I Stony Brook University

Graphical User Interfaces JavaFX GUI Basics. CSE114, Computer Science I Stony Brook University Graphical User Interfaces JavaFX GUI Basics CSE114, Computer Science I Stony Brook University http://www.cs.stonybrook.edu/~cse114 GUI Examples 2 GUI Graphical User Interface (GUI) provides user-friendly

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

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

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

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

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

Grafica e non solo: Java FX

Grafica e non solo: Java FX Grafica e non solo: Java FX Creazione di una Applicazione JavaFX public class JavaFXApplica/onTEST extends Applica/on { @Override public void start(stage primarystage) { BuCon btn = new BuCon(); btn.settext("say

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

JavaFX:Using Built-in Layout Panes

JavaFX:Using Built-in Layout Panes CS244 Advanced programming Applications JavaFX:Using Built-in Layout Panes Dr Walid M. Aly Lecture 7 Example of JavaFX nodes http://docs.oracle.com/javafx/2/ui_controls/overview.htm# 2 Shapes JavaFX provides

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

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

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

PART ONE CREATING THE BOARD AND MAIN SPRITES

PART ONE CREATING THE BOARD AND MAIN SPRITES PART ONE CREATING THE BOARD AND MAIN SPRITES SETTING UP THE WINDOW Create a new basic JavaFX application. Use a Group for the main layout. When setting the scene, ensure the basic window is 800 by 600.

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

Grafica e non solo: Java FX

Grafica e non solo: Java FX Grafica e non solo: Java FX Creazione di una Applicazione JavaFX public class JavaFXApplica/onTEST extends Applica/on { @Override public void start(stage primarystage) { BuCon btn = new BuCon(); btn.settext("say

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

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

COMP1406 Tutorial 5. Objectives: Getting Started: Tutorial Problems:

COMP1406 Tutorial 5. Objectives: Getting Started: Tutorial Problems: COMP1406 Tutorial 5 Objectives: Learn how to create a window with various components on it. Learn how to create a Pane and use it in more than one GUI. To become familiar with the use of Buttons, TextFields

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

Grafica e non solo: Java FX

Grafica e non solo: Java FX Grafica e non solo: Java FX Creazione di una Applicazione JavaFX public class JavaFXApplicationTEST extends Application { @Override public void start(stage primarystage) { Button btn = new Button(); btn.settext("say

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

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

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

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

CS-202 Introduction to Object Oriented Programming

CS-202 Introduction to Object Oriented Programming CS-202 Introduction to Object Oriented Programming California State University, Los Angeles Computer Science Department Lecture 13 JavaFX Basics Part 2 Slides by Keenan Knaur The Image and ImageView Classes

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

JavaFX Application Structure. Tecniche di Programmazione A.A. 2017/2018

JavaFX Application Structure. Tecniche di Programmazione A.A. 2017/2018 JavaFX Application Structure Tecniche di Programmazione Application structure Introduction to JavaFX Empty JavaFX window public class Main extends Application { @Override public void start(stage stage)

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

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

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

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

Threads & Timers. CSE260, Computer Science B: Honors Stony Brook University

Threads & Timers. CSE260, Computer Science B: Honors Stony Brook University Threads & Timers CSE260, Computer Science B: Honors Stony Brook University http://www.cs.stonybrook.edu/~cse260 Multi-tasking When you re working, how many different applications do you have open at one

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

Definizione dei costru'ori

Definizione dei costru'ori Costru'ori Definizione dei costru'ori Se per una classe A non scrivo nessun costru'ore, il sistema automa9camente crea il costru'ore A(); Se invece definisco almeno un costru'ore non void, ad es. A(int

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

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

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

Java FX GUI. Pieter van den Hombergh. May 31, Fontys Hogeschool voor Techniek en Logistiek. Java FX GUI. Pieter van den Homb

Java FX GUI. Pieter van den Hombergh. May 31, Fontys Hogeschool voor Techniek en Logistiek. Java FX GUI. Pieter van den Homb ergh Fontys Hogeschool voor Techniek en Logistiek May 31, 2016 ergh/fhtenl May 31, 2016 1/10 JAVA FX Application A java fx gui application uses a different way to start. A javafx application extends javafx.application.application

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

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

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

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

@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

Graphical User Interfaces JavaFX GUI Basics, Event Programming and GUI UI Controls

Graphical User Interfaces JavaFX GUI Basics, Event Programming and GUI UI Controls Graphical User Interfaces JavaFX GUI Basics, Event Programming and GUI UI Controls CSE260, Computer Science B: Honors Stony Brook University http://www.cs.stonybrook.edu/~cse260 GUI Examples 2 GUI Graphical

More information

The main method. The program s entry point

The main method. The program s entry point The main method The program s entry point A program has to start somewhere You invoke the JVM in order to run a Java application. Typically (at least in our books/courses) from the command line Using the

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

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

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

JavaFX. Embedding Swing Content in JavaFX Applications Release 8.0 Developer Preview E

JavaFX. Embedding Swing Content in JavaFX Applications Release 8.0 Developer Preview E JavaFX Embedding Swing Content in JavaFX Applications Release 8.0 Developer Preview E41513-01 September 2013 JavaFX /Embedding Swing Content in JavaFX Applications, Release 8.0 Developer Preview E41513-01

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

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

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

PROGRAMMIERPRAKTIKUM GRAPHICAL USER INTERFACES. Tobias Witt

PROGRAMMIERPRAKTIKUM GRAPHICAL USER INTERFACES. Tobias Witt PROGRAMMIERPRAKTIKUM GRAPHICAL USER INTERFACES Tobias Witt K.O.-SYSTEM Korrekt Oida! Jeder Student für jeden Meilenstein 1, ½ oder 0 K.O. Erstes K.O. für den Eingangstest ab 15 Punkten (ohne Aufgabe 3)

More information

JavaFX. Working with Layouts in JavaFX Release 8 E

JavaFX. Working with Layouts in JavaFX Release 8 E JavaFX Working with Layouts in JavaFX Release 8 E50476-01 March 2014 Learn how to use the Layout API and built-in layout panes to lay out the interface for your JavaFX application. JavaFX Working with

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

light side dark side canoo

light side dark side canoo CON 1072 light side dark side han Solo (Also known as Gerrit Grunwald) Former smuggler, now Leader in the Rebel Alliance. Captain of the Millennium Falcon and sometimes involved in some Java business at

More information

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

Composite Pattern Diagram. Explanation. JavaFX Subclass Hierarchy, cont. JavaFX: Node. JavaFX Layout Classes. Top-Level Containers 10/12/2018 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(

More information

Java Programming Hello FX

Java Programming Hello FX Java Programming Hello FX Alice E. Fischer Feb 16, 2015 Java Programming - Hello FX... 1/22 Winter Colors Fonts Spring Circle Demo Java Programming - Hello FX... 2/22 Example: Winter Introduction to fx

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

Copyright 2012, Oracle and/or its affiliates. All rights reserved.

Copyright 2012, Oracle and/or its affiliates. All rights reserved. 1 Custom Controls Paru Somashekar parvathi.somashekar@oracle.com Jonathan Giles Tech Lead, JavaFX UI Controls jonathan.giles@oracle.com 2 The following is intended to outline our general product direction.

More information

Govt. of Karnataka, Department of Technical Education Diploma in Information Science & Engineering. Fifth Semester

Govt. of Karnataka, Department of Technical Education Diploma in Information Science & Engineering. Fifth Semester Govt. of Karnataka, Department of Technical Education Diploma in Information Science & Engineering Fifth Semester Subject: Programming With Java Contact Hrs / week: 4 Total hrs: 64 Table of Contents SN

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 UNIVERSIY SCHOOL O COMPUING CISC124, ALL ERM, 2015 INAL EXAMINAION 7pm to 10pm, 15 DECEMBER 2015 Instructor: Alan McLeod HAND IN Answers Are Recorded on Question Paper SOLUION If the instructor

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

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

Chapter 2 First Java Programs

Chapter 2 First Java Programs First Java Programs Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Why is Java an important programming language? What is the Java virtual machine and byte code? What are

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

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

Lesson 2: First Java Programs

Lesson 2: First Java Programs Lesson 2: First Java Programs Lesson 2: First Java Programs Objectives: Discuss why Java is an important programming language. Explain the Java virtual machine and byte code. Choose a user interface style.

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

5 Drawing Stuff in 2D

5 Drawing Stuff in 2D 16 Advanced Java for Bioinformatics, WS 17/18, D. Huson, November 6, 2017 5 Drawing Stuff in 2D The scene graph is a tree whose nodes are layout items, controls and, as we will see, graphic objects. JavaFX

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

Outline. Introduction to Java. What Is Java? History. Java 2 Platform. Java 2 Platform Standard Edition. Introduction Java 2 Platform

Outline. Introduction to Java. What Is Java? History. Java 2 Platform. Java 2 Platform Standard Edition. Introduction Java 2 Platform Outline Introduction to Java Introduction Java 2 Platform CS 3300 Object-Oriented Concepts Introduction to Java 2 What Is Java? History Characteristics of Java History James Gosling at Sun Microsystems

More information

How to lay out a web page with CSS

How to lay out a web page with CSS How to lay out a web page with CSS You can use table design features in Adobe Dreamweaver CS3 to create a simple page layout. However, a more powerful technique is to use Cascading Style Sheets (CSS).

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

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. OpenCV

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. OpenCV About the Tutorial OpenCV is a cross-platform library using which we can develop real-time computer vision applications. It mainly focuses on image processing, video capture and analysis including features

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

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

CSS Selectors. element selectors. .class selectors. #id selectors

CSS Selectors. element selectors. .class selectors. #id selectors CSS Selectors Patterns used to select elements to style. CSS selectors refer either to a class, an id, an HTML element, or some combination thereof, followed by a list of styling declarations. Selectors

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

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

Wednesday, November 16, 11

Wednesday, November 16, 11 1 JavaFX 2.0 Danny Coward Principal Engineer What is JavaFX 2.0 JavaFX is the evolution of the Java rich client platform, designed to address the needs of today s and tomorrow s customers.

More information

Developing applications using JavaFX

Developing applications using JavaFX Developing applications using JavaFX Cheshta, Dr. Deepti Sharma M.Tech Scholar, Dept. of CSE, Advanced Institute of Technology & Management, Palwal, Haryana, India HOD, Dept. of CSE, Advanced Institute

More information

The new SmartDashboard (SFX)

The new SmartDashboard (SFX) The new SmartDashboard (SFX) We have a new SmartDashboard that uses the more modern JavaFX for it's user interface. This has the promise of much richer user interfaces since it allows the widgets to have

More information

Outline. Composite Pattern. Model-View-Controller Pattern Callback Pattern

Outline. Composite Pattern. Model-View-Controller Pattern Callback Pattern Outline Composite Pattern Motivation Structure Transparent vs Safe composite Applications: AWT & Swing Composite Problems: Alias references Model-View-Controller Pattern Callback Pattern 1 Composite Pattern

More information

JAVAFX 101 [CON3826]

JAVAFX 101 [CON3826] JAVAFX 101 [CON3826] Alexander Casall sialcasa JavaFX Script 1.0 Script Language Flash Successor 1.3 JavaFX 2.0 Java API OpenJFX JavaFX 8 Classpath 3D API Printing 8.X Accessibility, Controls... F3 Today

More information

ADOBE 9A Adobe Dreamweaver CS4 ACE.

ADOBE 9A Adobe Dreamweaver CS4 ACE. ADOBE 9A0-090 Adobe Dreamweaver CS4 ACE http://killexams.com/exam-detail/9a0-090 ,D QUESTION: 74 You use an image throughout your Web site. You want to be able to add this image to various Web pages without

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

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. Working with JavaFX Graphics Release 8 E

JavaFX. Working with JavaFX Graphics Release 8 E JavaFX Working with JavaFX Graphics Release 8 E50627-01 March 2014 In this tutorial, you learn how to use the graphics features (3D, canvas, and imageops) that are available through the JavaFX APIs. JavaFX

More information

An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a

An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a CBOP3203 An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a page. When you use a Java technology-enabled

More information

For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to

For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to access them. Contents at a Glance About the Authors...

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

As we design and build out our HTML pages, there are some basics that we may follow for each page, site, and application.

As we design and build out our HTML pages, there are some basics that we may follow for each page, site, and application. Extra notes - Client-side Design and Development Dr Nick Hayward HTML - Basics A brief introduction to some of the basics of HTML. Contents Intro element add some metadata define a base address

More information

Horse in Mo&on. HorseInMo&on

Horse in Mo&on. HorseInMo&on Anima&on in JavaFX Horse in Mo&on HorseInMo&on Horse in Mo&on Esempio di Anima&on public void start(stage primarystage) { final String content = "Animazioni Java FX"; final Text text = new Text(10, 20,

More information

JavaFX. Skinning JavaFX Applications with CSS Release 2.2 E

JavaFX. Skinning JavaFX Applications with CSS Release 2.2 E JavaFX Skinning JavaFX Applications with CSS Release 2.2 E20470-06 June 2013 Learn how to skin your JavaFX applications using cascading style sheets (CSS) to create a custom look. JavaFX/Skinning JavaFX

More information

Responsive Web Design (RWD)

Responsive Web Design (RWD) Responsive Web Design (RWD) Responsive Web Design: design Web pages, so that it is easy to see on a wide range of of devices phone, tablet, desktop,... Fixed vs Fluid layout Fixed: elements have fixed

More information

HTML5, CSS3, JQUERY SYLLABUS

HTML5, CSS3, JQUERY SYLLABUS HTML5, CSS3, JQUERY SYLLABUS AAvhdvchdvchdvhdh HTML HTML - Introduction HTML - Elements HTML - Tags HTML - Text HTML - Formatting HTML - Pre HTML - Attributes HTML - Font HTML - Text Links HTML - Comments

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

CSC Website Design, Spring CSS Flexible Box

CSC Website Design, Spring CSS Flexible Box CSC 122 - Website Design, Spring 2017 CSS Flexible Box CSS Flexible Box Layout Module The CSS flexbox can be used to ensure that elements behave predictably when the page layout must accommodate different

More information