SlideShare ist ein Scribd-Unternehmen logo
1 von 60
Downloaden Sie, um offline zu lesen
美觀、快速與流暢的Java用戶端應用程式
甲骨文授權教育訓練中心
聯成電腦
張益裕
JCheckBox

JWindow

JButton
JTable

Swing

JPanel
MouseListener
JList
JToggleButton

JEditorPane

JPopupMenu

ItemListener

Java3D

JColorChooser

JComboBox

AdjustmentListener

KeyListener
JRadioButton

GroutLayout

JToolBar

JOptionPane

JLabel

JRootPane

BorderLayout

JFrame

ActionListener
WindowListener
JMenuItem
JSplitPane

Java2D

CardLayout

JProgressBar

ComponentListener

JTextPane

JToolbar

JTextArea

FocusListener

GridLayout

JScrollPane

JTree

JScrollBar

TextListener

JTextField

JMenu

JTabbedPane

AWTJDialog

JPasswordField
FlowLayout

ScrollPaneLayout
Beautiful

Fast

Smooth

Simple
Beautiful

Fast

Smooth

Simple
Java EE

JavaFX

Java SE

Java ME

Java Card

JVM

Java ME VM

Card VM

Java Programming Language
• Java language features
• FXML for defining user interfaces
• New graphics pipeline for modern GPUs
• Rich set of UI controls
• Powerful Properties Model
• Swing and AWT Interoperability
JavaFX Public APIs and Scene Graph

Quantum Toolkit

Prism

Java 2D

Open GL

3D

Glass
Windowing
Toolkit

Media
Engine

Web
Engine
• Over 50+ components
• CSS skinning and layout
• Advanced UI controls
Animation
Belgium
Antwerp
FXML
javafx.stage.Stage
javafx.scene.Scene
root

parent

leaf
javafx.application.Application

public class HelloJavaFX extends Application {
Top level container

@Override
public void start(Stage stage) {

Root container

BorderPane root = new BorderPane();
Button btn = new Button("Hello JavaFX!");
root.setCenter(btn);

}

}

Place Button

Scene scene = new Scene(root, 300, 250);
stage.setScene(scene);
stage.show();

public static void main(String[] args) {
launch(args);
}
Run...
• Region & Pane
• AnchorPane
• BorderPane
• FlowPane & TilePane
• GridPane
• VBox & HBox
• StackPane
BorderPane

FlowPane

GridPane

TilePane

AnchorPane

HBox

VBox

StackPane
• All new event structure and Handler
• Working with convenience methods
• Support Multi-Touch
KeyEvent.KEY_PRESSED
InputEvent.ANY

KeyEvent.ANY

KeyEvent.KEY_RELEASED
KeyEvent.KEY_TYPED

Event.ANY

ActionEvent.ACTION

MouseEvent.ANY

MouseEvent.MOUSE_PRESSED

...

MouseEvent.MOUSE_RELEASED
...

WindowEvent.ANY

WindowEvent.WINDOW_SHOWING
WindowEvent.WINDOW_SHOWN
...
listener?

Button btn = new Button("Hello JavaFX!");
Generic Event type

Register

btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
/* Do something */
Generic Event type
}
});

Override
final Circle circle = new Circle(radius, Color.RED);
circle.setOnMouseEntered(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
/* Do something */
}
});
circle.setOnMouseExited(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
/* Do something */
}
});
circle.setOnMousePressed(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
/* Do something */
}
});
handle

EventHandler
final Ellipse oval = new Ellipse(100, 50);
oval.setOnZoom(new EventHandler<ZoomEvent>() {...});
oval.setOnScroll(new EventHandler<ScrollEvent>() {...});
oval.setOnRotate(new EventHandler<RotateEvent>() {...});
• JavaBean Component architecture
• Expanded JavaBean properties
• In conjunction with Binding
Label mile = new Label();

KM to mile

double kmValue = 32.5;
double mileValue = kmValue * 0.621371192;
String mileText = Double.toString(kmValue);
mile.setText(mileText);
Set Label text

Double to String
KM Property Object

