CMPE212 – Stuff… Assignment 4 due March 23 – this Friday.

Slides:



Advertisements
Similar presentations
CSS Layout Crash Course An Advance CSS Tutorial. Inline vs. Block Many HTML elements have a default display setting of Block. Block elements take up the.
Advertisements

Quiz #3 - CSS Lecture Code: Get Neighbors’ URLs for MP1
UNIT 12 LO4 BE ABLE TO CREATE WEBSITES Cambridge Technicals.
Web Design with Cascading Style Sheet Lan Vu. Overview Introduction to CSS Designing CSS Using Visual Studio to create CSS Using template for web design.
MORE Cascading Style Sheets (The Positioning Model)
Written by Liron Blecher
SWING IF YOU GET LOST - IMPORTANT LINKS  Swing articles:
Topics Introduction Scene Graphs
Understanding CSS Cascading Style Sheets control the presentation of content in HTML pages Style Sheets separate formatting from the content –Styles defined.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 next week. See next slide. Both versions of assignment 3 are posted. Due today.
Notices Assn 3 is posted – due tomorrow. Quiz marking underway (still – sigh…). Alternate solution code was added on Tuesday to the assignment 3 statement.
Today Javadoc. Packages and static import. Viewing API source code. Upcoming Topics: –protected access modifier –Using the debugger in Eclipse –JUnit testing.
Lecture 7:Introduction to JavaFX Michael Hsu CSULA.
Notices Assn 4 posted. Due last day of class. Last quiz this week in Moodle, in the lab. Would the student doing the USATS please get them from Emily Crawford.
Laying out Elements with CSS
Java FX: Scene Builder.
Cascading Style Sheets Boxes
Creating Oracle Business Intelligence Interactive Dashboards
CSS Layouts: Positioning and Navbars
CSS Layouts: Grouping Elements
3.01 Apply Controls Associated With Visual Studio Form
3.01 Apply Controls Associated With Visual Studio Form
CISC124 Quiz 2 grading underway.
CMPE212 – Stuff… Assn 2 due next Friday. Winter 2018
CSS Applications to XML 19-Sep-18.
IS333: MULTI-TIER APPLICATION DEVELOPMENT
CMPE212 – Stuff… Assn 3 due and Quiz 2 in the lab next week.
Winter 2018 CMPE212 9/21/2018 CMPE212 – Stuff…
CMPE212 – Stuff… Exercises 4, 5 and 6 are all fair game now.
Chapter 14 JavaFX Basics Dr. Clincy - Lecture.
CMPE212 – Stuff… Assn 3 sample solution is posted.
Winter 2018 CMPE212 11/12/2018 CMPE212 – Stuff…
Styles and the Box Model
Controlling Layout with Style Sheets
Second CSS Lecture Applications to XML
MORE Cascading Style Sheets (The Positioning Model)
CISC124 Assignment 4 on Inheritance due next Monday, the 12th at 7pm.
CISC124 Last Quiz this week. Topics listed in last Tuesday’s lecture.
CISC124 Last Quiz this week. Topics listed in last Tuesday’s lecture.
CISC124 Last Quiz this week. Topics listed in last Tuesday’s lecture.
Fall 2018 CISC124 12/1/2018 CISC124 Note that the next assignment, on encapsulation, is due next Wednesday at 7pm – not Friday. The next Quiz is not until.
CISC101 Reminders Assn 3 due tomorrow, 7pm.
CISC124 Last Quiz next week. Topics listed in Tuesday’s lecture.
CISC124 Assignment 4 on Inheritance due today at 7pm.
CISC124 Assignment 4 on Inheritance due next Friday.
CISC124 Assignment 3 due tomorrow at 7pm.
CISC124 Assignment 4 on Inheritance due next Friday.
CISC124 Quiz 3 marking underway. Assn 5 due Friday. Fall 2018
More CSS 22-Feb-19.
Floating and Positioning
Using Templates and Library Items
Fall 2018 CISC124 2/24/2019 CISC124 Quiz 1 marking is complete. Quiz average was about 40/60 or 67%. TAs are still grading assn 1. Assn 2 due this Friday,
CISC124 Assignment 3 sample solution will be posted tonight after 7pm.
CMPE212 – Reminders Assignment 2 sample solution is posted.
CMPE212 – Reminders Assignment 3 due next Friday.
Winter 2019 CMPE212 4/20/2019 CMPE212 – Reminders
CMPE212 – Reminders Quiz 1 marking done. Assignment 2 due next Friday.
Winter 2019 CMPE212 5/3/2019 CMPE212 – Reminders
CSS Boxes CS 1150 Fall 2016.
CMPE212 – Reminders Assignment 2 due today, 7pm.
Winter 2019 CMPE212 5/25/2019 CMPE212 – Reminders
CSS Applications to XML 20-May-19.
CISC101 Reminders Assignment 3 due today.
CMPE212 – Reminders Assignment 5, a JavaFX GUI, due this Friday.
CMPE212 – Reminders Assignment 5, a JavaFX GUI, due next Friday.
CSc 337 Lecture 5: Grid layout.
CMPE212 – Reminders Assignment 2 due next Friday.
CMPE212 – Reminders Assignment 4 on Inheritance due next Friday.
CSS Applications to XML 3-Jul-19.
Presentation transcript:

