aspose file tools*
The moose likes Beginning Java and the fly likes Wanted: Advise on threads and application layout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Wanted: Advise on threads and application layout" Watch "Wanted: Advise on threads and application layout" New topic
Author

Wanted: Advise on threads and application layout

Ed Patterson
Greenhorn

Joined: Aug 22, 2009
Posts: 3
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 :-).

Thanks,
Ed
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
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.

Best of luck!
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Well, unfortunately there is no easy or quick route here.

Java seems to be close to VB/Perl

Unfortunately that isn't true, not even close. Java is not a scripting language it is a full-fledged object oriented language.

If you want to learn it, Look here, start with the basics and proceed down the page. But a better option would be one of the many beginning books, like Head First Java.

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.


Steve
Ed Patterson
Greenhorn

Joined: Aug 22, 2009
Posts: 3
Steve Luke wrote:Well, unfortunately there is no easy or quick route here.
If you want to learn it, Look here, start with the basics and proceed down the page. But a better option would be one of the many beginning books, like Head First Java.

Amazon and I thank you, Head First Java, 2nd Edition is on the way.
Gerardo Tasistro
Ranch Hand

Joined: Feb 08, 2005
Posts: 362
For Swing I use JFormDesigner. It's going to cost you, but it's worth it. Or you can opt with Matisse. I believe it is free.

No regarding your questions. Combos don't have add/remove element. They need a model and that model handles the actual elements on the list.

For example:

Ed Patterson
Greenhorn

Joined: Aug 22, 2009
Posts: 3
Gerardo Tasistro: Thank you very much. This gives me a GREAT example to study.

New book came in the mail today: Pro Netbeans IDE 6 though from the advice I got here I will be shelving it until I get a better handle on syntax and supplied objects.

Ed
Nawapunth Manusitthipol
Greenhorn

Joined: Aug 14, 2009
Posts: 14
If you familiar with VB, try Gambas (Gambas Almost Means BASic). It's a VB wannabe for Linux.


Middle path.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Wanted: Advise on threads and application layout