Thursday Feb 28, 2013

Improved support for JavaFX in your favorite Java IDE

On April 3rd, 2013, JetBrains, the company behind IntelliJ IDEA, announced support for JavaFX in IntelliJ IDEA 12.1, the latest version of their Java Integrated Development Environment (IDE). Support for JavaFX includes complete support for FXML markup, custom CSS, code completion, navigation and search, refactorings, packaging tools. IntelliJ IDEA 12.1 also adds includes integration with JavaFX Scene Builder, Oracle's visual layout tool for JavaFX.

JavaFX development in IntelliJ IDEA

Coincidentally, the NetBeans team released the GA version of NetBeans IDE 7.3 on February 21st, which features, among other features, improved support for JavaFX Scene Builder,  including improved FXML editing with code completion, and FXML controller generation. An increasing number of Java developers are using NetBeans to create new JavaFX applications, or migrating Swing and NetBeans RCP applications to JavaFX.

FXML code completion in NetBeans IDE

Eclipse users don't need to be jealous; e(fx)clipse provides a great JavaFX tool solution for Eclipse and OSGi, including integration with Eclipse JDT and Eclipse PDE, an FXML editor with code completion, and a JavaFX-proof CSS editor. Note that e(fx)clipse has been proposed as an Eclipse Foundation project.

e(fx)clipse CSS editor

It has never been a better time to develop rich client applications with Java; developers can now leverage even better support for JavaFX development in the leading Java IDEs, including NetBeans, Eclipse, and IntelliJ, as well as a number of specialized tools, utilities, and application frameworks.

To sum it up: get coding!

Friday Aug 17, 2012

What's new in JavaFX 2.2

Earlier this week, Oracle released JavaFX 2.2, which is a significant update release:

  • With version 2.2, JavaFX is finally available on Windows (32-bit & 64-bit), Mac OS X (64-bit), and Linux (32-bit & 64-bit), which means that most developers can build and test JavaFX applications on their preferred development environment. Have a look at the JavaFX Certified System Configurations for more details.

  • The JavaFX 2.2 Runtime is now part of Oracle’s Java SE 7u6 implementation. While we already had some form of integration between these two products since December 2011, , we now have one unified installer, with the JavaFX libraries installed alongside the Java SE libraries for both the JDK and the JRE. This means a more streamlined user experience, and the assurance for application developers that the number of computers capable of running JavaFX applications will soon be as large as for Java SE applications.

  • A stand-alone implementation of JavaFX 2 will remain available for Java SE 6 users, but only on Windows. Additionally, that stand-alone version will no longer be supported when Java SE 6 reaches End of Life (EOL) in February 2013. As explained previously, this means there will no longer be bug fixes or security fixes available for Java SE 6 users after that date, unless you or your customers sign up for our commercial Java SE Support offering. Otherwise, plan your migration to Java SE 7 right now.

 

Besides these important changes, JavaFX 2.2 brings in some key new features:

  • JavaFX applications can now be redistributed as self-contained application packages. These platform-specific packages include all application resources and a private copy of Java and JavaFX Runtimes. Distributed as a native installable package, they provide the same installation and launch experience as native applications for that operating system. A key benefit to take into consideration is that it will allow you to deploy JavaFX 2.2 applications bundled with Java SE 7 without impacting existing deployments of older Java SE implementations.

  • Multi-touch support for touch-enabled devices. As of today this is mostly relevant for desktop-class touch screen displays and touch pads, this will enable the adoption of sophisticated UIs on embedded devices running Java SE Embedded on ARM-based chipsets, such as kiosks, telemetry systems, healthcare devices, multi-function printers, monitoring systems, etc. This is a segment of the Java application market that is usually overseen by most application developers, but that is thriving.

  • The JavaFX Canvas API, a Canvas 2D drawing surface that provides HTML5 Canvas-style operations. Developers familiar with HTML5 will definitely be at ease with the JavaFX Canvas API, although it is important to notice that this is not meant to be a duplicate of the HTML5 Canvas Graphics API. We believe this API will also be welcome by developers with other backgrounds, such as AWT or SVG. You can run a demo of the “Fireworks” canvas demo under the section “NEW!” of the Ensemble sample application, or you can watch the making of another Canvas example on this video.

  • JavaFX 2.2 introduces the ability to read and write pixels to and from JavaFX image objects. An example is available as “Image Operator” in the “NEW!” section of Ensemble.

  • Two new UI controls have been added to JavaFX 2.2: a color picker, and a pagination control; you can give them a try in the “NEW!” section of Ensemble. In addition, the WebView control now provides the ability to manage web history. Finally, we have documented how to create a custom control with FXML, which takes advantage of FXML enhancements.

  • HTTP Live Streaming support is a feature that strengthens up JavaFX’s media support. Essentially, media players are now able to switch to alternate video and audio streams, as specified in a downloadable playlist file and based on network conditions.

  • Additional information to help Swing developers implement a Swing application in JavaFX, and SWT developers to integrate JavaFX content in SWT applications. We also have documented some Best Practices for developing a JavaFX application.

  • Last but not the least, JavaFX developers can now leverage the new JavaFX Scene Builder 1.0 to visually layout an application UI, and generate FXML content that helps keep a clean separation between application logic and UI. Scene Builder is also a great example of a complex application written in JavaFX. It is currently available on Windows and Mac OS X, and is optimized to work seamlessly with NetBeans 7.2 or higher (it can also be used with other Java IDEs).