DoubleProperty kmPro = new SimpleDoubleProperty();
Label mile = new Label();

StringBinding Object,
hold KM to mile value

StringBinding mileBinding =
kmPro.multiply(0.621371192).asString();
mile.textProperty().bind(mileBinding);
...

Bind mile value
to Text Property

kmPro.set(32.5);
Change KM Property value
DoubleProperty kmPro = new SimpleDoubleProperty();
Label mile = new Label();

Extends Binding Class

StringBinding mileBinding = new StringBinding() {
{
Binding Property
super.bind(kmPro);
}
Override computeValue method

@Override
protected String computeValue() {
return Double.toString(kmPro.get() * 0.621371192);
}
Produce value here

};
mile.textProperty().bind(mileBinding);
...
kmPro.set(32.5);
Login.css

.root	
  {	
  
	
  	
  	
  	
  -­‐fx-­‐background-­‐image:	
  url("background.jpg");
}
.label	
  {	
  	
  	
  	
  ...	
  	
  	
  	
  }
#welcome-­‐text	
  {	
  	
  	
  	
  ...	
  	
  	
  	
  }
#ac@ontarget	
  {	
  	
  	
  	
  ...	
  	
  	
  	
  }
.buAon	
  {	
  	
  	
  	
  ...	
  	
  	
  	
  }
.buAon:hover	
  {	
  	
  	
  	
  ...	
  	
  	
  	
  }
Scene scene = new Scene(grid, 300, 275);
scene.getStylesheets().add("login/Login.css");
Text scenetitle = new Text("Welcome");
scenetitle.setId("welcome-text");
Text actiontarget = new Text();
actiontarget.setId("actiontarget");

Login.css

.root	
  {	
  
	
  	
  	
  	
  -­‐fx-­‐background-­‐image:	
  url("background.jpg");
}
.label	
  {	
  	
  	
  	
  ...	
  	
  	
  	
  }
#welcome-­‐text	
  {	
  	
  	
  	
  ...	
  	
  	
  	
  }
#ac,ontarget	
  {	
  	
  	
  	
  ...	
  	
  	
  	
  }
.buAon	
  {	
  	
  	
  	
  ...	
  	
  	
  	
  }
.buAon:hover	
  {	
  	
  	
  	
  ...	
  	
  	
  	
  }
FXML

• XML-based language
• Separate UI from your code
• Support localize
• Support any JVM language
BorderPane border = new BorderPane();
Label topPaneText = new Label("Label - TOP");
border.setTop(topPaneText);
Button centerPaneButton = new Button("Button - CENTER");
border.setCenter(centerPaneButton);
FXML

