First, let me apologize my rookie questions, but I am a rank beginner at
Macintosh coding. I'e got quite a few years of C coding experience, but
never attempted Java or anything object-oriented. I'm laid-up after
surgery and to amuse myself and learn I'm trying to write a simple Mac
app using Cocoa and Java. I've started with searching the net and new
groups, but in this case I haven't found a clear-cut example.
What I want to do is pre-load a pull-down menu with entries to allow
entering of dates and times. I've got the pull-downs setup in IB, but
can't figure out how to load the text values into them. For example, the
month pull-down should contain something like "Jan" in the top entry,
followed by "Feb", etc. Days should be "1", then "2", etc.
What I'm stuck at is finding a clear example of initializing the
pull-downs. It seems like an NSArray would do the trick, but I may be
missing the boat entirely. If someone has been through this can could
provide some direction, it would be greatly appreciated.
Thanks in advance...

Signature
-spiff
Never be bullied into silence. Never allow yourself to be made a victim.
Accept no one's definition of your life; define yourself.
David Phillip Oster - 23 Feb 2005 17:18 GMT
> What I'm stuck at is finding a clear example of initializing the
> pull-downs. It seems like an NSArray would do the trick, but I may be
> missing the boat entirely. If someone has been through this can could
> provide some direction, it would be greatly appreciated.
Do a google search for:
cocoa bindings controller popup sample code
and see what you get.

Signature
David Phillip Oster
matt neuburg - 23 Feb 2005 17:25 GMT
> What I want to do is pre-load a pull-down menu with entries to allow
> entering of dates and times. I've got the pull-downs setup in IB, but
> can't figure out how to load the text values into them. For example, the
> month pull-down should contain something like "Jan" in the top entry,
> followed by "Feb", etc. Days should be "1", then "2", etc.
You should read the manual on NSMenuItem, NSMenu, and (if this is a
popup button) NSPopUpButton, and look at the MenuMadness example code
that is already on your hard disk. m.

Signature
matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/
AppleScript: The Definitive Guide
http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
Read TidBITS! It's free and smart. http://www.tidbits.com
Patrick Machielse - 23 Feb 2005 17:49 GMT
> First, let me apologize my rookie questions, but I am a rank beginner at
> Macintosh coding. I'e got quite a few years of C coding experience, but
> never attempted Java or anything object-oriented. I'm laid-up after
> surgery and to amuse myself and learn I'm trying to write a simple Mac
> app using Cocoa and Java. I've started with searching the net and new
> groups, but in this case I haven't found a clear-cut example.
question: why not jump straight into Obj-C? There is much (much) more
documentation on Cocoa-ObjC than there exists on Cocoa-Java.
> What I want to do is pre-load a pull-down menu with entries to allow
> entering of dates and times. I've got the pull-downs setup in IB, but
> can't figure out how to load the text values into them. For example, the
> month pull-down should contain something like "Jan" in the top entry,
> followed by "Feb", etc. Days should be "1", then "2", etc.
1) Populate the month popup in IB. The # of months (probably) won't
change.
2) Populate the days popup by code. A strategy would be to populate the
days popup each time the selection in the month popup changes.
> What I'm stuck at is finding a clear example of initializing the
> pull-downs. It seems like an NSArray would do the trick, but I may be
> missing the boat entirely. If someone has been through this can could
> provide some direction, it would be greatly appreciated.
I don't use Cocoa Java, but it could be as simple as:
dayPopUp.removeAllItems();
dayPopUp.addItemsWithTitles(new NSArray(new String[]{"1", "2", "3"}));
where dayPopUp is the popup menu you made in IB.
As you can see it is a good idea to get to grips with creating and
manipulating objects before diving headlong into Cocoa. If you only know
C now, the fastest way to learn Cocoa would be to use the Apple Obj-C
tutorials (the infamous temperature converter...)
Good luck and get well soon...
patrick
CyberSpiff - 23 Feb 2005 18:03 GMT
[much good advice snipped]
Thank you all, David, Matt and Patrick. You're advice is excellent.
Thanks to you all (and Rhino from c.i.j.p in case you read this group
:-) ) I'm finally able to control the simple interface I have and am
ready to move onto more difficult (for me) things like file I/O and date
manipulation.

Signature
-spiff
Never be bullied into silence. Never allow yourself to be made a victim.
Accept no one's definition of your life; define yourself.