advertisement

Article:
  Giving the Simple Text Editor 'Legs'
Subject:   Java Version - Solution
Date:   2002-05-25 15:12:43
From:   jsumnertx
I've been doing these examples in Java rather than Objective C. Here's the Java code version of this example


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


public class MyDocument extends NSDocument {
NSTextView textView;
NSData fileData;

public MyDocument() {
super();
}


public MyDocument(String fileName, String fileType) {
super(fileName, fileType);
}


public String windowNibName() {
return "MyDocument";
}


public void windowControllerDidLoadNib(NSWindowController aController) {
super.windowControllerDidLoadNib(aController);
// Add any code here that need to be executed once the windowController has loaded the document's window.
if ( fileData != null ) {
NSRange range=new NSRange(0,0);
textView.replaceCharactersInRangeWithRTFD(range, fileData);
}
}


public NSData dataRepresentationOfType(String aType) {
NSRange range = new NSRange(0, textView.textStorage().length());
return textView.RTFDFromRange(range);
}


public boolean loadDataRepresentation(NSData data, String aType) {
// Insert code here to read your document from the given data.
fileData=data;
return fileData!=null;
}
}


1 to 1 of 1
  1. Java Cocoa Odysee
    2004-03-02 05:01:31  linus4200 [View]

1 to 1 of 1