Results 1 to 3 of 3
  1. #1
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Location
    Houston, TX & Flint, MI
    Posts
    609
    Rep Power
    6

    Default Why is my list returning nothing?

    This code creates my list and adds it to the view
    Java Code:
    //Servers
    		new Label(banner, SWT.NONE).setText("Servers:");
    		Server[] servers = ServerGroup.getChildren();
    	    final String[] serverNames = new String[servers.length];
    	    for(int i = 0; i < servers.length; i++){
    	    	serverNames[i] = servers[i].getName(); 
    	    }
    	    categories = new List(banner, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
    		String[] testString = {"Test1","Test2","Test3"};
    	    categories.setItems(testString);
    	    //categories.setItems(serverNames);
    		gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
    		gridData.verticalSpan = 4;
    		int listHeight = categories.getItemHeight()*servers.length;
    		Rectangle trim = categories.computeTrim(0, 0, 0, listHeight);
    		gridData.heightHint = trim.height;
    		categories.setLayoutData(gridData);
    and this is my selection listener that gets called after I press a button on the view
    Java Code:
    enter.addSelectionListener(new SelectionAdapter() {
    			public void widgetSelected(SelectionEvent event) {
    				final String newDeploymentName = deploymentNameText.getText();
    				if (newDeploymentName.trim().isEmpty()) {
    					MessageDialog.openError(new Shell(), "Invalid Name", "Name field must not be blank.");
    					return;
    				}
    				if ( MessageDialog.openConfirm(new Shell(), "Confirm creation", "You are about to create a new Deployment")){
    					System.out.println("Categories:");
    //I think it fails here	        	String[] cats = categories.getItems();
    				//	String[] cats = categories.getSelection();
    					for (int i = 0; i > cats.length; i++) {
    						System.out.println("Test");
    						System.out.println("\t" + cats[i]);
    					}
    		//			Deployment newDeployment = new Deployment(newDeploymentName, ,);
    		//			views.NavigationView.deploymentGroup.addChild(newDeployment);
    				}
    
    			}
    		});
    I think getItems() is killing my program somehow. All that gets printed is Categories:

    It never starts the loop for some reason. Any ideas?

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,415
    Rep Power
    25

    Default

    Which loop are you talking about? I see 2
    What if servers.length or cats.length is zero?
    Add a println() to show the value before entering the loop.

  3. #3
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Location
    Houston, TX & Flint, MI
    Posts
    609
    Rep Power
    6

    Default

    .... I had a greater then symbol instead of a less then. Stupid chair to keyboard error

Similar Threads

  1. How to access ArrayList in List of List?
    By alvations in forum New To Java
    Replies: 5
    Last Post: 10-08-2008, 12:23 PM
  2. String returning null value
    By impact in forum New To Java
    Replies: 7
    Last Post: 08-03-2008, 07:49 AM
  3. returning a value from an arraylist
    By xkross in forum New To Java
    Replies: 2
    Last Post: 04-18-2008, 05:30 PM
  4. JNI - passing and returning parameters by value
    By java_to_c in forum New To Java
    Replies: 0
    Last Post: 01-31-2008, 08:49 PM
  5. Replies: 4
    Last Post: 07-31-2007, 05:19 PM

Posting Permissions

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