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 > Cocoa java: setIndicatorImage InTableColumn()

Cocoa java: setIndicatorImage InTableColumn()
Thread Tools
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status: Offline
Reply With Quote
May 28, 2002, 10:45 AM
 
Greetings,

I can't seem to find the method setIndicatorImage InTableColumn() in the Java API's? In Obj-C, it is in the NSTableView class? I did a search for the method in the JavaBrowser and still no luck.

Does anyone know why this isn't implemented in Cocoa Java? Or if it is, does it have a different name?

I would like to put the little triangles in one of my table columns where the user can sort entries.

Thanks,
Ian
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
May 30, 2002, 04:08 PM
 
You've learned your first important lesson about the ObjC-Java bridge: it's incomplete. There is no method to do so. It shouldn't be too hard to do manually, though. Just call headerCell() off of each of your tableColumns that you wish to have the arrow, and call setImage(NSImage). That should do the trick (I think). You shouldn't have to subclass NSCell or use one of the already created subclasses of NSCell, but you might, and then need to call setHeaderCell(NSCell).

HTH,
F-bacher
     
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status: Offline
Reply With Quote
May 30, 2002, 07:14 PM
 
Thank you for replying. So if I put an image in a header cell, will it automatically go in the far right corner? And if so, will it look okay with the text name of the column I put in using IB?

It seems a little unclear as to how much support Apple is going to give to Cocoa java. They created the Obj-C java bridge, but is still incomplete; and from what I heard about the WWDC 2002, Cocoa java was not talked about.
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
May 31, 2002, 12:15 PM
 
Support "exists," but not entirely. Part of the problem is that Java doesn't support categories like ObjC does, so you can't have anything like NSTableView Additions. They have to go write a whole new class (like they did with Graphics). I have no idea why this method wasn't there in the first place, but there is a sneaky way to get around it When I was still doing Java, I would run into problems on the Java side of the bridge which wouldn't happen on the ObjC side. But, it is possible to mix objC code and Java code in the same application. What you could do, is subclass NSTableView in ObjC. Create the instance in IB as normal, and create a reference to the table view in your java code. Now, when you call java methods off of the subclass, the bridge will properally forward them to the ObjC side, so if you were to override one of the methods in NSTableView on the ObjC side, you could call it on the Java side and have your custom implementation occur on the other side. You wouldn't be able to write your own methods for your subclass and call it from the java side, though, as the java side only knows about the methods of NSTableView. Because you can call superclass methods off of a subclass, this will work. It's REALLY hacky, and I avoid doing it if possible (well, I just use ObjC now), but it will work. If you'd like some more concrete examples of how this works, just post again and I'll follow it up with something clearer.

HTH,
F-bacher
     
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status: Offline
Reply With Quote
May 31, 2002, 07:22 PM
 
Thanks F-bacher. That does sound pretty darn hacky! As it is now, I have a java.lang.Object class set as my data source and delegate. In that class I have all kinds of methods that have to do with the table. So you are suggesting creating a subclass of NSTableView in Obj-C and making it the delegate, but keeping my java class the datasource?

I guess some more concrete examples would be nice. I am still a pretty novice programmer, so all of this info is really great!

Thanks again.
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Jun 2, 2002, 01:57 AM
 
Gwah! I can't believe I didn't think of using notifications sooner! it may not work across the bridge... but it might...

Here's what you can try: You're going to need the NSNotification and NSNotificationCenter class. NSNotificaionCenter.defaultCenter() should get you a reference to the default center. You're going to want to add an observer (your NSTableView instance), with a notification name of "MyNotification" (you can be more creative), selector with method signature setMyIndicatorImage with one argument of class NSNotification, and an object of this (you know which this I'm talking about <img border="0" title="" alt="[Wink]" src="wink.gif" /> ). Okay, in your subclass of NSTextView that you implement in objC, all you need to do is implement the method mentioned above in objC syntax such that it takes the NSNotication object that gets passed into it, gets its userInfo, obtains an NSImage and tableColumn name (or some other way of identifying table columns) from it, and then calls setIndicatorImage:inTableColumn: with appropriate data. Then, in your java code, simply post a notificaion to the default NSNotification center with the userinfo containing the NSImage you want displayed and the identifier for your table column, with a name as specified above.

Hmm... I understand all this but lost you 5 blocks ago <img border="0" title="" alt="[Wink]" src="wink.gif" /> I'll try to throw up some code tomorrow to see if this convoluted process even works.

F-bacher
     
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status: Offline
Reply With Quote
Sep 26, 2002, 11:01 PM
 
setIndicatorImage is available in Jaguar now.
     
   
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 03:05 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