Beginning JavaFX.pdf
A hands-on tutorial for learning and using JavaFX™to build your next Java™ rich client or Rich InternetApplication (RIA)Beginning JavaFXMLAWRENCE PREMKUMARPRAVEEN MOHANApressBeginning JavaFX MCopyright o 2010 by Lawrence PremKumar and Praveen MohanAll rights reserved No part of this work may be reproduced or transmitted in any form or by any means,electronic or mechanical, including photocopying, recording, or by any information storage or retrievalsystem, without the prior written permission of the copyright owner and the publisherISBN-13(pbk):978-1-4302-71994ISBN-13( electronic:978-1-4302-7198-7Printed and bound in the United States of America(POD)Trademarked names, logos, and images may appearin this book. Rather than use a trademark symbolin an editorial fashion and to the benefit of the trademark owner, with no intention of infringemello ywith every occurrence of a trademarked name, logo, or image we use the names, logos, and images onlythe trademarkThe use in this publication of trade names, trademarks, service marks, and similar terms, even if they arenot identified as such, is not to be taken as an expression of opinion as to whether or not they are subjectto proprietary rights.President and Publisher: Paul ManningLead Editor: Steve anglinDevelopment Editor: Tom WelshTechnical Reviewer: Sten AndersonEditorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell,Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan ParkesJeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft,Matt Wade, Tom WelshCoordinating editor: Kelly moritzCopy Editor: James A ComptonCompositor: Kimberly BurtonIndexer: Toma MulliganArtist: April milneCover Designer: Anna Ishchenko6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax(201)348-4505, e-mali'23Distributed to the book trade worldwide by Springer Science+Business Media, LLC3 Spring Streorders-nyaspringer-sbm.comorvisitwww.springeronline.comForinformationontranslationspleasee-mailrights@apress.com,orvisitwww.apress.comApress and friends of ed books may be purchased in bulk for academic, corporate, or promotional useeBook versions and licenses are also available for most titles For more information reference ourSpecialBulkSales-ebookLicensingwebpageatwww.apress.com/info/bulksalesThe information in this book is distributed on an"as is"basis, without warranty Although everyprecaution has been taken in the preparation of this work, neither the author(s) nor Apress shall haveany liability to any person or entity with respect to any loss or damage caused or alleged to be causeddirectly or indirectly by the information contained in this workTHesourcecodeforthisbookisavailabletoreadersatwww.apress.comYouwillneedtoanswerquestions pertaining to this book in order to successfully download the codeContents at a GlanceAbout the Authors mmmm xivAbout the technical reviewerAcknowledgements■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■IntroductionChapter 1: Introduction to RIA■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■a■■Chapter 2: Introduction to JavaFXaanChapter 3: Data Types mmmm mmmmaamaamammammnnm 33Chapter 4: Operators and Expressions47Chapter5: Functions…,,,…,,,…,,…,:,:;,…,;:75Chapter 6: Class Definitions mman■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■Chapter 7: Access Specifiersaa109Chapter 8: Inheritance■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■141Chapter 9: Data Binding.155Chapter10: Sequences,,,,…m,m,,,,…,,m……,,,,,m,,,,…175Chapter11: Triggers,,,,,,,,,,,,,,,,,,,,m,m,,189Chapter 12: Introduction to JavaFX UI Elements mAma.■■■■■■■■■■■口■■■■■■■■■■■■■■■■■■■■■■■203Chapter 13: Introduction to Animation mmmm nmIn 269Index303ContentsAbout the Authors mmmm xivAbout the technical reviewerAcknowledgements■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■IntroductionChapter 1: Introduction to RIA■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■a■■The history of RIAKey characteristics of RIA■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■RIA Workflow.2Why ria3Some RIA ExamplesSummary…,,,,,,,,,Chapter 2: Introduction to JavaFx■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■Why JavaFX99-9Advantages of JavaFXHistory of JavaFX,10The javafX PlatformThe Developer Bundle…,…The Designer Bundle.Standalone日日日日日日日日a12JavaFX Platform Integration: The bigger Picture13JavaFX Mobile: An Introduction14Advantages of JavaFX MobCONTENTSDeployment and Distribution15Getting Started16What to downloadWriting Your First JavaFⅩ Application.…16Running Your Application Using NetBeans…,,…Running the application from the command Line27Comments…30Summary31Chapter 3: Data Types■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■33Variable declaration1■■■■■■■■■■■■■■■■■■■■■■■■■■■■■33var vs, def declarations34Variable Naming…,…34Variable Declaration Synt35Data typesgetNumbBooleanDuration.…42TypecastingnnnnnnnnnnnnnnnnnnnnnnnnD1DDDBDDDBDDDDBBDBBDD43SequencesDefault Values for Data Types5SummaryChapter 4: Operators and Expressions mmmmmmmammamm na, 47The Assignment Operator48The as Operator….....,……49Arithmetic Operators0The Modulus or Remainder OperatorCONTENTSThe Arithmetic assignment operato面日日0 perator Precedence…....,…,……,………………52Unary Operators.The Increment and Decrement operators: and…153The Unary and-Operators….154The not operatorRelational OperatorsB日面B日面B自日面B面a面B面a面B面a自面B面a自面B面面自面面自面面面D面日面日面日B55Logical Operators…........………………56Range Expressions…,,,,,,,,,,…,,,,Block Expressions日日面aBa日面aB61Looping Expressions62Break Expressions66Continue Expressions67The if-else ExpressionEXception Handling……,The new Expression…...,.,,.,,.,,,…Differentiating Expressions.Summary73Chapter 5: Functions mRImEIERRRERIRRR EIRRRRamEEERRRR IRR 75How a function worksA Function with Neither an Argument nor a Return value....A Function with Arguments but Without a Return valueA Function Without an argument but with a Return valueA Function with Arguments and a return valueVariable access within a function81Script-Level variablesLocal variables∴…82CONTENTSFunction Overloading82Recursive functions83Anonymous Functions84The run( function86Command-Line Arguments87Summary89Chapter 6: class DefinitionsClasses and objects91C| asses…910 bjects.……………………92Features of oop92Data abstraction92EncapsulantInheritancePolymorphismThe class definition93Creating object Literals94nitializing Class attributes within an object Literal…....……….95Calling the members of the class.Assigning Default Values to Data Members.97The init block97The postinit B|ock…..…9Modifying Class objects99Objects as function Arguments100Non-Member Functions Accessing the object.mamont101Static Members,102Sharing a Function Name Between Script-Level and Member Functions104
下载地址
用户评论