Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Java & Carbon - outlets really bug me

Java & Carbon - outlets really bug me
Thread Tools
Dedicated MacNNer
Join Date: Oct 2000
Location: Pasadena, CA, USA
Status: Offline
Reply With Quote
Dec 4, 2000, 11:43 PM
 
Here's the deal. When you use IB to create a java class with outlets and actions, the actions are implemented as methods (which is fine) and the outlets are implemented as package-scope instance variables. Instance variables which somehow magically get a reference to the interface elements defined in the nib file.

That seems to me to be kind of ugly. It seems to me that the Java way of doing things would be to make the outlets accessor methods. I've tried doing just that, but for can't quite get it to work.

Am I out on a limb here? Cocoa and Java are really cool, but the more I dig into it the more I feel like Java is the poor second cousin in Cocoa development. This seems to me like the sort of thing that's fine in Objective C (I don't know if it is or not; I'm just saying) but in Java it just stinks.

     
Senior User
Join Date: Nov 2000
Status: Offline
Reply With Quote
Dec 8, 2000, 11:54 PM
 
I feel the same way. This outlet thing isn't quite right. The oulets should be initialized in the constructor with some form of magic method or something...anything is better than having it just work.

on another note: any idea how to keep the focus in a NSTextField?
     
eyadams  (op)
Dedicated MacNNer
Join Date: Oct 2000
Location: Pasadena, CA, USA
Status: Offline
Reply With Quote
Dec 11, 2000, 05:50 PM
 
Well, I posted more or less the same question to comp.sys.mac.programmer.help, and was eventually told that you can use normal accessors. So, instead of

> NSTextfield foo;

You can have

> public void setFoo(NSTextfield t) { /* whatever you want */ }

The only weirdness is with the case. In IB (and the generated class) you define your outlet with the first letter lower case; but after the word "set" in the accessor it has to be initial capped.

     
Senior User
Join Date: Nov 2000
Status: Offline
Reply With Quote
Dec 12, 2000, 04:53 PM
 
I'll give that a try since it makes more sense...thanks.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:20 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2