In summary, JavaFX 2.2 is a key release that brings much more than Linux support. It fulfills Oracle’s vision to integrate JavaFX with Java SE to a large extent, and is a proof of our commitment for cross-platform support and predictable timelines.

 

Tuesday Feb 28, 2012

JavaFX 1.2 and JavaFX 1.3 EOL Announcement

December 21, 2012

Update: JavaFX 1.2 and JavaFX 1.3 Runtime Downloads to Remain Available Until End of March 2013

In order to allow specific companies to finalize the migration of their JavaFX Script-based applications to JavaFX 2, the JavaFX 1.2 and 1.3 Runtime products will remain available until the end of March, 2013, unless the server hosting these downloads is affected by a technical issue.


February 28, 2012

Original  JavaFX 1.2 and JavaFX 1.3 EOL Announcement

Back in September 2010, during the JavaOne conference in San Francisco, Oracle announced they were discontinuing the JavaFX Script language. Oracle also committed to expose all the JavaFX functionality through a Java API, starting with the upcoming JavaFX 2.0 release. As promised, the Windows version of JavaFX 2.0 and the Developer Preview for Mac OS X were released in October 2011; a Developer Preview for Linux was added in January 2012.

Today, we are announcing that JavaFX 1.2 and JavaFX 1.3 will reach end of life (EOL) on December 20, 2012. More specifically, the Oracle server providing access to the JavaFX Runtime for these versions will no longer be available after that date.

Because of the specific deployment architecture used for the JavaFX 1.x product line, this means that users of JavaFX 1.2 or 1.3 applications will no longer be able to download the JavaFX Runtime. Therefore, companies and developers who have JavaFX 1.x applications in use today are strongly encouraged to migrate their applications to the JavaFX 2, which is currently available on Windows, Mac OS X and Linux. Extensive documentation, tutorials, and samples are available on the JavaFX Website, and a growing developer community has started sharing its experience and providing advise on forums, blogs, or social media.

Please refer to the JavaFX website for more information about the current version of JavaFX. You may also discuss specific issues related to this announcement on the JavaFX OTN forum, which we monitor on a regular basis.

Friday Feb 24, 2012

Communicating between JavaScript and JavaFX with WebEngine

Content by Peter Zhelezniakov

JavaFX 2 has introduced the WebEngine and WebView classes to support modern Web standards such as JavaScript, CSS, SVG, and a subset of HTML5.

Besides browsing Web pages, WebEngine can also serve as a container to host Web applications. Running standalone Web applications inside JavaFX is not very exciting though. You can do the same with any browser. What makes it interesting is the fact that the a Web application can communicate with its hosting JavaFX application, enabling a two-way communication channel. This article describes how this channel works in the JavaFX 2.1 Developer Preview.

Invoking JavaScript from JavaFX

The Java application can pass arbitrary scripts to the JavaScript engine of a WebEngine object by calling the WebEngine.executeScript() method:

webEngine.executeScript("history.back()");

The script is executed within the context of the current page. The result of the script invocation is converted to a Java type and returned. For the primitive types, the conversion is straightforward: integer values are converted to Integer, strings to String, etc. Most JavaScript objects are wrapped as instances of the netscape.javascript.JSObject class well-known to LiveConnect developers. Its methods are shown below:

public Object call(String methodName, Object... args);
public Object eval(String s);
public Object getMember(String name);
public void setMember(String name, Object value);
public void removeMember(String name);
public Object getSlot(int index);
public void setSlot(int index, Object value);

So, here is another way to go back one history item in a browser:

JSObject history = (JSObject) webEngine.executeScript("history");
history.call("back");

This example shows an interesting aspect of extending the WebEngine functionality. The WebEngine API, as of writing this, is deliberately limited to just a few methods that are considered critically important. However, the WebEngine class supports the much broader JavaScript API. You can use the executeScript() and JSObject methods to enable this second layer of API and get access to the functionality you miss. So, while there's no a Java method like goBack(), a similar JavaScript method exists and can be invoked as in the above example.

