real world technologies
DESCRIPTION
Real World Technologies: NetBeans GUI Builder, JRuby, JavaFX, and Java ME. A brief introduction on each one.TRANSCRIPT
![Page 1: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/1.jpg)
1
Real World Real World Technologies: Technologies: NetBeans GUI Builder,NetBeans GUI Builder,JRuby, JavaFX, and JRuby, JavaFX, and Java MEJava ME
developers.sun.com/students/courses
1
![Page 2: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/2.jpg)
2
Topics• Introduction to “Real World Technologies: NetBeans
GUI Builder, JRuby, JavaFX, and Java ME – Earn a Certificate” 5-hour online course
• NetBeans GUI Builder• JRuby & JRuby on Rails • Java FX Programming• Java ME Programming
![Page 3: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/3.jpg)
3
Real World Technologies 5-hour Online Course• You can take it anytime – it is free!• http://developers.sun.com/students/courses• You get exposed to exciting and leading-edge real-
life technologies• You do the hands-on lab and homework• If you submit all 4 homeworks, you will receive PDF
version of certificate• You can participate in the course forum
![Page 4: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/4.jpg)
4
NetBeans GUI NetBeans GUI BuilderBuilder
4
![Page 5: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/5.jpg)
5
NetBeans GUI Builder (Matisse)• Issues with building GUI without Matisse
> Complexity with Swing APIs> Resizing and Alignment are hard> Locale handling> Behave differently over different OS platforms
• Matisse handles all these for you!> Guidelines provided at design time to help with placing and
sizing controls> Adjustments made at runtime for user's look & feel and locale
![Page 6: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/6.jpg)
6
Free Design• You can build your forms by simply putting
components where you want them as though you were using absolute positioning
• The GUI Builder figures out which layout attributes are required and then generates the code for you automatically. > You need not concern yourself with insets, anchors, fills, and
so forth.
![Page 7: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/7.jpg)
7
Automatic Component Positioning• As you add components to a form, the GUI Builder
provides visual feedback that assists in positioning components based on your operating system's look and feel.
• The GUI Builder provides helpful inline hints and other visual feedback regarding where components should be placed on your form, automatically snapping components into position along guidelines.
![Page 8: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/8.jpg)
8
Visual Feedback• The GUI Builder also provides visual feedback
regarding component anchoring and chaining relationships.
• These indicators enable you to quickly identify the various positioning relationships and component pinning behavior that affect the way your GUI will both appear and behave at runtime. > This speeds the GUI design process, enabling you to
quickly create professional-looking visual interfaces that work.
![Page 9: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/9.jpg)
NetBeans GUI BuilderNetBeans GUI BuilderDemo: These Are TheDemo: These Are TheExercises You Will DoExercises You Will Doas Part of the Courseas Part of the Course
![Page 10: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/10.jpg)
10
Demo 1: Building a Contact Editor
![Page 11: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/11.jpg)
11
Demo 2: Adding Event Handlers
![Page 12: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/12.jpg)
12
JRuby &JRuby &JRuby on RailsJRuby on Rails
12
![Page 13: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/13.jpg)
13
Topics• What is and Why JRuby?• What is “JRuby on Rails”?• “Ruby on Rails” Principles• Why “Ruby on Rails”?• Why “JRuby on Rails”?
![Page 14: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/14.jpg)
What is and Why JRuby? What is and Why JRuby?
![Page 15: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/15.jpg)
15
Open source Java
implementation of the Ruby
language
![Page 16: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/16.jpg)
16
What Is JRuby?• Started in 2002• Java platform implementation of Ruby language• Open source, many active contributors• Aiming for compatibility with current Ruby version• Integrates with Java technology
> Call to Ruby from Java technology via Java Specification Request (JSR) 223, BSF, Spring
> Use Java class files from Ruby (e.g., Script Java)• Growing set of external projects based on JRuby
> JRuby-extras (GoldSpike, ActiveRecord-JDBC,…)
![Page 17: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/17.jpg)
17
JRuby: Java Technology Integration• Script Java
> Power of Java technology with the Syntax of Ruby
require 'java'list = java.util.ArrayList.newlist << 1list << 3list << 2list.sort
![Page 18: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/18.jpg)
18
Why JRuby?• JRuby over Ruby
> Strong likelihood we will be faster soon> Better scalability with native threading> Native unicode support> Compilation> Integration with Java libraries> Easier path to getting Ruby in the enterprise
• JRuby over Java technology> Language features
> Blocks, modules, metaprogramming, dynamic-typing> Ruby applications/libraries
> Rails, Rspec, Rake, Raven, other R’s
![Page 19: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/19.jpg)
What is “JRuby on Rails”? What is “JRuby on Rails”?
![Page 20: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/20.jpg)
20
What Is “Ruby on Rails”?• A full-stack MVC web development framework• Open source (MIT), many contributors• Written in Ruby• First released in 2004 by
David Heinemeier Hansson• Gaining popularity
> Ruby and Rails book sales are outselling Perl book sales
![Page 21: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/21.jpg)
““Ruby on Rails”Ruby on Rails”Principles Principles
![Page 22: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/22.jpg)
22
“Ruby on Rails” Principles• Convention over configuration
> Why punish the common cases?> Encourages standard practices> Everything simpler and smaller
• Don’t Repeat Yourself (DRY)> Framework written around minimizing repetition> Repetitive code harmful to adaptability
• Agile development environment> No recompile, deploy, restart cycles> Simple tools to generate code quickly> Testing built into the framework
![Page 23: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/23.jpg)
23
Why “Ruby on Rails”?• Greatly simplified web development
> Instant applications: working code in minutes> “Less Rails code than Java application configuration”
• Growing community of developers• Makes small apps trivial to create• Ruby is an excellent language
![Page 24: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/24.jpg)
24
Why “JRuby on Rails” over “Ruby on Rails”?• Deployment to Java application servers• Java technology production environments pervasive
> Easier to switch framework vs. whole architecture> Lower barrier to entry
• Broader, more scalable database support• Integration with Java technology libraries,
legacy services• No need to leave Java technology servers, libraries,
reliability
![Page 25: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/25.jpg)
25
“JRuby on Rails”: Java EE Platform• Pool database connections• Access any Java Naming and Directory Interface™
(J.N.D.I.) API resource• Access any Java EE platform TLA:
> Java Persistence API (JPA)> Java Management Extensions (JMX™)> Enterprise JavaBeans™ (EJB™)> Java Message Service (JMS) API> SOAP/WSDL/SOA
![Page 26: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/26.jpg)
26
“JRuby on Rails”: Deployment Platforms
• Mongrel> Built-in container
• Warfile deployment to:> GlassFish™ V2> GlassFish™ V3> Servlet-based app server
![Page 27: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/27.jpg)
27
JRuby on Rails: Futures• Improve Java EE platform support for Rails
> Rubify Java EE platform APIs> Create Rails plug-ins to make installable units
• Use Java technology native equivalents> Unicode support> XML support
• Port Ruby native libraries> RMagick
![Page 28: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/28.jpg)
JRuby on RailsJRuby on RailsDemo: These Are TheDemo: These Are TheExercises You Will DoExercises You Will Doas Part of the Courseas Part of the Course
![Page 29: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/29.jpg)
29
Demo 1: Building WebLog Webapp
![Page 30: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/30.jpg)
30
Demo 2: Building Flickr Webapp
![Page 31: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/31.jpg)
31
JavaFX JavaFX ProgrammingProgramming
31
![Page 32: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/32.jpg)
32
Topics• What is and Why JavaFX?• JavaFX Product family and Architecture• JavaFX Script• JavaFX Script examples
![Page 33: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/33.jpg)
33
What is and Why What is and Why JavaFX? JavaFX?
![Page 34: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/34.jpg)
34
Market Trends• Personal & mobile computing are blurring
> Handsets becoming more advanced> Higher-speed IP Networks
• Ecosystem shifting to “platforms”> Full application environment including middleware, user
experience, etc.> Reduce development costs and improves device
consistency• Software stacks largely proprietary
> Industry looking for an Open alternative
![Page 35: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/35.jpg)
35
The GUI Quagmire• Java Swing and 2D APIs are very powerful and yet
> Why does it take a long time to write GUI programs?> How can we avoid the “Ugly Java technology GUI”
stereotype?> Why do Flash programs look different than Java
programs?> Why does it seem easier to write web apps than Swing
programs?> How can I avoid having an enormous mass of listener
patterns?
![Page 36: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/36.jpg)
36
Why yet another scriting language for Java, JavaFX Script?• Language for Spicying up Java GUI Programing
easier• Building and running of media/content- rich Java
clients application much easier• More productive by making Swing and Java 2D™
API accessible to a much the script programmer • Simple Accessing of Java Objects• Serve as persistence format for a new class of tools
targeted at non programmers like designers and end users
![Page 37: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/37.jpg)
37
Expanding the Community
Javadevelopers
Scriptprogrammers
VisualdesignersPr
ogr a
mm
i ng
(Jav
a) s
kills
Com
mun
ity s
ize
Professionals
Hobbyist
![Page 38: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/38.jpg)
38
JavaFXJavaFXProduct Family &Product Family &Architecture Architecture
![Page 39: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/39.jpg)
39
JavaFX Product Family• Announced at JavaONE 2007• Leverages the Java platform's write-once-run-
anywhere portability, application security model, ubiquitous distribution and enterprise connectivity
• Initially comprised of:JavaFX Script
> Highly productive scripting language for content developers to create rich media and interactive content
JavaFX Mobile> Mobile software stack available via OEM license to carriers and
handset manufacturers seeking a branded relationship with consumers
![Page 40: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/40.jpg)
40
Home Entertainment Desktop
InteractiveContent
JavaFX Script
JavaFXFramework
Devices JavaFX Mobile
The Big Picture
Content Authoring Tools
CLDC CDC CDC SE
PBP2D/3DAGUI
SVG/MSA
JavaFX: An Architecture that Scales
![Page 41: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/41.jpg)
41
JavaFX Workflow
JavaFX Tools
Visual Designer
Content developer
Visual Assets
Java FX Scr ip t c od e
Java FX SourceApplication
Compil
ation
JavaFX Mobile
Java FX MobileApp Binary
JavaFX TV
Java FX TV App Binary
JavaFX Desktop/ Consumer JRE
Java FX DesktopApp Binary
Packa
ging
Packaging
Packaging
![Page 42: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/42.jpg)
42
What is What is JavaFX Script?JavaFX Script?
![Page 43: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/43.jpg)
43
What is JavaFX Script?
• Formerly known as F3 (Form Follows Function) of Chirstopher Oliver from Sun Microsystems> http://blogs.sun.com/chrisoliver/category/JavaFX
• Java Scripting Language > Object-oriented> Static typing + type inference> Declarative Syntax> Automatic Data Binding> Mixed functional/procedural evaluation model
![Page 44: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/44.jpg)
44
What is JavaFX Script?• Extensive widget library encompassing Swing
components and Java2D objects• Easily create and configure individual components• Work with all major IDEs• Statically typed - retains same code structuring,
reuse, and encapsulation features of Java• Capable of supporting GUIs of any size or
complexity• Makes it easier to use Swing• Rich Internet Applications (RIA)
![Page 45: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/45.jpg)
45
JavaFX Script – A Simple ComparisonIn JavaFX Script In Java
In Java (SwingLabs Timing Framework)
picks.opacity = [0, .01 .. 1 ] dur 1000 linear
public void class Guitar { private GuitarPick pick = ...; public Guitar() { pick.setOpacity(.5f); Animator a =
PropertySetter.createAnimator( 300, pick, "opacity", .5f, 1.0f);
MouseTrigger.addTrigger(pick, a, MouseTriggerEvent.ENTER, true);
}}
Main guitar class
guitarAnimationThread = new StringOpThread(); ...... ...... if (guitarAnimationThread != null) { guitarAnimationThread.run(); } .........
StringOpThread class ........... public void run() { opacityBegin = 0.01; opacityEnd = 1.0; opacityIncreStep = 0.02; opacitySleep = 2;
for(currOpacity = opacityBegin; \ currOpacity < opacityEnd; \ currOpacity+=opacityIncreStep) { setPickOpacity(); repaint(); try { thread.sleep(opacitySleep); } catch (InterruptedException e) { }
![Page 46: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/46.jpg)
46
JavaFX Script Examples: JavaFX Script Examples: Hello WorldHello World
![Page 47: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/47.jpg)
47
Example : Hello world in Java FX
import javafx.ui.*;
Frame { title: "Hello World JavaFX" width: 200 height: 50 content: Label { text: "Hello World" } visible: true}
![Page 48: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/48.jpg)
48
Example : Hello world in Swingimport javax.swing.*;
public class HelloWorldSwing { public static void main(String[] args) { JFrame frame = new Jframe("HelloWorld Swing"); final JLabel label = new JLabel("Hello World"); frame.getContentPane().add(label);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
![Page 49: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/49.jpg)
49
Data BindingData Binding
![Page 50: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/50.jpg)
50
• Cause and Effect—Responding to change• The JavaFX bind operator—Allows dynamic content to be
expressed declaratively• Dependency-based evaluation of any expression• Automated by the system—Rather than manually wired
by the programmer• You just declare dependencies and the JavaFX runtime
takes care of performing updates when things change• Eliminates listener patterns
Data Binding in JavaFX
![Page 51: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/51.jpg)
51
class HelloWorldModel { attribute saying: String;}var model = HelloWorldModel { saying: "Hello World"};var win = Frame {
title: bind "{model.saying} JavaFX" width: 200 content: TextField { value: bind model.saying } visible: true
};
Example: Dynamic Behavior
![Page 52: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/52.jpg)
52
Java 2DJava 2D
![Page 53: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/53.jpg)
53
Java 2D API• To match the designs of UI designers requires using Java
2D API• But Java 2D API doesn’t have compositional behavior
> The barrier to entry for many Java code programmers is too high (i.e., other than Romain Guy)
• In addition to Swing Components, JavaFX includes SVG-like interfaces to Java 2D API as first-class elements which can be composed together into higher-level components
• JavaFX allows declarative expression of this composition
![Page 54: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/54.jpg)
54
Java ME Java ME ProgrammingProgramming
54
![Page 55: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/55.jpg)
55
Topics• What is and Why Java ME?• Java ME architecture• NetBeans Mobility Pack Features• Game development
![Page 56: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/56.jpg)
56
What is and Why What is and Why Java ME?Java ME?
![Page 57: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/57.jpg)
57
Why Develop Mobility Applications?
• “Application at your fingertips”• Personal
> One of 4 things you always carry with you (keys, wallet, watch, handphone)
• Powerful, feature rich, programmable and royalty free> Games in particular
• Anyone commuting will have 30mins to kill> Capture audience
• It's not really that difficult
![Page 58: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/58.jpg)
58
The Java™ Platforms
High-EndServer
Java TechnologyEnabled Desktop
WorkgroupServer
Java TechnologyEnabled Devices
![Page 59: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/59.jpg)
59
Java on Mobile Devices
Mobile Service Architecture (MSA) provides a complete platform for mobile application development
![Page 60: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/60.jpg)
60
Java ME Application Market
$3 Billion JavaMobile Game Market
$3B
![Page 61: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/61.jpg)
61
Java MEJava MEArchitectureArchitecture
![Page 62: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/62.jpg)
62
Java Platforms
JTWI/MSAJTWI/MSA
JavaJavaPlatform,Platform,
EnterpriseEnterpriseEditionEdition
(Java EE)(Java EE)
JavaJavaPlatform,Platform,StandardStandardEditionEdition
(Java SE)(Java SE)ConnectedConnected
DeviceDeviceConfigurationConfiguration
(CDC)(CDC)
ConnectedConnectedLimited DeviceLimited DeviceConfigurationConfiguration
(CLDC)(CLDC)
JavaJavaCardCard
OptionalOptionalPackagesPackages
OptionalOptionalPackagesPackages
Foundation Profile (FP)Foundation Profile (FP)
PersonalBasis ProfilePersonalBasis Profile(PBP)(PBP)
AdvancedAdvanced GUIGUI
(AGUI)(AGUI)
MobileMobileInformationInformation
Device ProfileDevice Profile(MIDP)(MIDP)
Optional PackagesOptional Packages
Optional PackagesOptional Packages
Java Platform,Java Platform,Micro Edition (Java ME)Micro Edition (Java ME)
PersonalPersonalProfileProfile(PP)(PP)
![Page 63: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/63.jpg)
63
Java ME CLDC Stack
• Connected Limited Device Configuration (CLDC)> For devices with limited memory and processing power> KVM (Kilo VM) Virtual Machine especially designed for
devices with limited computing power and resources• Mobile Information Device Profile (MIDP)
> Defines application model, OTA (over-the-air) installation, basic UI model and widgets, media capabilities, basic Game API, RMS (record management system), connectivity, security model
![Page 64: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/64.jpg)
64
Java ME CLDC Stack (2)
• Multitude of optional JSRs: Media, Bluetooth, Messaging, Location, SIP, and many more
• More JSRs are in the pipeline• “Umbrella” JSRs
> Define a complete platform from existing JSRs• Example
> JSR 185 (Java Technology for Wireless Industry/JTWI)> JSR 248 (Mobile Services Architecture/MSA)
![Page 65: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/65.jpg)
65
Java ME Evolution in WirelessMIDP → JTWI → MSA (Mobile Service Architecture)
MSAMSACDCCDC(2007-08)(2007-08)
MSAMSACLDCCLDC(2006)(2006)
MIDPMIDPCLDCCLDC(2001)(2001)
JTWIJTWICLDCCLDC(2003)(2003)
We are hereWe are here
Dev
ice
Dev
ice
Cap
abili
tyC
apab
ility
![Page 66: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/66.jpg)
66
Compelling Feature Phone Platform:MSA (JSR 248)
VirtualMachine
Security &Commerce
ApplicationConnectivity
PersonalInformation
JSR 180JSR 180SIPSIP
JSR 82JSR 82BluetoothBluetooth
JSR 179JSR 179LocationLocation
JSR 238JSR 238I18NI18N
JSR 184JSR 1843D Graphics3D Graphics
JSR 229JSR 229PaymentPayment
JSR 226JSR 2262D Scalable2D Scalable
Vector GraphicsVector Graphics
JSR 211JSR 211ContentContentHandlerHandler
JSR 234JSR 234Mobile-mediaMobile-mediaSupplementSupplement
JSR 120JSR 120SMSSMS
MessagingMessaging
JSR 172JSR 172Web ServicesWeb Services
JSR 177JSR 177Security &Security &
Trust ServicesTrust Services
JSR 118JSR 118MIDP 2.0MIDP 2.0
JSR 205JSR 205MMSMMS
MessagingMessaging
JSR 135JSR 135Mobile MediaMobile Media
JSR 185JSR 185JTWIJTWI
JSR 75JSR 75PIM & FilePIM & File
JSR 139JSR 139CLDC 1.1CLDC 1.1
Comms
ApplicationEnvironment
Graphics
Conditional APIsJTWI APIs
![Page 67: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/67.jpg)
67
NetBeans MobilityNetBeans MobilityPackPack
![Page 68: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/68.jpg)
68
Mobility Pack
IDE
SDK
● Open, integrated development environment
● Build, test, deploy rich applications
● Accelerate application time-to-market
● Visual, drag-n-drop authoring
● Java ME Platform emulation
● Device agnostic
● Provides additional utilities for application support
● Over 2,000,000 combined downloads
● Industry voted awards
A full IDE built around Sun JavaTM Wireless Toolkit
![Page 69: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/69.jpg)
69
Visual Designer
![Page 70: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/70.jpg)
70
• SVG = Scalable Vector Graphics• Automatically adjusts to screen size• Two roles
> Graphical designers create images> Developers add business logic
• Visual designer for SVG> SVG Menu, SVG Splash Screen, SVG Wait Screen,
SVG Image, ...
SVG
![Page 71: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/71.jpg)
71
NetBeans 6.0 Mobility New Feature• New game builder
> Easier to create mobile games with the Mobility Pack's visual editing support for the MIDP 2.0 Game API
> API supports animated sprites and the ability to arrange tiled layers into scenes
• New Integrated UI for CLDC/MIDP and CDC development
• New Visual Mobile Designer• Design analysis• New components for Flow Control
![Page 72: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/72.jpg)
72
Game DevelopmentGame Development
![Page 73: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/73.jpg)
73
Development of Java Technology-Based Games
• JSR 184 (3D Graphics)• 3D world creation and manipulation
• JSR 135 (Mobile Media)• Sounds
• JSR 82 (Bluetooth)• P2P gaming
• JSR 180 (SIP)• P2P over the network
• JSR 229 (Payment)• Payment of new levels
![Page 74: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/74.jpg)
74
Examples of 2D Games
![Page 75: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/75.jpg)
75
Core Game API Class Hierarchy
![Page 76: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/76.jpg)
76
Game Canvas• GameCanvas specifically for developing game
display> Class extends GameCanvas to use it
• Subclass of Canvas but provides the following improvements> Off-screen buffering> Keypad polling> Access to Graphics object> Do not need to override paint(Graphics) method
• Behavior can be set to be backward compatible with Canvas
![Page 77: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/77.jpg)
77
GameCanvas Example – Main Game Loop01 //main game loop02 while (true) {03 //Poll key press04 int key = getK eyStates();05 if ((key & GameCanvas.LEFT_PRESSED) != 0) {06 //update game objects07 }08 if ((key & GameCanvas.UP_PRESSED) != 0) {09 //update game objects10 }11 //Get off-screen graphics object12 Graphics g = getGraphics();13 //update game screen14 ...15 //update the 'dirty' portion to the screen16 flushGraphics(x, y, dirtyWidth, dirtyHeight);17 }
![Page 78: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/78.jpg)
78
Elements in a Game• Background
> Composable from basic elements
> Static and animated objects• Background layers
> Different layers> Layer management
• Sprites> Transformation > Collision detection
SpriteBackground
Viewport
![Page 79: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/79.jpg)
79
Creating a TiledLayer
tileWidth
tileH
eigh
t
TiledLayer background = new TiledLayer(50, 50, image, tileWidth,
tileHeight)
![Page 80: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/80.jpg)
80
Creating the Background
// Draw the waterfor (int x = 0; x < 12; x++)
background.setCell(x, y, 5);
Tile index
5 5 5 5 5 5 5 55 5 5 5 5
![Page 81: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/81.jpg)
81
Creating Animated Tile
//Indicate the tile to be animatedint animatedTile = backgroud.createAnimatedTile(5);
//Switch the animated tilebackgroud.setAnimateTile(animatedTile, 6);
![Page 82: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/82.jpg)
82
Creating Sprites Loading is similar to TiledLayer
Calling nextFrame() will display the next frame
![Page 83: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/83.jpg)
83
Changing the Frame Sequence
sprite.setFrameSequence(new int[]
{0, 1, 2, ... 1, 1});
sprite.nextFrame();
![Page 84: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/84.jpg)
84
Reference Pixel on Sprites
Default reference pixel
at (0, 0)
![Page 85: Real World Technologies](https://reader035.vdocuments.site/reader035/viewer/2022081403/55568383d8b42abc5a8b54f6/html5/thumbnails/85.jpg)
85
Real World Real World Technologies: Technologies: NetBeans GUI Builder,NetBeans GUI Builder,JRuby, JavaFX, and JRuby, JavaFX, and Java MEJava ME
85