CMPE212 – Stuff… Assignment 4 due March 23 – this Friday. Winter 2018 CMPE212 12/3/2018 CMPE212 – Stuff… Assignment 4 due March 23 – this Friday. Next (and last) quiz next week. See next slide. Winter 2018 CMPE212 - Prof. McLeod Prof. Alan McLeod

Quiz 3 Topics Main new topics from last quiz are: ArrayList<T> Collection Type. Generics: Generic Classes & Methods, Use of Wildcards. The Class<T> Object. Lambda Functions. Method References. GUI Design. How JavaFX works. JavaFX Containers and Layout Manager Algorithms. And older topics such as writing methods, loops, conditionals, arrays, encapsulation and inheritance are still fair game. Winter 2018 CISC124 - Prof. McLeod

Quiz 3, Cont. When writing code in Quiz 3, you may have difficulty getting < > to display properly. The text box may try to treat these as html tags. Code after the <, may not display at all! It is OK to use [ ] instead for < >, when typing code in a text box. So, “ArrayList<T>” can be written as “ArrayList[T]” instead. Winter 2018 CMPE212 - Prof. McLeod

Today Continue: Intro to JavaFX. Start looking at Panes and Layout Managers. Winter 2018 CMPE212 - Prof. McLeod

New JavaFX Project Wizard, Cont. An item (layouts, controls, images, etc.) is called a “node”. Nodes are added to the Nodes hierarchy (next, next slide), and the root node of this hierarchy is added to the Scene object when it is instantiated (and it is given a size in pixels). The Scene object is then put on the stage using the .setScene() mutator. When the scene is all constructed the “curtains are raised” by invoking .show() on the stage object. Winter 2018 CMPE212 - Prof. McLeod

New JavaFX Project Wizard, Cont. The wizard also adds a link to a CSS (“Cascading Style Sheet”) file for the scene, called “application.css”. Initially the file is empty, but you can “skin” the scene using css style specifications for the window and any controls you are using. You can do all this in your GUI class too, but using the css file allows you to separate style code from application code. We’ll look into doing this a bit later. For now we’ll just use the default style (“Modena”). Winter 2018 CMPE212 - Prof. McLeod

JavaFX Scene Graph Here is part of the existing Node hierarchy: Node Parent Region Control Pane Labeled Winter 2018 CMPE212 - Prof. McLeod

JavaFX Scene Graph, Cont. Left-hand branch are containers – used to contain and organize other controls. Right-hand branch are the controls. Usually a container type object will be the “root”. Winter 2018 CMPE212 - Prof. McLeod

JavaFX Scene Graph, Cont. There are many more classes extending nodes in this hierarchy. For example, some classes extending from Labeled: Labeled ButtonBase Label Button CheckBox ToggleButton See the JavaFX API Tree diagrams for all the classes. RadioButton Winter 2018 CMPE212 - Prof. McLeod

Aside - JavaFX API Docs These used to be a separate from the regular Java API docs, but are now part of the “whole”. Winter 2018 CMPE212 - Prof. McLeod

JavaFX Scene Graph, Cont. Typically you build your GUI by first instantiating existing node objects. For example, Label myLabel = new Label(“Hello!”); In order to display the node in the window, you need to add the object you instantiated to the existing Scene Graph structure. Winter 2018 CMPE212 - Prof. McLeod

JavaFX Scene Graph, Cont. In order to be able to place your nodes (or “controls”) where you want them, you add them to a Pane object. A Pane child object includes a layout manager that decides where nodes can be placed. A Pane object can be added to different type Pane objects as if it was a node itself to give you a great deal of flexibility in your layout. Finally, the root pane object becomes the root of the scene object and the entire Scene Graph that you have constructed can be displayed. Winter 2018 CMPE212 - Prof. McLeod

Aside – Generating Import Statements Eclipse is great at helping you generate a missing import statement if you try to use a class that you have not yet imported. But: if you have a choice, make sure to choose the javafx one, rather than the class from javax.swing or java.awt. Winter 2018 CMPE212 - Prof. McLeod

Pane Objects In order to design your window you need to understand how the different Pane objects work. From the JavaFX API Tree: Winter 2018 CMPE212 - Prof. McLeod

Pane Objects, Cont. Won’t discuss: DialogPane – Used as the base container for customized dialog windows. We can just use the built-in dialogs. We don’t need to design our own. PopupControl.CSSBridge – Seems to be mostly for internal use. Winter 2018 CISC124 - Prof. McLeod

