JavaMEComponent VDComponentProject

NOTE: Before start reading this document make sure you completed part one: Part One: Java ME component implementation


Contents


Introduction

This document is a part of Java ME Custom Component Creation tutorial.

It will help you to create Java ME Visual Designer component using "Mobile Designer Components" project creation wizard. You will also learn how to create Visual Designer component to existing project.

You may download zipped project created in this tutorial: VMDSplashScreenExt_part2_JavaMEComponent_VDComponentProject.zip

Steps

If you not familiar with Netbeans Module Development you may read Introduction to NetBeans Module Development

Open Wizard

  1. Open Java ME Mobile Designer Components project creation wizard
    Image:MobileDesignerComponentsProject_JavaMEComponent_VDComponentProject.jpg
  2. Go to next Name and Location step
    1. Name it VMDSplashScreenExt
    2. Select Standalone Module radio button
  3. Go to next Basic Module Configuration step
    1. Set code Name Base value to org.netbeans.custom
  4. Go to next step Libraries

Add Library

  1. Open Java SE Library Descriptor creation wizard using Add... button
  2. Create library with Java ME component SplashScreenStatus implementation
    1. Press Manage Libraries button to open Library Manager
    2. Press New Library...
    3. In opened New Library dialog set Library name to JavaMESplashScreenExt and press OK
    4. Select JavaMESplashScreenExt library in Libraries list on the left
    5. Press Add JAR/Folder... button
    6. Browse to SplashScreenExtLibrary/dist/SplashScreenExtLibrary.jar file created in previous tutorial page
    7. Close Library Manager by pressing OK button
    8. Select JavaMESplashScreenExt in Available Libraries list
    9. Go to the next Name and Location step
    10. Accept default values and press Finish
  3. Created Library Descriptor should be added to the list
    Image:addedLibraryDescriptor_JavaMEComponent_VDComponentProject.jpg


  1. Go to next step Components

Add Component

  1. Open Component Descriptor creation wizard using Add... button
  2. Set Prefix value to SplashScreenStatus
    Prefix is used in new Visual Designer component Descriptor and Producer class names
    Component Descriptor Class Name will be automatically set to SplashScreenStatusCD
  3. Set TypeID value to full name of Java ME component org.netbeans.microedition.lcdui.custom.SplashScreenStatus
  4. Set Super Descriptor Class to org.netbeans.modules.vmd.midpnb.components.displayables.SplashScreenCD
    We create Component Descriptor for Visual Designer component that represents Java ME component org.netbeans.microedition.lcdui.custom.SplashScreenStatus
    SplashScreenCD describes component with represents Java ME component SplashScreen in Visual Designer
    While SplashScreenStatus extends SplashScreen, we want SplashScreenStatusCD to have SplashScreenCD as supertype
    Image:cdwizard_cdstep_JavaMEComponent_VDComponentProject.jpg
  5. Go to next step Component Producer
  6. Select Add dependent library on the Design Component creation checkbox
  7. Set library name value to JavaMESplashScreenExt
    We use name of library descriptor created on Libraries step
    If name is specified library will be added to the Mobility project when Visual Designer component is created and added to the document for the first time.
  1. Other values leave by default
    Image:cdwizard_producerstep_JavaMEComponent_VDComponentProject.jpg
  2. Press Finish
  3. Created Component Descriptor should be added to the list
    Image:addedComponentDescriptor_JavaMEComponent_VDComponentProject.jpg
  4. Press Finish button

Result

Created Project is NetBeans Module Project.

Project is updated to contain data related to Java ME Visual Designer component

  • ComponentDescriptor class, which represents a component descriptor. It is registered in the component descriptor registry and then available for using in document. Component descriptor contains information about particular component:
  • Presenters which are implementing functionality and behavior of the component
  • TypeID, which combines two types of information:
  • Kind of the component which for ComponentDescriptor is TypeID.Kind.Component
  • String which represents fully qualified name of the Java ME class Object. In our case Visual Designer component SplashScreenStatus represents JavaME SplashScreenStatus. Fully qualified name of this class is org.netbeans.microedition.lcdui.custom.SplashScreenStatus so CustomComponet string for TypeID is excatly the same org.netbeans.microedition.lcdui.custom.SplashScreenStatus
  • And other information like supported MIDP version, Property descriptors for declared properties
  • Producer class. Producers are also registered in the DescriptorRegistry are usually visualized in the palette and represent a component. Producer is a place to define PaletteDescriptor, set property of new created DesignComponent, attach DesignComponent to the parent component or do other components related actions
  • layer.xml is necessarily created
  • ComponentDescriptor and Producer are registered in DescriptorRegistryand, described in layer.xml
  • Necessary modules are added to project dependencies
    look into Project Properties | Libraries for module dependencies information

And data for runtime library

  • Java library descriptor


Run

If you install created Module now, SplashScreenStatus component is visible in the Mobility Visual Designer Palette, it is possible to edit it using Screen Editor and D&D component form Mobility Palette.

  1. Build both created project SplashScreenExtLibrary and VMDSplashScreenExt
  2. Invoke Install/Reload in Development IDE command for VMDSplashScreenExt project.
    Image:run_install_JavaMEComponent_VDComponentProject.jpg
  3. After module is installed, create new Mobility project with HelloMIDlet created.
  4. Open created HelloMIDlet on Flow view
  5. Drag&Drop splashScreenStatus element from palette

You can link it with other elements on diagram and see it's properties in properties tab.
Image:run_flow_JavaMEComponent_VDComponentProject.jpg

You can also switch to Screen view by double-clicking at the top-left corner of splashScreenStatus element on diagram.
You will see an approximate preview of how component will be displayed at phone's display.
Image:run_screen_JavaMEComponent_VDComponentProject.jpg

Add Component to existing project

It is also possible to add Visual Designer component to existing NetBeans Module project.

Library Descriptor

Top add library descriptor to existing NetBaans module project, invoke New File wizard and select Module Development | Java SE Library Descriptor file type.

Component

To add component to existing project, invoke New File wizard and select Mobile Designer | Mobile Designer Component file type.

Module Dependencies

If project was created using "Mobile Designer Components" project creation wizard, necessary module dependencies are already added. Otherwise you have to add the following module dependencies:

  • Utilities API - Basic Utilities API. Here is used to load localized resources form Bundle.properties files
  • VMD MIDP - Visual Designer implementation of MIDP 2
  • VMD Model - Visual Designer Model
  • VMD Properties - Module responsible for Netbeans Properties Window

optional:

  • VMD MIDP NB - NetBeans extension for Visual Designer implementation of MIDP 2
    Is necessary if you use any Visual Designer components, added by NetBeans (e.g. SplashScreen).

Now you can continue with the next tutorial step: Part Three: Extending Java ME Visual Designer component source code

Back to Java ME Custom Component Creation tutorial

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