What's new in Java 8 (Part I – JavaFX)
Join the DZone community and get the full member experience.Join For Free
disclaimer: i do not work for oracle or represent oracle in any way. this list of features is not official. this is just part of my research as an “outsider”.
java 8 has become feature complete about two months ago and the developer preview is just around the corner (in a couple week’s time). this blog post will detail what’s coming in this next major release with an emphasis on javafx 8, which is the ui library. javafx release number is now on par with the java release, that’s why it has jumped from 2.2 to 8.
this is part i of a three part series of posts. this first part will focus on what oracle has officially been telling developers that should come out in javafx 8, the second part will be mostly speculative, and listing what i think might come out and is not officially being reported. and the final part focuses on the rest that’s coming to java 8, excluding the ui library (e.g., new language features and such).
the original schedule aimed to ship the release in early september 2013, but due to the recent focus on browser-related security issues that date was not achieved. the new schedule is as follows:
- 2013/06/13 – feature complete
all features have been implemented and integrated into the master forest, together with unit tests.
- 2013/09/05 – developer preview
a reasonably stable build suitable for broad testing by the developer community is published. this build will include all planned features unless otherwise stated.
- 2014/01/23 – final release candidate
the date by which the final release candidate must be declared and submitted for testing. one or more release candidates will be declared after the planned zbb date; if another is necessary after this milestone then the general availability date will be at risk.
- 2014/03/18 – general availability
final release, ready for production use.
to this let me add that i’ve been developing java based apps under java 8 for more than a month now and consider it to be quite stable. i’m also not using any of the features under development (like 3d graphics for example), so i can’t say anything for that part.
you can already get an early access release of jdk8 here: http://jdk8.java.net/download.html
the following list will focus especially on the most relevant upcoming features. the list of all coming new features and changes to existing ones is particularly big in this release and it could be that some relevant ones might have escaped my attention and may not me mentioned.
rich text support
this will allow you to:
- style individual words;
- apply effects to words
- apply transforms
- embed nodes inside text
- support bidi text, that is text containing text in both text directionalities, both right-to-left (rtl) and left-to-right (ltr)
- create text that can be individually styled via css
for more details visit this links:
- rich text api details:
- samples and code snippets: https://wikis.oracle.com/display/openjdk/rich+text+api+samples
swing node will allow you to embed swing components inside a javafx scene. support for the opposite, that is, embedding a javafx scene inside a swing app is already possible via jfxpanel.
for the api specification and a simple example visit: http://download.java.net/jdk8/jfxdocs/javafx/embed/swing/swingnode.html
changes to the controls api
several changes will occur to the controls api, this is especially important to third party control providers:
- skin class which will become public;
skinbase class will become public, but behavior class and subclasses are still private implementation, there is still some work to be done here after javafx 8.
- new css api which will allow you to define custom properties for your controls and custom pseudo-classes – additional details can be found in: https://wiki.openjdk.java.net/display/openjfx/css+api+to+support+custom+ui+controls
video and audio recording
support for video and audio recording will be added.
you can watch this video presentation for more details (jump to minute 39 to see an example app in action): http://www.youtube.com/watch?v=japubzfjx2a
printing support will be added to javafx. you can check this detailed blog post by carl dea for more details: http://carlfx.wordpress.com/2013/07/15/introduction-by-example-javafx-8-printing/
new looks with a new theme called modena
the looks have been significantly improved with a new theme called modena. this time a lot developer feedback was taken into account making for a very nice end result.
more details can be found here:
new datepicker and treetable controls
javafx 8 will have a datepicker and a treetable control:
user experience documentation: http://openjdk.java.net/projects/openjfx/ux/datepicker/
actual datepicker screenshot:
user experience documentation:
the following enhancements were added to webview:
more information on:
- websocket – http://javafx-jira.kenai.com/browse/rt-14947
- web workers – http://javafx-jira.kenai.com/browse/rt-9782
javafx will be included in oracle’s java se embedded 8. it will include a subset of features of the desktop version, namely it will not include:
- webview support
- media support
workaround for media:
for media there is a workaround however, as this comment in fxexperience from jasper potts explains:
“there is no javafx media support on pi, we prototyped passing
hardware decoded frames of video into opengl so that it could be drawn
in javafx scene but performance was not great. so what we do is draw
javafx with a transparent background just like a transparent window on
desktop. then use the native omx media player to play video to a lower
layer under the javafx graphics. so basically standard hardware overlay
graphics. this works great on pi and there is only about a 10% drop in
javafx performance when playing a hd video stream underneath. so simple
animations we can get 50+ fps with video at same time.”
improved 3d support
improved 3d support will be available in this release. or it’s probably more accurate to say: true 3d support.
it is an optional feature, you can query the runtime to know whether it is available for the given platform. when javafx runs with software rendering this 3d features will not be available.
· movable cameras and subscene
- camera is now a node
camera can be added to a scenegraph, its position and aim (or orientation) is set using standard transforms.
- addition of subscene
subscene is a special node that can be used to render part of a scene with a different camera.
· 3d primitives
added two type of 3d shapes, extending from an abstract shape3d base class:
- user-defined shapes (meshview)
- predefined shapes
three commonly used predefined 3d shapes are introduced: box, cylinder and sphere.
shape3d class hierarchy:
- javafx.scene.shape.shape3d (abstract)
mesh class hierarchy:
- javafx.scene.shape.mesh (abstract)
· 3d attributes
- added lights and 3d materials to add realism for 3d shapes.
material specifies the appearance of a 3d shape. light interacts with the geometry of a shape3d and its material to provide the rendering result.
a shape 3d can be rendered either as a filled shape or as a wireframe.
- light is defined as a node in the scene graph
- there are 2 types of light sources:
ambientlight : a light source that affects all objects equally. ambientlight objects model the light reflected from other visual objects. if you look up at the underside of your desk, you will see the bottom surface of the desk although no light source is directly shining on that surface (unless you have a lamp under your desk). the light shining up on the bottom surface of the desk reflected off the floor and other objects. in natural environments with many objects, light reflects off many objects to provide ambient light. the ambientlight class simulates this effect.
pointlight : a light source with a position. the distance and direction to a given object affects how this lights up the object. pointlight objects approximate bare light bulbs, candles, or other light sources without reflectors or lenses.
may add more types of lights in the future (example: spot light, a light that simulates light sources such as flash lights).
- a scene contains a set of active lights
a default light is provided when the set of active light is empty
- each light contains a set of affected nodes
if a parent is in the set, all its children are affected. the default is the root node of the scene.
- material contains a set of rendering properties
phongmaterial is a concrete subclass of material. it has the following properties:
- ambient color
- diffuse color, diffuse map
- specular color, specular map
- specular power
- bump map
- self-illumination map
· methods added to node
- a lod helper method that returns the area of the node projected onto the physical screen in pixel units:
public double computeareainscreen()
lod stands for level of detail. it is technique that changes the appearance of an object depending on how close or distant to the camera it is, or in other words the level of detail is changed according to the area occupied by the object if the object is far then the detail can be lowered without the user noticing it, and thus improving performance.
- a new set of methods that transform 3d points
· loader support
many 3d file formats exist, such as: obj, maya, 3d studio max, collada, krml. there will be no official 3d file format loaders shipping with the api. oracle however will provide sample code for one or two popular formats. at least a collada file loader is in the works.
- oracle showed a cool proof of concept last javaone. it was built on an early javafx prototype with added 3d mesh, camera and lighting support. also a simple 3d example (with code) is showed in this blog post: http://fxexperience.com/2013/02/javafx-3d-early-access-available/
- another very neat sample app showed at last year javaone: http://www.youtube.com/watch?v=zfk0kpmptom
- a presentation by chien yang and kevin rushforth from oracle showed the state of art of the 3d javafx apis. it’s a bit old so some things might have changed: http://www.youtube.com/watch?v=ebkhdv-_ric
- another presentation from oracle that was done more recently (march 27, 2013), – introduction to javafx 3d (sound quality and image quality is not so good). again, some things might have changed (presentation starts at 43:18): http://www.youtube.com/watch?v=1ebmy-jaygg&list=uumrtpmgnq04cmupsuqpfhxq&index=1#
other minor features, tweaks and changes
builders are deprecated
builders are now deprecated in this release. in java 9 they will be removed (this is several years down the road). you should start planning to replace builders if you are using them.
due to an implementation detail, builders would stop working in java 8 unless some binary incompatibilities were introduced. because of that the decision was to phase out the builders, the changes that were required would reduce the value of the builders to the point where they just wouldn’t be worth it, and when considering mobile / embedded use cases, the extra cost of the builders would be prohibitive. ( http://mail.openjdk.java.net/pipermail/openjfx-dev/2013-march/006725.html )
javafx thread and swing will merge
javafx thread and swing can be merged, this is still an experimental api and will not be public, and you’ll have to turn it on explicitly. if you are developing a hybrid swing/javafx app this will simplify the code since you only have to worry about one ui thread.
you can read more about this in this blog post:
javafx fully open sourced
javafx has just recently become fully open sourced . this is great news since it will allow third parties and developers to extend the functionality of javafx more easily and thoroughly. also good for debugging errors, and other things.
javafx on the default classpath
this has been a recurring request from developers, javafx classes are now on the default runtime classpath for an oracle java implementation.
Published at DZone with permission of Pedro Duque Vieira, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.