Aside – Layout Managers Each pane is associated with a different layout manager – an algorithm that determines where controls are placed within the pane and often their size. Provides flexibility during design and during runtime when the size of the window is changed or the window is viewed on a different OS (or even just a different monitor resolution!) than the one on which it was designed. Winter 2018 CISC124 - Prof. McLeod

Layout Managers – A Reference A Nice Reference – “Working with Layouts in JavaFX”: http://docs.oracle.com/javafx/2/layout/jfxpub-layout.htm Winter 2018 CISC124 - Prof. McLeod

Aside – Absolute Positioning Used by Microsoft’s Visual Studio .NET, for example. Control positions and sizes (in pixels) are all absolute. The visual editor helps you assign default values and to line up controls. But .NET is designed to run on one OS only… You can still use absolute positioning in JavaFX, but you are giving away some convenience. Winter 2018 CISC124 - Prof. McLeod

BorderPane BorderPane lays out components in top, left, right, bottom, and center positions: Winter 2018 CISC124 - Prof. McLeod

BorderPane, Cont. For example, to add a Button to the Top position: BorderPane bPane = new BorderPane(); Button myButton = new Button(“Click Me!”); bPane.setTop(myButton); A component adopts its preferred size if it is smaller than the available region. Center swells to occupy neighbouring positions if they are empty. Winter 2018 CISC124 - Prof. McLeod

BorderPane, Cont. You can add margins around a component by using an Insets object with the static .setMargin() method. You can also specify alignment within a position using a value from the Pos enum and the static .setAlignment() method. This layout is good for blocking out an entire window into sub-regions and then you use another layout in the regions of interest. Winter 2018 CISC124 - Prof. McLeod

BorderPane, Cont. See FXProjectBorderPane Test control positioning, alignment and sizing. Setting individual control properties one at a time will be painful, especially when the properties are all being set to the same value… Winter 2018 CISC124 - Prof. McLeod

Aside – Running JavaFX Lecture Notes Code Create a blank JavaFX project. Remove any files in the application folder. In a file browser, unzip the archive (*.zip) file to the application folder of the project. At the moment this is just Main.java and some also have application.css. Back in eclipse, use <F5> to refresh the project listing. Winter 2018 CISC124 - Prof. McLeod

Aside - Component Sizing Padding Border Margin Unless you define a preferred size the calculated size is based on the size of the rendered label plus a default padding size between the label and the border. You can also change the size of the margin in code. Winter 2018 CISC124 - Prof. McLeod

AnchorPane Components are anchored at a specified distance from the edge of the Pane using the static methods: “value” is in pixels as a distance from the border of the pane. Why a double? Winter 2018 CISC124 - Prof. McLeod

AnchorPane, Cont. See FXProjectAnchorPane. Here is the interesting part: AnchorPane root = new AnchorPane(); Button leftTopButton = new Button("Left Top"); leftTopButton.setFont(new Font("Consolas", 20)); Button rightBottomButton = new Button("Right Bottom"); rightBottomButton.setFont(new Font("System", 18)); Label leftBottomLabel = new Label("Left Bottom"); leftBottomLabel.setFont(new Font("Times New Roman", 22)); AnchorPane.setLeftAnchor(leftTopButton, 10.0); AnchorPane.setTopAnchor(leftTopButton, 10.0); AnchorPane.setRightAnchor(rightBottomButton, 10.0); AnchorPane.setTopAnchor(rightBottomButton, 10.0); AnchorPane.setBottomAnchor(rightBottomButton, 10.0); AnchorPane.setLeftAnchor(leftBottomLabel, 80.0); AnchorPane.setBottomAnchor(leftBottomLabel, 80.0); root.getChildren().addAll(leftTopButton, leftBottomLabel, rightBottomButton);

AnchorPane, Cont. Note the effect of window re-sizing. Note how two or more anchors can combine to change the size of the control away from its calculated/preferred size. This is another relatively crude layout manager that might be best used to lay panes out in a window. Winter 2018 CISC124 - Prof. McLeod

Aside – Pane “Children” Nodes added to a pane are also called “Children”. Add nodes to a pane by invoking the .add() or .addAll() methods on the children collection owned by the pane. The .addAll() method can also accept a Collection<? extends Node> object. The .getChildren() method of the pane object “exposes” its children collection. Winter 2018 CISC124 - Prof. McLeod

FlowPane Piles children into the pane in the order in which they are added from left to right (by default). The children wrap around if the available space is full. See FXProjectFlowPane. See what happens when you re-size the window. Play with gaps, padding, default sizes and alignment. Note the use of an ArrayList<Button> to hold buttons. Why are some buttons larger than others? Winter 2018 CISC124 - Prof. McLeod