In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about how to create a framework for Java rich client platform JavaFX. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
In the future, JavaFX hopes to have general abstract capabilities in rendering, whether it is for Java 2D/OpenGL/Hospot VM framework or Javascript/HTML5/Web browser framework, it can be implemented using the same API.
JavaFX originally had two main components: JavaFX scripting and JavaFX Mobility. The core of JavaFX is JavaFX scripting, which is a declarative scripting language. It maintains a high degree of interaction with the Java class. JavaFX Mobile (JavaFX Mobile) is a platform for developing Java applications for mobile devices. However, Oracle later announced that the JavaFX script had been discarded and replaced by a new Java API for building JavaFX applications, and of course, it was possible to choose a replacement from languages like JRuby,Clojure,Scala and Groovy. While I was hesitant to shift the focus of my study to JavaFX, the prospect of JavaFX in 2011 gave me a boost and made me make up my mind to learn some JavaFX2.0.
What is JavaFX?
The JavaFX platform is the evolution of the Java client platform, which is used to help program developers quickly create and deploy rich client applications and achieve cross-platform consistency. The JavaFX platform is based on Java technology and provides a series of charts and multimedia API to simplify the development of data-driven enterprise client applications.
For Java developers, the JavaFX platform has the following advantages:
1. Because the JavaFX platform is written in the Java language, Java developers can make full use of their existing skills and tools to develop JavaFX applications.
2. Because Java is widely used, experienced Java developers can develop JavaFX applications quickly and efficiently.
3. By using Java technology on the server and client platform, the JavaFX platform reduces the investment risk by reducing the complexity of the business solution.
4. Based on the above advantages, the development cost has also been reduced.
5. JavaFX platform provides a development framework and runtime environment for developers to create enterprise business applications and support Java to achieve cross-platform.
Second, the current development of JavaFX: JavaFX 2.0 release
At the JavaOne 2011 conference, Oracle announced the release of JavaFX 2.0 on the Windows platform as well as a developer preview version of JavaFX 2.0 on the Mac OS X platform.
JavaFX 2.0 is a major upgrade of JavaFX, designed for the next generation of UI platforms, providing powerful Java-based UI design capabilities that can handle large-scale data-driven business logic. JavaFX 2.0 contains a wealth of UI controls, graphics and multimedia features, can be used to simplify the development of visual applications, the new WebView can be directly embedded in the application web pages; another version 2.0 allows the use of FXML for UI definition, which is a scripted XML-based markup language.
JavaTM SE 7 Update 2 includes a new JVM to improve reliability and performance, supporting Oracle Solaris 11 and Firefox 5 and later. Java SE includes JavaFX,Java JDK, including JavaFX SDK, as well as the JavaFX runtime environment.
The developer preview version of JavaFX 2.1, available for download on the Windows platform earlier this month, includes new diagrams and composite box controls.
Third, how to create an application framework
JavaFX applications all have a similar framework. The Main () function calls the Launch () function, and the Start () method is used to set the UI design of the application.
How to use NetBeans 7.1to create a JavaFX project
1. Download and install JavaFX 2.0 SDK. The default path for my installation files is C:\ Program Files\ Oracle\ JavaFX 2.0 SDK, C:\ Program Files\ Oracle\ JavaFX Runtime 2.0.
Although JavaFX applications can be run from the command line, I'm going to use NetBeans to build my applications. NetBeans 7.1 beta supports JavaFX 2.0, while JavaFX 2.0 SDK needs to be downloaded separately.
I downloaded all versions of NetBeans 7.1 beta, because both Java SE and JavaFX support Groovy, Java EE, PHP, and Cmax Clipper + to create desktop, Web, and mobile applications. Current NetBeans IDE supports Windows, Mac, Linux, and Oracle Solaris platforms. It supports the rules and standards in the Java platform. Moreover, NetBeans IDE 7.1 Beta supports JavaFX 2.0 in addition to the Java standard, and JavaFX 2.0 applications can be fully compiled, debugged, and monitored.
2. A new JavaFX project is created in NetBeans 7.1. There are two ways to create a project.
"CTRL+SHIFT+N"
Right-click the "projects" tab and select "New Project"
Note: * activation is required when creating a JavaFX project in a newly installed version of NetBeans 7.1beta.
3. Once you click the "finish" button to create the JavaFX project, three files will be generated. These files include HelloJavaFX.java, Sample.java, and Sample.fxml.
After clicking the build button on the project, you can see what kind of file NetBeans 7.1beta generates.
In the 'dist' directory, you can use the JAR and JNLP files to generate the HTML file.
How to use the built-in layout panel
JavaFX applications support manual UI layout settings, you can set the appropriate location and size attributes for each UI element, and the easiest way is to make full use of the layout panel. JavaFX SDK provides several layout container classes called panels to easily create and manage classic layouts such as rows, columns, stacks, and so on. As an adjusted window, the layout panel can flexibly and automatically adjust the position and size according to the properties of the node.
The layout panel provided with JavaFX is as follows:
1 、 BorderPane
The BorderPane layout panel provides five areas for placing nodes: up and down, left and right. Figure 1-1 shows the layout type, which can be used to create border panels and can be flexibly resized.
The border panel can be used to create the top classic sidebar, the bottom status bar, the left navigation bar panel, the right extra information, and the middle workspace.
The following code shows how to create a polygon border panel in each area
Example 1-1 Create a BorderPane BorderPane layout = new BorderPane (); layout.setTop (new Rectangle (200,50, Color.DARKCYAN)); layout.setBottom (new Rectangle (200,50, Color.DARKCYAN)); layout.setCenter (new Rectangle (100,100, Color.MEDIUMAQUAMARINE)); layout.setLeft (new Rectangle (50,100, Color.DARKTURQUOISE)); layout.setRight (new Rectangle (50,100, Color.DARKTURQUOISE))
2 、 Hbox
The Hbox layout panel provides an easy way to adjust nodes in a single row.
The Padding property can be used to set the spacing between the node and the Hbox panel. The Spacing attribute can be used to manage the distance between nodes. You can adjust the background color to adjust the style.
The following example uses the Hbox panel to create a sidebar with two buttons
Example 1-2 Create an HBox Pane HBox hbox = new HBox (); hbox.setPadding (new Insets (15,12,15,12); hbox.setSpacing (10); hbox.setStyle ("- fx-background-color: # 336699"); Button buttonCurrent = new Button ("Current"); buttonCurrent.setPrefSize (100,20); Button buttonProjected = new Button ("Projected"); buttonProjected.setPrefSize (100,20); hbox.getChildren (). AddAll (buttonCurrent, buttonProjected); BorderPane border = new BorderPane () Border.setTop (hbox)
3 、 VBox
The VBox layout panel is similar to the Hbox layout panel. The Padding attribute can be used to adjust the spacing between the node and the edge of the VBox panel. The Spacing property is used to adjust the spacing between nodes.
Example 1-3 Create a VBox Pane VBox vbox = new VBox (); vbox.setPadding (new Insets (10,10,10,10)); vbox.setSpacing (10); Text title = new Text ("Data"); title.setFont (Font.font ("Amble CN", FontWeight.BOLD, 14)); vbox.getChildren (). Add (title) Text options [] = new Text [] {new Text ("Sales"), new Text ("Marketing"), new Text ("Distribution"), new Text ("Costs")}; for (int iTuno; I
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.