[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSOutlineView, Java, Bug?



After helping Patrick Naughton to understand the concept of an NSOutlineView, I tried to implement a hierarchical file listing myself. I've successfully used this class in Objective C, but never in Java.

Here is my code:
/* FileBrowser */

import java.io.File;
import java.util.Arrays;

import com.apple.cocoa.foundation.*;
import com.apple.cocoa.application.*;

public class FileBrowser {
    File root=new File("/");
    
    public int outlineViewNumberOfChildrenOfItem(NSOutlineView outlineView, Object object)
    {
            if(object==null)
                    return Arrays.asList(root.listFiles()).size();
            else
                    return Arrays.asList(((File)object).listFiles()).size();
    }
    
    public boolean outlineViewIsItemExpandable(NSOutlineView outlineView, Object item)
    {
            return ((File)item).isDirectory();
    }
    
    public Object outlineViewChildOfItem(NSOutlineView outlineView, int index, Object item)
    {
            if(item==null)
                    return root.listFiles()[index];
            else
                    return ((File)item).listFiles()[index];
    }

    public Object outlineViewObjectValueForItem(NSOutlineView outlineView, NSTableColumn tableColumn, Object item)
    {
            return ((File)item).getName();
    }
}

When I compile and execute it, the root view is ok, but nothing else works:
* click on a triangle:
Jan 04 02:09:13 FileBrowser[8806] can't invoke constructor `(ZI)V' on class java/io/File
* resize or scrolling of the window:
Jan 04 02:13:36 FileBrowser[8806] can't invoke constructor `(ZI)V' on class java/io/File
+ window goes blank

Is this a bug (in Apple's code)? I got no problems in ObjC (Tomorrow, I'll try the same in ObjC).

andy


-- 
Description forthcoming.