Code sample: Displaying a row of images for scrolling

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.container.*;
import net.rim.device.api.ui.decor.*;    
import net.rim.device.api.ui.extension.component.*;

public class PictureScrollFieldDemo extends UiApplication
{
     public static void main(String[] args)
     {
          PictureScrollFieldDemo app = new PictureScrollFieldDemo();
          app.enterEventDispatcher();
     }
    
     public PictureScrollFieldDemo()
     {
          pushScreen(new PictureScrollFieldDemoScreen());
     }
}

class PictureScrollFieldDemoScreen extends MainScreen
{	
     public PictureScrollFieldDemoScreen()
     {
          setTitle("PictureScrollField Demo");

          Bitmap[] images = new Bitmap[3];
          String[] labels = new String[3]; 
          String[] tooltips = new String[3];

          images[0] = Bitmap.getBitmapResource("img1.jpg");
          labels[0] = "Label for image 1";
          tooltips[0] = "Tooltip for image 1";

          images[1] = Bitmap.getBitmapResource("img2.jpg");
          labels[1] = "Label for image 2";
          tooltips[1] = "Tooltip for image 2";

          images[2] = Bitmap.getBitmapResource("img3.jpg");
          labels[2] = "Label for image 3";
          tooltips[2] = "Tooltip for image 3";

          ScrollEntry[] entries =  ScrollEntry[3];

          for (int i = 0; i < entries.length; i++) 
          { 
               entries[i] = new ScrollEntry(images[i], labels[i],tooltips[i]);
          }
		
		
          PictureScrollField pictureScrollField = new PictureScrollField(150, 100);
          pictureScrollField.setData(entries, 0);
          pictureScrollField.setHighlightStyle(HighlightStyle.ILLUMINATE);
          pictureScrollField.setHighlightBorderColor(Color.BLUE);
		
          pictureScrollField.setBackground(BackgroundFactory.createSolidTransparentBackground(Color.RED, 150));

          pictureScrollField.setLabelsVisible(true); 

          add(pictureScrollField);
     }
}

Was this information helpful? Send us your comments.