formData = new FormData (); formData.right = new FormAttachment( 100, 0 ); formData.bottom = new FormAttachment( 100, 0 ); label.setLayoutData( formData );
	public static void main( String[] args ) {		/* initializing */		display = new Display();		shell = new Shell( display );		splashShell = new Shell( display, SWT.ON_TOP );		preferenceStore = new PreferenceStore( "g2gui.pref" );		myPrefs = new Preferences( preferenceStore );		waiterObject = new Object();		box = new MessageBox( shell, SWT.ICON_ERROR | SWT.OK );		progressBar = new ProgressBar( splashShell, SWT.NONE );		count = new int[] { 2 };		/* build the splash */		progressBar.setMaximum( count[0] );		image = new Image( display, "icons/splash.png" );		label = new Label( splashShell, SWT.NONE );		label.setImage( image );		FormLayout layout = new FormLayout();		splashShell.setLayout( layout );		formData = new FormData ();		formData.right = new FormAttachment( 100, 0 );		formData.bottom = new FormAttachment( 100, 0 );		label.setLayoutData( formData );		formData = new FormData();		formData.left = new FormAttachment( 0, 5 );		formData.right = new FormAttachment( 100, -5 );		formData.bottom = new FormAttachment( 100, -5 );		progressBar.setLayoutData( formData );		splashShell.pack();		shellRect = splashShell.getBounds();		displayRect = display.getBounds();		int x = ( displayRect.width - shellRect.width ) / 2;		int y = ( displayRect.height - shellRect.height ) / 2;		splashShell.setLocation( x, y );		splashShell.open();		increaseBar( "Starting the model" );		/* load the preferences */		try {			myPrefs.initialize( preferenceStore );		}		catch ( IOException e ) { }					/* if the gui isnt set up yet launch the preference window */		if ( !( preferenceStore.getBoolean( "initialized" ) ) ) {								splashShell.setVisible( false );			myPrefs.open( shell, null );			splashShell.setVisible( true );		}				port = preferenceStore.getInt( "port" );		hostname = preferenceStore.getString( "hostname" );		username = preferenceStore.getString( "username" );		password = preferenceStore.getString( "password" );				/* create the socket connection to the core */		Socket socket = null;		try {			socketPool = new SocketPool( hostname, port );			socket = ( Socket ) socketPool.checkOut();		}		catch ( UnknownHostException e ) {			box.setText( "Invalid Host Address" );			box.setMessage( "Illegal Host Address" );			box.open();			myPrefs.open( shell, null );		}		catch ( IOException e ) {			box.setText( "IOException" );			box.setMessage( "Core is not running on this Host/Port" );			box.open();			myPrefs.open( shell, null );		}				/* launch the model */		core = new Core( socket, username, password, waiterObject );		core.connect();		mldonkey = new Thread( core );		mldonkey.setDaemon( true );		mldonkey.start();				while ( true ) {			/* wait as long as the core tells us to continue */			synchronized ( waiterObject ) {				try {					waiterObject.wait();				}				catch ( InterruptedException e1 ) { }			}			/* did the core receive "bad password" */			if ( core.getBadPassword() ) {				badPasswordHandling();			}			/* user/pass was valid, leave the loop */			else				break;		}				increaseBar( "Starting the view" ); 				/* launch the view */			MainTab g2gui = new MainTab( core, shell );		core.disconnect();	}