Display an image for zooming and panning

  1. Import the required classes and interfaces:
    import net.rim.device.api.system.*;
    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.component.*;
    import net.rim.device.api.ui.extension.container.*;
  2. Create the application framework by extending the UiApplication class. In main(), create an instance of the new class and invoke enterEventDispatcher() to enable the application to receive events. In the constructor, create an EncodedImage using a resource in your project, create a ZoomScreen with the EncodedImage, and invoke pushScreen() to display the image for zooming and panning.
    public class ZoomableImageApp extends UiApplication
    {
         public static void main(String[] args) 
         {
              ZoomableImageApp theApp = new ZoomableImageApp();
              theApp.enterEventDispatcher();
         }
    
         public ZoomableImageApp() 
         {
              EncodedImage myImg = EncodedImage.getEncodedImageResource("myImg.jpg");
              ZoomScreen zoomableImg = new ZoomScreen(myImg);
              pushScreen(zoomableImg);
         }
    }

Was this information helpful? Send us your comments.