Results 1 to 1 of 1
  1. #1
    ashin is offline Member
    Join Date
    Nov 2008
    Posts
    71
    Rep Power
    0

    Default Nebula Gallery in SWT

    Hi guys does anyone knows how to show the gallery nebula? ihave this code from a source/site:

    Java Code:
    package webportalcms;
    
    import java.io.File;
    
    import org.eclipse.nebula.widgets.gallery.Gallery;
    import org.eclipse.nebula.widgets.gallery.GalleryItem;
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.graphics.Image;
    import org.eclipse.swt.graphics.ImageLoader;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Event;
    import org.eclipse.swt.widgets.Listener;
    import org.eclipse.swt.widgets.Shell;
    
    
    
    public class FilesFolder {
    
    	public FilesFolder(Display display,final Shell parent) {
    		final Gallery gallery = new Gallery(parent, SWT.V_SCROLL | SWT.VIRTUAL);
    
    		// Open Directory 
    		final File f = new File("C:\\Images"); 
    		final File[] contents = f.listFiles(); 
    
    		// SetData is called when Gallery creates an item. 
    		gallery.addListener(SWT.SetData, new Listener() {
    		   public void handleEvent(Event event) {
    		      GalleryItem item = (GalleryItem) event.item; 
    		      if (item.getParentItem() == null) { 
    		         // It's a group 
    		         int index = gallery.indexOf(item); 
    		         if( index == 0 ) { 
    		            // This is group 1 
    		            item.setText("C:\\Images"); 
    		            item.setItemCount(contents.length);
    		            item.setExpanded(true); 
    		        } else {
    		           // Should never be used 
    		           item.setItemCount(0); 
    		        } 
    		     } else { 
    		       // It's an item 
    		       GalleryItem parentItem = item.getParentItem();
    		       
    		       // Get item index 
    		       int index = parentItem.indexOf(item);
    
    		       // Load corresponding items 
    		       String imgFilePath = contents[index].getAbsolutePath();
    		       ImageLoader loader = new ImageLoader(); 
    		       Image img = new Image(parent.getDisplay(), loader.load(imgFilePath)[0]); 
    		       item.setImage(img); 
    		     }
    		   } 
    		}); 
    
    		// Create one group (will call SetData) 
    		gallery.setItemCount( 1 );
    		
    		
    		
    	}
    
    }
    There are no errors but the gallery doesn't show.... tnx..
    Last edited by ashin; 09-06-2010 at 05:53 PM.
    :cool:

Similar Threads

  1. trouble accomplishing 100% width gallery
    By andyjoe81 in forum New To Java
    Replies: 1
    Last Post: 07-07-2010, 02:32 AM
  2. Gallery Mage 2.4.1
    By levent in forum Java Software
    Replies: 0
    Last Post: 05-20-2007, 10:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •