Results 1 to 3 of 3
  1. #1
    new2java2009 is offline Member
    Join Date
    Aug 2009
    Posts
    60
    Rep Power
    0

    Default What is wrong with my code?!

    I catch an "Array index out of range: 0" exception from the following code. Can someone help me find the problem? It took me all morning already with this piece of the code. Thanks.

    Java Code:
    ColumnSettings[] columns = this.getColumns();
    
    /* Set row sorter */
    final RowSorter<DTableModel> sorter = new TableRowSorter<DTableModel>(model);
    this.Table.setRowSorter(sorter);
    		    
    try {
    	TableColumn column = null;
        List<RowSorter.SortKey> sortList = new ArrayList<RowSorter.SortKey>();
    			
        for (int i = 0; i < columns.length; i++)
    	{
        	column = this.Table.getColumnModel().getColumn(i);
    				
        	/* Set column preferred width */	
        	column.setPreferredWidth(columns[i].getColumnWidth());
    				
        	/* Set column renderers */
        	if (columns[i].getColumnName().equals(TIME))
        	{			     
        		column.setCellRenderer(new AlertAckRenderer());
        	}	
    	
        	/* Set sort orders */
        	if (columns[i].isColumnSorted())
        	{
        		if (columns[i].isColumnAscending())
        		{
        			sortList.add(new RowSorter.SortKey(i, SortOrder.ASCENDING));  
        		} else {
        			sortList.add(new RowSorter.SortKey(i, SortOrder.DESCENDING));  
        		}		
        	} else {
        		sortList.add(new RowSorter.SortKey(i, SortOrder.UNSORTED));  
        	}
    	} 			
        sorter.setSortKeys(sortList);
    
    } catch ( Throwable e) {
    	super.logMessage("Error Setting table Columns - " + e.getMessage());
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #3
    new2java2009 is offline Member
    Join Date
    Aug 2009
    Posts
    60
    Rep Power
    0

    Default

    It seems to execute all the lines, then after
    sorter.setSortKeys(sortList);
    it gets to the exception.

Similar Threads

  1. What's going wrong with this code?
    By Suurisa in forum New To Java
    Replies: 5
    Last Post: 10-19-2009, 11:59 PM
  2. what's wrong with my code? please help me...
    By lovely23 in forum Java Applets
    Replies: 2
    Last Post: 03-01-2009, 01:33 PM
  3. pls tell wat wrong with my code???
    By low224 in forum New To Java
    Replies: 13
    Last Post: 01-11-2009, 07:40 AM
  4. What's wrong with this code?
    By Doctor Cactus in forum New To Java
    Replies: 4
    Last Post: 11-29-2008, 05:44 PM
  5. What's wrong with this code?
    By Wizard wusa in forum New To Java
    Replies: 14
    Last Post: 01-22-2008, 11:55 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
  •