Date post: | 15-Jan-2015 |
Category: |
Technology |
Upload: | stephen-chin |
View: | 6,992 times |
Download: | 0 times |
1 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
2 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
O Retorno do Rich-Client Java
Apresentado por Stephen ChinTranslation By:Marcelo Quinta @mrquinta
3 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Sobre o palestrante: Stephen Chin
• Evangelista Java/JavaFX na Oracle
• Autor de vários livros de Java, mais recentemente o Pro JavaFX 2
• Blog: steveonjava.com
• Twitter: @steveonjava
4 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
5 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Recursos da apresentação
• Visite ProJavaFX2.com para baixar o capítulo 1 e todos os exemplos
• Site do JavaFX: oracle.com/javafx
• Site do NetBeans: netbeans.org
• Blog fxexperience: fxexperience.com
• Blog do Jim Weaver sobre JavaFX: JavaFXpert.com
• Meu blog de JavaFX: steveonjava.com
6 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
O que eu quero que vocês percebam
1. A JRE com JavaFX permite a execução de aplicações graficamente ricas e com ótima performance
2. Desenvolver apps em JavaFX é natural e divertido
3. Existem ótimos recursos para ajudá-lo a começar com JavaFX
4. Você deve começar a brincar com JavaFX agora!
7 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
1. Introdução ao JavaFX
• Trazendo de volta o rich-client Java
• Entendendo a história do JavaFX
• Obtendo ferramentas e recursos do JavaFX
• Desenvolvendo e rodando o Hello EarthRise
• Revisando a estrutura do Hello EarthRise
8 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Trazendo de volta o rich-client Java
• A web, originalmente projetada para compartilhamento de recursos de hipertexto ligados (ex:HTML) está sendo forçada a se tornar uma plataforma para clientes ricos (rich-client)
• A JRE com JavaFX é uma plataforma de rich-client muito melhor, permitindo a execução de aplicações graficamente ricas e com ótima performance
• Veja a seção JavaFX Can’t Bring Rich-Client Java Back by Itself do capítulo 1
9 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Entendendo a história do JavaFX
• A idéia é de Chris Oliver na SeeBeyond, que foi adquirida pela Sun
• Plataforma e linguagem JavaFX Script anunciada no JavaOne 2007
• Oracle implementou JavaFX 2 como uma API para Java, anunciada no JavaOne 2010
• JavaFX 2.1 GA lançado no JavaOne India 2012– Windows and OS/X now GA, Linux GA soon
• Veja a seção A Brief History of JavaFX no Capítulo 1
10 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Obtendo ferramentas e recursos JavaFX
• Visite oracle.com/javafx e navegue para JavaFX 2.1 SDK. Página de download é:– http://www.oracle.com/technetwork/java/javafx/downloads
• Você também pode fazer download do NetBeans 7.1 nessa página
• Siga as instruções do Set Up NetBeans IDE With JavaFX
• Nota: JDK 7u4 já vem com o SDK do JavaFX 2.1
11 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Construindo e executando o Hello EarthRise
• Siga os passos da seção Building and Running the Program with NetBeans do Capítulo 1
12 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Demo
13 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Revisão da estrutura do Hello Earthrise
• Classe da aplicação e o método sobrescrito start()
• Código declarativo que define a interface do usuário
• Usando a classe Stage
• Usando a classe Scente
• Mostrando imagens
• Veja a seção Understanding the Hello Earthrise Program do capítulo 1
14 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Passo-a-passo no código
15 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
2. Criando uma interface gráfica em JavaFX
• Demo da app MetronomeTransition
• Revisão do código do MetronomeTransition
• Expressando a interface gráfica de maneira declarativa
• Fazendo o binding(ligação) de propriedades no modelo
• Nós de animação
16 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Demo da app MetronomeTransition
• Código do MetronomeTransition está na pasta 8727_ch02code do pacote de download do Pro JavaFX 2 code
17 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Demo
18 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Revisão do código do MetronomeTransition
• Expressando a interface gráfica de maneira declarativa
• Usando classes de layout
• Fazendo o binding(ligação) de propriedades no modelo
• Nós de animação
19 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Passo-a-passo no código
20 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
3. Usando os controles da JavaFX UI
• Demo do exemplo StarterApp
• Examinando o código do StarterApp
• Visão geral dos componentes de interação da StarterApp
• Aproveitando os controles de UI em código
• Associando uma folha de estilos CSS ao JavaFX
• Definindo as classes do domínio
21 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Demo do exemplo StarterApp
• Código do StarterApp está na pasta 8727_ch05code do pacote de download do Pro JavaFX 2 code
22 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Demo
23 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Examinando o código StarterApp
• Visão geral dos componentes de interação da StarterApp
• Aproveitando os controles de UI em código
• Associando uma folha de estilos CSS ao JavaFX
• Definindo as classes do domínio
24 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Passo-a-passo no código
25 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
4. Usando as classes de Mídia
• Demo da app VideoPlayer1
• Examinando o código do VideoPlayer1
• Usando MediaView, MediaPlayer e classes de Mídia
• Programação procedural vs. abordagem declarativa
26 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Demo do VideoPlayer1
• Código do VideoPlayer1 está na pasta 8727_ch08code do pacote de download do Pro JavaFX 2 code
27 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Passo-a-passo no código
28 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Examinando o código do VideoPlayer1
• Usando MediaView, MediaPlayer e classes de Mídia
• Programação procedural vs. abordagem declarativa
29 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Passo-a-passo no código
30 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
5. Usando FXML
• Demo da app AdoptionForm
• Examinando a arquitetura do AdoptionForm
• Ferramenta Scene Builder gera FXML
31 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
The AdoptionForm example app
32 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Demo
33 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
6. Implantando apps JavaFX
• Algumas opções são Java WebStart e rodar como um applet– ex. Ícone em uma página conhecida que invoca o TweetBrowser
no Java WebStart
• Outra boa opção de implantação é chamar um instalador– “Não há aplicação que faça isso”– Veja o post relacionado no FXexperience.com
34 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
7. Embutindo HTML5
• Ver a API WebView
• Demonstrar o exemplo Java Conference Tour
• Examinar a arquitetura do Java Conference Tour
35 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Mostrando HTML no JavaFX
public class WebViewTest extends Application {
public static void main(String[] args) {
launch(WebViewTest.class, args);
}
@Override public void start(Stage stage) {
WebView webView = new WebView();
webView.getEngine().load("http://google.com");
Scene scene = new Scene(webView);
stage.setScene(scene);
stage.setTitle("Web Test");
stage.show();
}}
36 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Mostrando HTMLno JavaFX
37 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Chamando Javascript no JavaFX
String script = "alert('We have got a message, Houston!');”;
eng.executeScript(script);
38 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Conversão de tipos JavaScript para Java
JavaScript Javanull nullundefined “undefined”number java.lang.Number (Integer ou Double)string java.lang.Stringboolean java.lang.Booleanobject netscape.javascript.JSObject
39 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Respondendo a eventos de Browser
• Alert/Confirm/Prompt – Responder para funções de interação JavaScript
• Redimensionamento – Página web se move ou redimensiona a janela
• Status – Página muda o texto de status
• Visibilidade – Esconder ou mostrar a janela
• Popup – Gerar uma segunda tela/engine
40 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
A app Java Conference Tour
41 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Demo
42 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
O que vimos nessa apresentação
1. A JRE com JavaFX permite a execução de aplicações graficamente ricas e com ótima performance
2. Desenvolver apps em JavaFX é natural e divertido
3. Existem ótimos recursos para ajudá-lo a começar com JavaFX
4. Você deve começar a brincar com JavaFX agora!
43 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8
Perguntas e Respostas
44 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Insert Information Protection Policy Classification from Slide 8