The JSObject methods apply the same conversion rules to the values they return as executeScript(). For example, the following method returns an instance of java.lang.Integer:

history.getMember("length");

A special case is when a JavaScript call returns a DOM Node. In this case, the result is wrapped in an instance of JSObject that also implements org.w3c.dom.Node.

Element p = (Element) webEngine.executeScript("document.getElementById('para')");
p.setAttribute("style", "font-weight: bold");

In this example, the script result is an Element object, and it is wrapped as org.w3c.dom.Element instance.


Making Upcalls from JavaScript to JavaFX

Since we are talking about a two-way communication channel, what about making calls in the opposite direction: from a Web application into JavaFX? On the JavaFX side, you need to create an interface object (of any class) and make it known to JavaScript by calling JSObject.setMember(). Having performed this, you can call public methods from JavaScript and access public fields of that object.

The code below shows how to set up an interface object:

class Bridge {
    public void exit() {
        Platform.exit();
    }
}
...
JSObject jsobj = (JSObject) webEngine.executeScript("window");
jsobj.setMember("java", new Bridge());

First we need a JSObject to attach our interface object to. The above code uses the JavaScript window object but any other object would work as well. Note that a cast is necessary. Then we create an interface object and add it as a new member of that JSObject. It becomes known to JavaScript under the name window.java, or just java, and its only method can be called from JavaScript as java.exit(). The upcall into Java is synchronous and occurs on the JavaFX Application thread. The following HTML code enables exiting the JavaFX application by clicking on a link:

<p>Click
<a href="" onclick="java.exit();">here</a>
to exit the application

Once you no longer need an interface object, you may want to call the JSObject.removeMember() method to make JavaScript "forget" it.

A Note about Security

Please be careful about functionality you open to JavaScript. Remember, there is no sandbox for standalone applications. Methods called by JavaScript on the interface object are invoked directly, as if they were called from your JavaFX code. If your application enables browsing arbitrary Web pages, a malicious script may take advantage of the ability to run Java methods with the user's permissions. So you probably do not want to write

jsobj.setMember("filesys", new File("/"));

as this would let scripts browse about the whole filesystem. By carefully designing the interface object, you can always make sure that only safe functionality is exposed. Another idea is to install and configure a security manager in your application.

Monday Jan 30, 2012

LCD Text support in JavaFX 2.1 Developer Preview

Content provided by Phil Race

LCD sub-pixel text has become a must-have for many Windows desktop users, who have become accustomed to its superior legibility and less blocky appearance at smaller point sizes over hinted black and white text, and being sharper than grey scale anti-aliased text at the same size.

Java SE has supported LCD subpixel text on AWT heavyweights and also on Swing components using Java 2D for many years. However up until now, JavaFX has supported only more Mac OS X-like grey scale smoothed text.

For the JavaFX 2.1 release we've added the ability to use Windows-style LCD sub-pixel rendering. All the JavaFX UI controls will be LCD-text enabled by default on Windows, as will "WebView", the Webkit-based node for rendering Web content.

Applications can also opt-in to use LCD text on the low-level scenegraph "Text" node by a new API :
Text.setFontSmoothingType(FontSmoothingType.LCD));

Here is a fairly representative example of "before" and "after" LCD text on a Windows system:

1. WebView text rendering without LCD text support


2. WebView text rendering with CD text support


Note: make sure both images at being viewed at proper size (1020x700px). Depending on your browser DPI setting, your browser may scale images to fit, and the second image nay bnot display like the original.

Monday Jan 23, 2012

JavaFX 2.0 is Cross Platform!

When we released the JavaFX 2.0 Beta at the end of May, there was an uproar from the Mac and Linux communities complaining that the software was only available on Windows. Developers were very vocal about the fact they would not touch JavaFX until this was remediated. Today, the JavaFX Team is very pleased to announce the availability of the JavaFX 2.1 Developer Preview for Linux, which you can download here.

The JavaFX Developer Preview for Linux has currently been tested against Ubuntu 10.04 / JDK 7u2 but is expected to be supported on other Linux distributions the Oracle Java SE implementation is available on when JavaFX for Linux reaches General Availability.

The quick summary is that it's time for you to code, test, and file bugs and feature requests. We are looking forward to your input to make JavaFX for Linux a rock-solid implementation, as we cannot possibly replicate software and hardware environments that are specific to you.

Happy coding!

About

This blog is maintained by Nicolas Lorain, Java Client Product Manager. The views expressed on this blog are my own & do not necessarily reflect the views of Oracle.

Search

Categories
Archives
« July 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today