Here is the basic idea (there are variations depending on your needs, so read the Javadoc):

 File f = ...;
int lineNumber = ...;
FileObject fo = FileUtil.toFileObject(f);
DataObject d = DataObject.findObject(f);
LineCookie lc = (LineCookie) d.getCookie(LineCookie.class);
if (lc == null) {/* cannot do it */ return;}
Line l = lc.getLineSet().getOriginal(lineNumber);
l.show(Line.SHOW_GOTO);

Source: NetBeans FAQ