欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Display an image for zooming and panning UI.net

程序员文章站 2022-03-10 10:57:04
...

  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 aZoomScreen 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 = new EncodedImage("myImg.jpg");
              ZoomScreen zoomableImg = new ZoomScreen(myImg);
              pushScreen(zoomableImg);
         }
    }

Code sample: Displaying an image for zooming and panning

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.*;

public class ZoomableImageApp extends UiApplication
{
     public static void main(String[] args) 
     {
          ZoomableImageApp theApp = new ZoomableImageApp();
          theApp.enterEventDispatcher();
     }

     public ZoomableImageApp()
     {
          EncodedImage myImg = new EncodedImage("myImg.jpg");
          ZoomScreen zoomableImg = new ZoomScreen(myImg);
          pushScreen(zoomableImg);
     }
}

相关标签: UI .net