NBDemoMobilityApplicationPorting

Revision as of 20:49, 6 November 2009 by Admin (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)

Application porting with Mobility Pack (5 Minutes)

Description

This demo showcases the application porting features of NetBeans Mobility Pack.

Product Versions Supported

6.0 Beta1+

Points to Hit

  • Mobility pack lets you create configurations and provides a pre-preprocessor which help to port your application to different devices.

Demo Prep

Gotchas

We're at Beta, anything can go wrong.

Demo

  • Open the BallGame project.
  • Run the game and shoot a couple of balls:

File:Balls small.png

  • Mention that the size of the game is too small for this phone.
  • Explain that Mobility Pack lets you manage configurations and we'll create a new configuration.
  • Go to project properties and click on Manage Configurations.
  • Add new configuratio and call it SunPhone.
  • Close the dialog.
  • Open class com.cotopia.games.BallShotImageCreator
  • Go to line 32 and mention that the ball size is set here and can be changed.
  • Create a pre-processor block using right click | Preprocessor blocks | Create If / Else block
  • Use code completion to select SunPhone and change the code like this:
//#if SunPhone
        this.ballWidth = 24;        
//#else
        this.ballWidth = 16;        
//#endif
  • Switch to Motorola configuration and explain that the code for SunPhone gets commented out.
  • Switch back to SunPhone and explain that the else block gets commented out now.
  • Run the demo with the SunPhone configuration.
  • Explain that the game is bigger now:

File:Balls.png

  • Switch to Motorola and run the game.
  • It will be smaller again.
  • Switch to files window.
  • Browse the dist directory and show different jars for different phones.

Demo Cleanup

Delete the demo project.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo