Configuring Your Project for Different Devices


One of the most problematic aspects of development for Mobility projects is the issue known as device fragmentation. Writing a single application that will run on disparate platforms can be challenging. Differences in physical aspects of the platform, such as screen size and free memory, as well as software issues such as available APIs, are some of the reasons why building a single application for multiple devices can require variations in both code and project settings. Fortunately, NetBeans Mobility Pack has built-in support for this issue that simplifies the problem.

The solution is based on the concept of project configurations. You may have noticed that one major difference in the Project Properties dialog box between Mobility and general Java projects is the combo box located at the top of the dialog box labeled Project Configurations. This combo box is the starting point for using the device fragmentation solution. It contains one element for each configuration in your project, as well as an item that creates new configurations.

In general, you should create one configuration for each distribution JAR file you plan on building for your project. So, for example, if you are planning to support three different screen sizes, using two sets of vendor-specific APIs, you would create six configurations.

Creating a Configuration

  1. Right-click your project in the Projects window and choose Properties.

  2. Click the Manage Configurations button. This opens the Project Configuration Manager dialog box, shown in Figure 14-4.

    Figure 14-4. Project Configuration Manager

  3. Click Add to open the Add Project Configuration dialog box.

  4. Enter a name for your new configuration and click OK.

    This name should be an identifier that describes the distribution that this configuration is used for. For example, some descriptive configuration names might be NokiaSeries40, SmallScreen, or HighResNoSizeLimit. The only restrictions are that the identifiers must be valid Java identifiers and that they must not conflict with existing configuration names within the project.

  5. Click Add again if you'd like to create another configuration. Otherwise, click Close to close the dialog box.

When creating a new configuration you may use an existing configuration template. The IDE automatically creates a template for every emulator device registered through Java Platform Manager. For instance, the QwertyDevice_template is pre-configured to use the QwertyDevice of Wireless Toolkit emulator.


Customizing Configurations

Once you have created your configurations, you may make customizations within the Project Properties dialog box that pertain to only one configuration. There are two basic principles of the configurations within the Project Properties dialog. First, by default, all configurations take the values set for the default configuration. Second, user-added configurations can override the default settings for any panel (other than the General panel) if you deselect the checkbox labeled Use Values from "Default Configuration." Once this checkbox has been unchecked, that configuration uses its own settings for the panel.

The following is an example of changing the default configuration and customizing a single configuration:

1.

Right-click your project in the Projects window and choose Properties.

2.

Make sure DefaultConfiguration is selected in the Project Configurations drop-down box. In the Emulator Platform drop-down box, select J2ME Wireless Toolkit 2.2, and in the Device drop-down box of the Platform panel, select DefaultGreyPhone.

3.

In the Project Configurations combo box at the very top of the Project Properties dialog box, select one of the configurations you created in the previous portion of this section.

4.

Select the Platform panel. All controls in this panel should be disabled. This is because the configuration is currently drawing its values from DefaultConfiguration.

5.

Deselect the Use Values from "DefaultConfiguration" checkbox. All controls on the panel are now enabled, as they are no longer taking their values from the default configuration.

6.

Change the Device combo value to DefaultColorPhone.

You have now configured the DefaultConfiguration to use the DefaultGreyPhone device and your user-added configuration to use the DefaultColorPhone.



NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 279

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net