Chapter 14 JavaFX Basics Dr. Clincy - Lecture.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming
Advertisements

View-Based Application Development Lecture 1 1. Flows of Lecture 1 Before Lab Introduction to the Game to be developed in this workshop Comparison between.
1 Chapter 8 Objects and Classes Lecture 2 Prepared by Muhanad Alkhalisy.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Graphics Programming. In this class, we will cover: The difference between AWT and Swing Creating a frame Frame positioning Displaying information in.
Lecture 15 Graphical User Interfaces (GUI’s). Objectives Provide a general set of concepts for GUI’s Layout manager GUI components GUI Design Guidelines.
Introduction to GUI Programming
A.k.a. GUI’s.  If you want to discuss your Lab 2 grade come see me this week. ◦ Office: 436 ERB. One hour prior to class ◦ Open to Appointments MWF 
Written by Liron Blecher
GUI Basics: Introduction. Creating GUI Objects // Create a button with text OK JButton jbtOK = new JButton("OK"); // Create a label with text "Enter your.
Lesson 27: Introduction to the Java GUI. // helloworldbutton.java import java.awt.*; import javax.swing.*; class HelloButton{ public static void main.
Lab 6: Shapes & Picture Extended Ellipse & Rectangle Classes Stand-Alone GUI Applications.
3461A Readings from the Swing Tutorial. 3461A Overview  The follow is the Table of Contents from the trail “Creating a GUI with JFC/Swing” in the “The.
Introduction to Windows Programming
Session 27 Swing vs. AWT. AWT (Abstract Window ToolKit) It is a portable GUI library for stand-alone applications and/or applets. The Abstract Window.
School of Computer Science & Information Technology G6DICP - Lecture 17 GUI (Graphical User Interface) Programming.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
MSc Workshop - © S. Kamin, U. ReddyLect 3 - GUI -1 Lecture 3 - Graphical User Interfaces r GUI toolkits in Java API r JFrame r GUI components.
Object Oriented programming Instructor: Dr. Essam H. Houssein.
Applets Yong Choi School of Business CSU, Bakersfield.
GUI Basics. What is GUI? A graphical user interface (GUI) is a type of user interface item that allows people to interact with programs in more ways than.
Creating Windows. How can we use Java to create programs that use windows (GUI applications)? How can we use Java to create programs that use windows.
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
GUIs Graphical User Interfaces. Everything coming together Known: – Inheritance – Interfaces – Abstract classes – Polymorphism – Exceptions New: – Events.
GUI Basics. Agenda What GUI How to make in java Creating frames Frequently used GUI components Layout Managers.
CIS Intro to JAVA Lecture Notes Set 8 9-June-05.
Basics of GUI Programming Chapter 11 and Chapter 22.
Graphical User Interfaces Tonga Institute of Higher Education.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. 1 Chapter 14 JavaFX Basics.
Lecture # 6 Graphical User Interface(GUI). Introduction A graphical user interface (GUI) presents a user- friendly mechanism for interacting with an application.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
Introduction to GUI Programming in Java: Frames, Simple Components, and Layouts.
Getting Started with GUI Programming Chapter 10 CSCI 1302.
CIS 270—Application Development II Chapter 11—GUI Components: Part I.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. 1 Chapter 14 JavaFX Basics.
Lecture 7:Introduction to JavaFX Michael Hsu CSULA.
Introduction to Swing Mr. Crone. What is Swing? a collection of pre-made Java classes used to create a modern graphical user interface.
Introduction to Swing Mr. Crone. What is Swing? a collection of pre-made Java classes used to create a modern graphical user interface.
Lecture 7:Introduction to JavaFX Michael Hsu CSULA.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 7 Event-Driven Programming and Basic GUI Objects.
Chapter 14 JavaFX Basics.
CSC 205 Programming II Lecture 5 AWT - I.
Welcome To java
Java FX: Scene Builder.
Chapter 9: Graphical User Interfaces
Topics Graphical User Interfaces Using the tkinter Module
Lecture 7:Introduction to JavaFX
A First Look at GUI Applications
Chapter Topics 15.1 Graphical User Interfaces
Chapter 8: Writing Graphical User Interfaces
Java FX.
GUI Using Python.
EE 422C Java FX.
Chapter 14 JavaFX Basics Dr. Clincy - Lecture.
Chapter 15 Event-Driven Programming and Animations
Recall: Timeline Class
Chapter 15 Event-Driven Programming and Animations
CISC124 Last Quiz next week. Topics listed in Tuesday’s lecture.
Graphics Programming - Frames
Lecture 9 GUI and Event Driven CSE /16/2019.
Chapter 15: GUI Applications & Event-Driven Programming
Introduction to Graphical Interfaces in Java: AWT and Swing
Chapter 14 JavaFX Basics Part 1
Chapter 12 GUI Basics.
Introduction to Java FX
TA: Nouf Al-Harbi NoufNaief.net :::
TA: Nouf Al-Harbi NoufNaief.net :::
Presentation transcript:

Chapter 14 JavaFX Basics Dr. Clincy - Lecture

Java GUI Programming What is a graphical user interface (GUI) ? And what is GUI programming ? When Java was initially introduced, the GUI classes were bundled in a library known as the Abstract Windows Toolkit (AWT). AWT is fine for developing simple GUIs, but not good for developing comprehensive GUI projects. In addition, AWT is prone to platform-specific bugs. Later, the AWT was replaced by a more robust, versatile, and flexible library known as Swing components. Swing components depend less on the target platform and use less resources. With the release of Java 8, Swing is replaced by a completely new GUI platform known as JavaFX. JavaFX is a newer framework for developing Java GUI programs. Dr. Clincy - Lecture

Basic Structure of JavaFX javafx.application.Application class defines the essential framework for writing JavaFX programs Every JavaFX program is defined in a class that extends javafx.application.Application Stage object is automatically created by JVM when the application is launched – considered the window – you can have multiple stages. Scene object is the container for the content – considered the frame in the window – can have only one scene per stage or window Button object (or node) is a visual component such as a shape, image, UI control, groups, and panes. Used to invoke some type of action Container classes called panes can be used to help layout the nodes within a scene. Control refers to a label, check box, radio button, text field and etc. A group can be used to group a set of nodes Dr. Clincy - Lecture

Panes, UI Controls, and Shapes ( 1 ) One Scene per Stage ( 2 ) A Scene can contain a Control, Group or Pane ( 3 ) A Pane or Group can contain any subtype of Node ( 4 ) Will cover the various types of Panes later Dr. Clincy - Lecture

Basic Structure of JavaFX Program Every JavaFX program extends javafx.application.Application The main class overrides the start method defined in javafx.application.Application and JVM constructs an instance of the class and invoke the start method. Create a button object and places it in a Scene object Scene object created using the constructor – specifies width and height and places node in scene The Stage object is automatically created by JVM when the app is launched Name the Stage, set the scene in the stage, and display the stage. The launch method is static method used for launching stand-alone JavaFX apps. Not needed if you run it from a command line. Output of program displays a button in the window Dr. Clincy - Lecture

JavaFX Program w/Multiple Stages Every JavaFX program extends javafx.application.Application The main class overrides the start method defined in javafx.application.Application and JVM constructs an instance of the class and invoke the start method. The first Scene object is created using the constructor – specifies width and height and places button in scene The first Stage object is automatically created by JVM when the app is launched Name the first Stage, set the scene in the stage, and display the stage. A new stage is created. Name the second Stage, set the scene in the stage, places button in Scene, and display the stage. The launches JavaFX app. Identical main method for all every JavaFX app. Output of program displays multiple stages Dr. Clincy - Lecture

JavaFX Program w/Stage within Stage Every JavaFX program extends javafx.application.Application The main class overrides the start method defined in javafx.application.Application and JVM constructs an instance of the class and invoke the start method. The first Scene object is created using the constructor – specifies width and height and places button in scene (200 and 250) Name the second Stage, set the scene in the stage, places button in Scene, and display the stage. The second Scene object is created using the constructor – specifies width and height and places button in scene (100 and 100) Output of program displays overlapping stages Dr. Clincy - Lecture

JavaFX Program w/Button in Pane For Pane Create a Pane Add button to created Pane Add Pane to Scene Name the Stage, set the scene in the stage, and display the stage. Output of program displays a button in the center of the pane Lines 11 and 12 could be replaced with: StackPane pane = new StackPane (new Button(“OK”)); Dr. Clincy - Lecture

JavaFX Program w/Circle in Pane For Circle and Color Create a Circle Set Circle properties Set Circle’s center at (100,100) Measurements are in pixels The color of the circle The color of the circle’s fill Create Pane and add Circle Add Pane to Scene Output of program displays a circle in the center of the scene Dr. Clincy - Lecture

Positioning a Shape Java’s Approach Conventional Approach Dr. Clincy - Lecture

Cover Lab 9 Dr. Clincy - Lecture