> The problem is, how to set the TextFields contents when its 1st displayed?
> i.e. from the constructor of my object? This is a simple java object, as
> in the CtoF example. I'm unsure how to tie this into the framework, as
> implementing the constructor Fortune() compiles, but fails at run time.
>
> Has anyone any ideas, pointers, or outright solutions?
I hope there might be an easier way, but this method works. If you subclass
NSWindowController, you can do your window initialization before the window
gets displayed by overriding the inherited method windowDidLoad(). However,
the only way I can figure out how to do this is by creating an NSDocument
object that creates the NSWindowController object. So here are the steps
that I use:
1. Start with a Cocoa-Java Document-based application.
2. In Interface Builder, create a subclass of NSWindowController
("MyWindowController" is the default) to respond to your outlets.
3. In MyDocument.nib, change "File's Owner" to be of type
"MyWindowController". Do this by selecting "File's Owner" in the Instances
tab, then going to the Info tool window, select the Attributes popup, then
pick "MyWindowController" from the list.
4. Connect "File's Owner" to your outlet.
5. In MyDocument.java, add the makeWindowControllers() and remove
windowNibName() and windowControllerDidLoadNib()
6. Add the nib file name to the constructor in MyWindowController, add the
windowDidLoad() method, and handle the rest of your window controls there.
I've attached the two example files in the hopes of making this explanation
clearer. Also, since you are using an NSTextField, this will leave whatever
text you set selected when the app launches, so you might want to make it
non-editable (or find another way to disable First Responder, which I think
requires a delegate method).
> How do you start an application at each login in Macos X anyway?
You can assign startup apps in the Login panel in System Preferences.