Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 9 of 9

Thread: Attempting to get to next level in API

  1. #1
    Member
    Join Date
    Jul 2011
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Attempting to get to next level in API

    I'm not too bad using primitive variables, but I'm having a fairly rough time trying to productively use the API. An example it recently used TreeMap and it took me a while to discover that it made shallow copies. Examples had used string literals to put stuff into TreeMap, so when I used a variable, it was not obvious at first. In this case I put the stuff into two Vectors first (K & V) and then entered it into TreeMap, and this worked fine. Anyway, I'm bumping into stuff like type mismatches and syntactic subtlties all the time. It makes it hard to plan my code and finding work-arounds is nerve racking. Having to amke little programs to see if a work-around works gets discouraging.

    Books packed with running code examples are really helpful. My favorite author is Herb Schildt.

    Nevertheless, I feel somewhat at wit's end. Any suggestions helpful.


    TIA


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,298
    My Mood
    Hungover
    Thanks
    142
    Thanked 620 Times in 531 Posts

    Default Re: Attempting to get to next level in API

    I know you aren't going to like this, but the best way to learn the API is by using it. The Java tutorials contain tons of examples of how to use the API, you could try working through them. What kinds of programs have you been writing? Are you writing them for school, for your own interests, for work?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. The Following User Says Thank You to KevinWorkman For This Useful Post:

    meathead (October 7th, 2011)

  4. #3
    Member
    Join Date
    Jul 2011
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Attempting to get to next level in API

    Actually, that's the sort of crime & punishment answer I was pretty much expecting/fearing. I'll try to take the time and table my big project. My programs are for my interests, though I have been able to adapt my code for productive use by others at times. Sometimes what I write is usable at work, though only informally if and only if it will speed something up or do something that could not otherwise be done.

    My big project is a MARC file reader (ANSI/NISO Z39.2,ISO-2709) of bibliographic records--think online catalog technology on a modest scale. I had been working from the command line and have just upgraded to Swing and have been in the process of restoring functionality and moving to Java 1.6 from 1.4, which has been messing somewhat with the innards of the project. Over the longer haul this could be used for making call number labels, generating reports, running term paper bibliographies, or ultimately making a mini catalog suitable for personal collections of books, records, DVDs, etc. Sort of therapy for a librarian (me) & outrage over the cost of catalogs and the difficulty of implementing open source projects that do this sort of thing. Oh well, I easily get carried away ...

    Thanks for asking and the encouragement.
    Last edited by meathead; October 7th, 2011 at 03:40 PM.

  5. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,298
    My Mood
    Hungover
    Thanks
    142
    Thanked 620 Times in 531 Posts

    Default Re: Attempting to get to next level in API

    Quote Originally Posted by meathead View Post
    Actually, that's the sort of crime & punishment answer I was pretty much expecting/fearing. I'll try to take the time and table my big project. My programs are for my interests, though I have been able to adapt my code for productive use by others at times. Sometimes what I write is usable at work, though only informally if and only if it will speed something up or do something that could not otherwise be done.

    My big project is a MARC file reader (ANSI/NISO Z39.2,ISO-2709) of bibliographic records--think online catalog technology on a modest scale. I had been working from the command line and have just upgraded to Swing and have been in the process of restoring functionality and moving to Java 1.6 from 1.4, which has been messing somewhat with the innards of the project. Over the longer haul this could be used for making call number labels, generating reports, running term paper bibliographies, or ultimately making a mini catalog suitable for personal collections of books, records, DVDs, etc. Sort of therapy for a librarian (me) & outrage over the cost of catalogs and the difficulty of implementing open source projects that do this sort of thing. Oh well, I easily get carried away ...

    Thanks for asking and the encouragement.
    That sounds like a great project, but yeah, one common mistake in programming is biting off too much too early. Start with smaller programs that have less features or that focus one a single part of the API you're unfamiliar with. Maybe eventually you can adapt the smaller programs to be pieces of your big project.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  6. #5
    Member
    Join Date
    Jul 2011
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Attempting to get to next level in API

    At the command line using an old 1.4 I had lying around I had gotten to the point where I was retrieving records that I had indexed, an offshoot of having been making lists extracted from MARC files, which I had been doing for a while in a variety of languages. Then I coveted Swing. I have gotten to a point where I had strung together the components to get an index running as a for instance. There are two ways to get at a record

    1) put int into JTextField. Ignore if out of range, else put record into JTextArea.

    2) JList loaded with DefaultListModel which has read titles out of file. The first version I decided to just read the index from JList to get the int to retrieve the record, just to see if it works & worry about retrieving the correct record later. By luck, the sample file had been in order by title proper, of which there is exactly one per record. I was stunned when the record that popped out was the right one.

    The way I had ordered the titles and fed them into the JList in order was through my Index class, which uses a TreeMap. When the index is fully loaded, it contains other variant titles as well, so JList index won't work in the real version. The plan was to take the title from JList, feed it back into Index's TreeMap to get the associated <V>, which contains the int to feed into the class tending the file. Anyway, this bit of fancy footwork is went wrong.

    When I get it going I get to fill out the Index for title and create instances of Index for author, subject, ... etc. At that point I'll be back to where I was at with the console version. So, while the to do list is long, I try to remember to take one hill at a time. But ya, making the whole thing project driven sees to it I visit unfamiliar terrain pretty regularly. Although I did use the same GUI to make a little app for planning karate workouts.

  7. #6
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,298
    My Mood
    Hungover
    Thanks
    142
    Thanked 620 Times in 531 Posts

    Default Re: Attempting to get to next level in API

    You say you're using a JList, but it sounds like you have multiple columns of information. Have you looked into using JTables at all?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  8. #7
    Member
    Join Date
    Jul 2011
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Attempting to get to next level in API

    Quote Originally Posted by KevinWorkman View Post
    You say you're using a JList, but it sounds like you have multiple columns of information. Have you looked into using JTables at all?
    In some ways putting JTable would make sense for a number of indexes, until you consider that a bibliographic record is bumpy, irregular & comes in different sizes--kind of like an asteroid. The only thing you are guaranteed is the canonical title proper. Apart from that there may be several other forms of title, say 0-3, authors 0-3, subjects 1-3. If you repeat some fields for the benefit of putting others in context, you wind up with a variant of the "Mozart problem" where the information that is repeated in say author and title to include multiple subjects.

    The canonical style in computer catalogs is to have divided indexes for author/title/subject, which I think would be represented nicely by JLists on separate panes JTabbedPane. A side benefit is I get to use separate instances of the same object, promised by OOP, but which I don't get to do a whole lot.

    The chief alternative, seen sometimes in old card catalogs is to have author and title and subject entries sharing the same index. This would have the additional headache of making the same string file differently author or title or subject file differently depending on which they are. Fudging the comparator used for alphabeting would not be fun.

    Another style is to do a keyword style search, which comes from a JTextField, but under the surface the index is essentially the same. This style would be popular in Amazon or Google. The processing is steeper up front in index construction, and at the user end because users feel free to put more than one search term.

    I always visualized JTable as working especially well with SQL style database unique values (e.g. an address book table or a payroll table--payroll being part of a mess of tables potentilly ...)

    Examples of catalog:

    St. Louis Research Library Consortium

    Library of Congress Online Catalogs

    Sorry, I'm getting too geeky for sure.

  9. #8
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,298
    My Mood
    Hungover
    Thanks
    142
    Thanked 620 Times in 531 Posts

    Default Re: Attempting to get to next level in API

    Quote Originally Posted by meathead View Post
    Sorry, I'm getting too geeky for sure.
    Haha don't worry, you're in good company here. You're probably right about using a JTable, and you obviously know what you're talking about. Keep us updated on your progress, we love hearing about people's pet programs.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  10. The Following User Says Thank You to KevinWorkman For This Useful Post:

    meathead (October 12th, 2011)

  11. #9
    Member
    Join Date
    Jul 2011
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Attempting to get to next level in API

    Sure, will do! Thanks for the advice and suggestions.

Similar Threads

  1. Setting a transparency level of a picture issue
    By Asido in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 18th, 2012, 05:42 AM
  2. Program is attempting to change booleans yet the result is unsuccesful.
    By CoolGuy134 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 26th, 2011, 08:48 AM
  3. Custom Log level help
    By seanman in forum Java SE APIs
    Replies: 1
    Last Post: September 25th, 2011, 08:55 PM
  4. Quick, beginner-level Java question.
    By DHG in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 27th, 2011, 12:06 PM
  5. need help w/ entry level homework...
    By rbread80 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: October 3rd, 2010, 10:24 PM