Help with NSArray

C

CyberSpiff

[already posted to comp.sys.mac.programmer.help - sorry, but I just
found this newsgroup as well]

First, let me apologize for my rookie questions and possible breach of
protocol, but I am a rank beginner at Macintosh coding. I've 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 newsgroups, 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...
 
R

Rhino

CyberSpiff said:
[already posted to comp.sys.mac.programmer.help - sorry, but I just
found this newsgroup as well]

First, let me apologize for my rookie questions and possible breach of
protocol, but I am a rank beginner at Macintosh coding. I've 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 newsgroups, but in this case I haven't found
a clear-cut example.
Good for you for using your time so productively!
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.
I'm not familiar with the acronym 'IB'; I'm guessing it is your IDE.

It's not at all common to see people enter data via menu items; a menu is
typically used to take you to a dialog that prompts for dates, times, names,
numbers, etc. but the menu rarely asks this information directly.
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 see any class called 'NSArray' in the Java 1.5 API, nor do I see
anything that might normally be abbreviated that way, like "NameSpaceArray"
if there was such a class. Is this a non-standard class that isn't in the
standard API? If so, I can't comment on whether it is the best approach or
not.

My advice to you is to have a look at the Java Tutorial, particularly the
trail entitled "Creating a GUI with JFC/Swing", at
http://java.sun.com/docs/books/tutorial/index.html. That should do a good
job of guiding you through any GUI components you want to use, including
menus, Lists, and ComboBoxes. Initialization of Lists and ComboBoxes is
typically accomplished via Models, as you'll see in the tutorial.

Rhino
 
C

CyberSpiff

Rhino said:
[snip]

I don't see any class called 'NSArray' in the Java 1.5 API, nor do I see
anything that might normally be abbreviated that way, like "NameSpaceArray"
if there was such a class. Is this a non-standard class that isn't in the
standard API? If so, I can't comment on whether it is the best approach or
not.

My advice to you is to have a look at the Java Tutorial, particularly the
trail entitled "Creating a GUI with JFC/Swing", at
http://java.sun.com/docs/books/tutorial/index.html. That should do a good
job of guiding you through any GUI components you want to use, including
menus, Lists, and ComboBoxes. Initialization of Lists and ComboBoxes is
typically accomplished via Models, as you'll see in the tutorial.

Rhino

Rhino, thank you for your advice. It pointed me in the right direction.
I should have been more explicit in my original post. I'm using the
Xcode development system from Apple, and the NSArray is part of their
foundation classes (NS=NEXTStep?) (forgive me if my terminology is wrong).

Your suggestion to look for ComboBoxes was very helpful. I found an
NSComboBox class that does exactly what I needed.

Now, onto file I/O! :)

Thank you once again...
 
R

Rhino

CyberSpiff said:
Rhino said:
[snip]

I don't see any class called 'NSArray' in the Java 1.5 API, nor do I see
anything that might normally be abbreviated that way, like "NameSpaceArray"
if there was such a class. Is this a non-standard class that isn't in the
standard API? If so, I can't comment on whether it is the best approach or
not.

My advice to you is to have a look at the Java Tutorial, particularly the
trail entitled "Creating a GUI with JFC/Swing", at
http://java.sun.com/docs/books/tutorial/index.html. That should do a good
job of guiding you through any GUI components you want to use, including
menus, Lists, and ComboBoxes. Initialization of Lists and ComboBoxes is
typically accomplished via Models, as you'll see in the tutorial.

Rhino

Rhino, thank you for your advice. It pointed me in the right direction.
I should have been more explicit in my original post. I'm using the
Xcode development system from Apple, and the NSArray is part of their
foundation classes (NS=NEXTStep?) (forgive me if my terminology is wrong).
Thanks for the clarification ;-)

I'm not familiar with 'Xcode' and know precious little about Macs in
general. However, you may want to consider one thing before using these 'NS'
classes. There's nothing forcing you to use the two standard Java GUIs, AWT
and Swing/JFC, but if you don't use those two GUIs, your applications will
need to distribute the 'NS' classes with your application code so that other
users can run them; if you use AWT or Swing/JFC, you only need to distribute
your application and the GUI classes will already be present in the JRE
(Java Runtime Environment). Therefore, using 'NS' classes gives you a lot
more to distribute/install than if you used AWT or Swing/JFC. That could be
a major factor for you - or not.
Your suggestion to look for ComboBoxes was very helpful. I found an
NSComboBox class that does exactly what I needed.

Now, onto file I/O! :)

Thank you once again...
You're very welcome!

Rhino
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top