<BorderPane>
<top>
<Label text="Label - TOP"/>
</top>
<center>
<Button text="Button - CENTER"/>
</center>
</BorderPane>
Parent root =
FXMLLoader.load(getClass().getResource("Sample.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
Sample.fxml

<BorderPane>
<top>
<Label text="Label - TOP"/>
</top>
<center>
<Button text="Button - CENTER"/>
</center>
</BorderPane>
Sample.fxml

<BorderPane fx:controller="SampleController" >
<top>
<Label text="Label - TOP" fx:id="label" />
</top>
<center>
<Button text="Button - CENTER"
fx:id="button"
onAction="#handleButtonAction"/>
</center>
</BorderPane>

...
public class SampleController implements Initializable {
@FXML
private Label label;
@FXML
private Button button;

SampleController.java

@FXML
private void handleButtonAction(ActionEvent event) {
button.setText("Button Pressed!");
label.setText("Button Pressed!");
}
...
}
• UI Layout Tool
• FXML Visual Editor
• Integrated Developer Workflow
• Preview Your Work
• CSS support
ImageView

TableView

Button

ListView

Label, TextField and TextArea
• JavaFX
❖http://www.oracle.com/technetwork/java/javafx/
• NetBeans
❖http://netbeans.org/
59
Thanks
甲骨文授權教育訓練中心
聯成電腦
張益裕

Weitere ähnliche Inhalte

Was ist angesagt? (7)

Angular js 24 april 2013 amsterdamjs
Angular js   24 april 2013 amsterdamjsAngular js   24 april 2013 amsterdamjs
Angular js 24 april 2013 amsterdamjs
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
 
Kursus
KursusKursus
Kursus
 
jQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journeyjQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journey
 
PHPConf-TW 2012 # Twig
PHPConf-TW 2012 # TwigPHPConf-TW 2012 # Twig
PHPConf-TW 2012 # Twig
 
Utopia Kindgoms scaling case: From 4 to 50K users
Utopia Kindgoms scaling case: From 4 to 50K usersUtopia Kindgoms scaling case: From 4 to 50K users
Utopia Kindgoms scaling case: From 4 to 50K users
 
Workshop 8: Templating: Handlebars, DustJS
Workshop 8: Templating: Handlebars, DustJSWorkshop 8: Templating: Handlebars, DustJS
Workshop 8: Templating: Handlebars, DustJS
 

Ähnlich wie JCD 2012 JavaFX 2

Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011
Chris Alfano
 
J Query The Write Less Do More Javascript Library
J Query   The Write Less Do More Javascript LibraryJ Query   The Write Less Do More Javascript Library
J Query The Write Less Do More Javascript Library
rsnarayanan
 
Overview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web FrameworkOverview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web Framework
IndicThreads
 
Scala based Lift Framework
Scala based Lift FrameworkScala based Lift Framework
Scala based Lift Framework
vhazrati
 
Build Lightweight Web Module
Build Lightweight Web ModuleBuild Lightweight Web Module
Build Lightweight Web Module
Morgan Cheng
 

Ähnlich wie JCD 2012 JavaFX 2 (20)

jrubykaigi2010-lt-rubeus
jrubykaigi2010-lt-rubeusjrubykaigi2010-lt-rubeus
jrubykaigi2010-lt-rubeus
 
[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern
 
Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011
 
J Query The Write Less Do More Javascript Library
J Query   The Write Less Do More Javascript LibraryJ Query   The Write Less Do More Javascript Library
J Query The Write Less Do More Javascript Library
 
JavaFX – 10 things I love about you
JavaFX – 10 things I love about youJavaFX – 10 things I love about you
JavaFX – 10 things I love about you
 
Griffon @ Svwjug
Griffon @ SvwjugGriffon @ Svwjug
Griffon @ Svwjug
 
Overview Of Lift Framework
Overview Of Lift FrameworkOverview Of Lift Framework
Overview Of Lift Framework
 
Overview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web FrameworkOverview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web Framework
 
Scala based Lift Framework
Scala based Lift FrameworkScala based Lift Framework
Scala based Lift Framework
 
Integrating SAP the Java EE Way - JBoss One Day talk 2012
Integrating SAP the Java EE Way - JBoss One Day talk 2012Integrating SAP the Java EE Way - JBoss One Day talk 2012
Integrating SAP the Java EE Way - JBoss One Day talk 2012
 
Learning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security APILearning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security API
 
How to React Native
How to React NativeHow to React Native
How to React Native
 
React on Rails - RailsConf 2017 (Phoenix)
 React on Rails - RailsConf 2017 (Phoenix) React on Rails - RailsConf 2017 (Phoenix)
React on Rails - RailsConf 2017 (Phoenix)
 
Build Lightweight Web Module
Build Lightweight Web ModuleBuild Lightweight Web Module
Build Lightweight Web Module
 
Porting legacy apps to Griffon
Porting legacy apps to GriffonPorting legacy apps to Griffon
Porting legacy apps to Griffon
 
College management system.pptx
College management system.pptxCollege management system.pptx
College management system.pptx
 
준비하세요 Angular js 2.0
준비하세요 Angular js 2.0준비하세요 Angular js 2.0
준비하세요 Angular js 2.0
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql
 
前端概述
前端概述前端概述
前端概述
 
React responsively, render responsibly - react meetup
React responsively, render responsibly - react meetupReact responsively, render responsibly - react meetup
React responsively, render responsibly - react meetup
 

Kürzlich hochgeladen

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Kürzlich hochgeladen (20)

Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 

JCD 2012 JavaFX 2