Hello all,

I'm stuck in my app right now. I'd like to be able to repopulate my table of contents (which is a SWT list) based on the selection of a folder from a combo box. I'm new to java/swt and gui programming all together for that matter. Please refer to my code below. Any help is most aprreciated, thank you in advance,

demoZors

Java Code:
import org.eclipse.swt.*;
import org.eclipse.swt.browser.*;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
//import org.eclipse.swt.events.SelectionAdapter.*;
//import org.eclipse.swt.events.SelectionEvent.*;
import java.io.*;
import java.net.*;

public class MainAppEntry{

  static Browser browser;
  static String[] urls;
  static String[] titles;
  static int index;

  public static void main( String[] args ){

    Display d = new Display();
    final Shell s = new Shell( d );

    s.setText( "Documentation Viewer" );
    s.setLayout( new GridLayout() );

    Composite compTools = new Composite( s, SWT.NONE );
    GridData data = new GridData( GridData.FILL_HORIZONTAL );
    compTools.swtLayoutData( data );
    compTools.swtLayout( new GridLayout( 4, false ) );

    Label docSetLabel = new Label( compTools, SWT.None );
    docSetLabel.setText( "Select Folder:" );

    final Combo docSet = new Combo, SWT.DROP_DOWN | SWT.READ_ONLY );
    docSet.setItems( new String[] { "Folder 1", "Folder 2", "Folder 3" });
    docSet.select( 0 );

    ToolBar navBar = new ToolBar( compTools, SWT.None );
    navBar.setLayoutData( new GridData( GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END ) );

    final ToolItem back = new ToolItem( navBar, SWT.PUSH );
    back.setText( "Back" );
    back.setEnabled( false );

    final ToolItem forward = new ToolItem( navBar, SWT.PUSH );
    foward.setText( "Forward" );
    forward.setEnabled( false );

    Composite comp = new Composite( s, SWT.NONE );
    data = new GridData( GridData.FILL_BOTH );
    comp.setLayoutData( data );
    comp.setLayout( new FillLayout() );

    final SashForm form = new SashForm( comp, SWT.HORIZONTAL );
    form.setLayout( new Filllayout() );

    final List list = new List( form, SWT.SINGLE );

    try{
        browser = new Browser( form, SWT.NONE );
    } catch ( SWTError e ) {
        MessageBox mBox = new MessageBox( s, SWT.ICON_ERROR | SWT.OK );
        mBox.setMessage( "The Browser could not be initialized" );
        mBox.setText( "Fatal error - application terminated." );
        mBox.open();
        System.exit( -1 );

    back.addListener( SWT.Selection, new Listener() {
        public void handleEvent( Event e ){
            browser.back();
        }
    });

    forward.addListener( SWT.Selection, new Listener() {
        public void handleEvent( Event e ){
            browser.forward();
        }
    });

    list.addListener( SWT.Selection, new Listener() {
        public void handleEvent( Event e ){
            int index = list.getSelectionIndex();
            browser.setUrl( urls[index] );
        }
    });

    final LocationListener locListener = new LocationListener(){

        public void changed( LocationEvent event ){
            Browser browser = ( Browser )event.widget;
            back.setEnabled( browser.isBackEnabled() );
            forward.setEnabled( browser.isForwardEnabled() );
        }

        public void changing( LoactionEvent event ){}

    });

    final TitleListener tocTitleListener = new TitleListener(){
        public void changed( TitleEvent event ){
            titles[index] = event.title;
        }
    });

    final ProgressListener tocProgressListener = new ProgressListener(){
    
        public void changed( ProgressEvent event ){}

        public void completed( ProgressEvent event ){

            Browser browser = ( Browser )event.widget;
            index++;
            boolean tocCompleted = index >= titles.length;

            if( tocCompleted ){

                browser.dispose();
                browser = new Browser( form, SWT.NONE );
                MainAppEntry.browser = browser;
                form.layout( true );
                browser.addLocationListener( locListener );
                list.removeAll();
                for( int i = 0; i < titles.length; i++ ) list.add( titles[i] );
                list.select( 0 );
                browser.setUrl( urls[0] );
                shell.setText( "Documentation Viewer" );
                return;
           }

            shell.setText( "Building index " +index+"/"+urls.length );
            browser.setUrl( urls[index[] );
        }
    });

    String folder = "Folder 1";
    if( folder == null ) return;
    final File file = new File( folder );

    File[] files = file.listFiles( new FilenameFilter() {
        public boolean accept( File dir, String name ){
            return name.endsWith( ".html" ) || name.endsWith( ".htm" );
        }
    });

    if( files.length == 0 ) return;

    urls = new String[files.length];
    titles = new String[files.length];

    for( int i = 0; i < files.length; i++ ){
    
        try{
            String url = files[i].toUrl().toString();
            urls[i] = url;
        } catch( MalformedURLException ex ){}
    }

    shell.setText( "Building index" );
    browser.addTitleListener( tocTitleListener );
    browser.addProgressListener( tocProgressListener );

    if( urls.length > 0 ) browser.setUrl( urls[0] );

    s.open();
    while( !s.isDisposed() ){
        if( !d.readAndDispatch() ) d.sleep();
    }
    d.dispose();
  }
}