44
1 Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8

Return of Rich Client Java - Brazil

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Return of Rich Client Java - Brazil

1 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 8

Page 2: Return of Rich Client Java - Brazil

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

Page 3: Return of Rich Client Java - Brazil

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

[email protected]

Page 4: Return of Rich Client Java - Brazil

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.

Page 5: Return of Rich Client Java - Brazil

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

Page 6: Return of Rich Client Java - Brazil

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!

Page 7: Return of Rich Client Java - Brazil

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

Page 8: Return of Rich Client Java - Brazil

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

Page 9: Return of Rich Client Java - Brazil

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

Page 10: Return of Rich Client Java - Brazil

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

Page 11: Return of Rich Client Java - Brazil

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

Page 12: Return of Rich Client Java - Brazil

12 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 8

Demo

Page 13: Return of Rich Client Java - Brazil

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

Page 14: Return of Rich Client Java - Brazil

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

Page 15: Return of Rich Client Java - Brazil

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

Page 16: Return of Rich Client Java - Brazil

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

Page 17: Return of Rich Client Java - Brazil

17 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 8

Demo

Page 18: Return of Rich Client Java - Brazil

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

Page 19: Return of Rich Client Java - Brazil

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

Page 20: Return of Rich Client Java - Brazil

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

Page 21: Return of Rich Client Java - Brazil

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

Page 22: Return of Rich Client Java - Brazil

22 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 8

Demo

Page 23: Return of Rich Client Java - Brazil

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

Page 24: Return of Rich Client Java - Brazil

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

Page 25: Return of Rich Client Java - Brazil

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

Page 26: Return of Rich Client Java - Brazil

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

Page 27: Return of Rich Client Java - Brazil

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

Page 28: Return of Rich Client Java - Brazil

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

Page 29: Return of Rich Client Java - Brazil

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

Page 30: Return of Rich Client Java - Brazil

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

Page 31: Return of Rich Client Java - Brazil

31 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 8

The AdoptionForm example app

Page 32: Return of Rich Client Java - Brazil

32 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 8

Demo

Page 33: Return of Rich Client Java - Brazil

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

Page 34: Return of Rich Client Java - Brazil

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

Page 35: Return of Rich Client Java - Brazil

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();

}}

Page 36: Return of Rich Client Java - Brazil

36 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 8

Mostrando HTMLno JavaFX

Page 37: Return of Rich Client Java - Brazil

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);

Page 38: Return of Rich Client Java - Brazil

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

Page 39: Return of Rich Client Java - Brazil

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

Page 40: Return of Rich Client Java - Brazil

40 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 8

A app Java Conference Tour

Page 41: Return of Rich Client Java - Brazil

41 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 8

Demo

Page 42: Return of Rich Client Java - Brazil

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!

Page 43: Return of Rich Client Java - Brazil

43 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 8

Perguntas e Respostas

Page 44: Return of Rich Client Java - Brazil

44 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.

Insert Information Protection Policy Classification from Slide 8