This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am slightly past the "Hello, World!" and simple math part of the learning curve.
Backstory: My wife got he hooked on Facebook, FarmTown and FarmVille. If you are not familiar with the Facebood apps, you get virtual farms to till, plant and harvest. Each crop has a time to haverst value, either in hours or days.
Being a computer person I immediately thought of an app that I could enter in what and when I planted and have it pop up a window when it is ready to harvest. Simple I thought. I did one in errrr VB and it worked quite well. Problem is thanks to Vista [end of MS bashing], all my machines except my server are now Ubuntu. So I figured Java would be the ticket. I could write it and if it worked, post if for all my 'friends' to use. Java seems to be close to VB/Perl and using Netbeans is a lot easier than Tk so...
First problem: Populating a listbox in swing. I can not find any kind of listbox.add, listbox.remove or listbox.delete. All the example for manipulating the listbox are so cryptic that the leave me more confused than when I began.
Second problem: Threads. There are numerous example of creating threads, all of which use fixed values to sleep. I creating a functin (class?) that accepts a string and int. the int is the time to sleep and the string is the name of the crop it is time to harvest.
I like Netbeans for the simplicity of building the user interface but I find the code completion part lacking/confusing
Ideas? Pointers to books? I bought the Definitive Guide to Java Swing naively thinking it would cover Netbeans (newbie, remember). It is just like my Tk books, type a million lines to get a textbox and button 'somewhere' on the screen :-).
Hello and welcome to the forum. Hope you like it here.
I think that many here will tell you that if you want to learn how to do things in Swing, you'd be best served to create your own Swing apps, to use NetBeans as an IDE (and it's a fine one), but not as a code generator. So, go ahead and pick up that Swing book, take a look at the Sun Swing Tutorials, take a look at the Java API, learn Swing and have fun.
For threading and Swing, have a look here: Concurrency in Swing. You may want to study and learn basic Swing first though.
As for Threads - don't use them yet. Not until you understand other aspects of programing in Java. For your situation a Timer would be appropriate (it uses Threads but you don't have to worry about managing them).
My suggestion is to drop using NetBeans, it is seductive to use an IDE at the start but it ends up being an impediment as you have to learn the application at the same time that you are learning the language.