Click to See Complete Forum and Search --> : The New LNO Java Programming Challenge Web Site
Dru Lee Parsec
06-28-2001, 01:11 PM
Hi Folks.
Well, I just sat down and made myself find the time to to this right. :) So I now have a new section on my web site for :
The LNO Java Programming Challenge. AND
One Hour Wumpus
I got the kitchen timer and re-wrote "Hunt The Wumpus" while timing myself to see how long each section took. The new web site has each step describes along with the source code and the time it took to write the code. Did I make it in under an hour!? Check out the web page and find out.
The web site is at my personal web page of www.brouelette.com (http://www.brouelette.com)
Please post any questions about your own "Java Hunt The Wumpus" program here in the programming forum of LNO. I'll do what I can to help you find a solution (Although nanode and Brian are certainly welcome to help out if things get too busy) ;)
This is my Summer Solstice gift from Dru Lee Parsec to the programming folks at LNO. Hope you enjoy it. :D
cool :)
I just wrote my first swing program. A cheezy "who wants to be a millionaire" clone for class. Swing is nice..
Is there anyway to write a program so that the same source file can be used as both an applet and an application? If not, is there a reason why not, or just because it wasn't implemented? Seems like that would be really cool.
Dru Lee Parsec
06-28-2001, 06:04 PM
Yes there is. You make your class extend JApplet. Then you also add a main method. Inside the main method you construct a JFrame and put an instance of the applet (itself) in the frame. Then just call the init and start methods of the applet and then call setVisible(true) on the JFrame.
Bruce Eckel's book as an example of this in chapter 13 (I still have the first edition, it may be a different chapter in the 2nd edition). You can go to www.bruceeckel.com (http://www.bruceeckel.com) and get the source code.
cool :) Another java Q, dru... this one's on jar files. I've jar'd up my first swing program, using the 'Main-class' tag in the manifest. That works, and the jar file executes properly.. kinda. The issue is that the application uses subfolders for such things as image resources. Those folders & files were included in the jar file (not using the '-C' tag, so the directory structure was maintained). Now, the problem is that the application, when executed from the jar file, looks in the filesystem that the jar file is in for those resources, instead of in the jar file (where I would like it to look, obviously). So, for example, if the jar file is in a directory with no subfolders, the images will not show up, but if it's in a dir that has the proper subfolders (if, for example, the jar file had been extracted already), it will use those and find the images. See what I mean? In essence, when I execute a jar file, I'd like it to use the images stored in that file as it's resources. How can I do this?
TheLinuxDuck
06-29-2001, 11:36 AM
Thinking in Java- http://www.arirom.com/eng/javaInternet/Chapter13.html
Here's the place I go.. it's 2dn edition, revision 11.. I think the latest... (^=
http://www.arirom.com/eng/javaInternet/Contents.html
Here's the full TOC.
Dru Lee Parsec
06-29-2001, 12:08 PM
Re: Images
I always put my images in a subdirectory just to keep my file structure organized. Are you using ClassLoader.getResource(String) to get your images out of the jar? Check out the ImageLoader class in my Wumpus.jar code for an example.
BTW, re: main-class in a manifest file. Did you know that if you forget to put a carriage return at the end of the main-class line then java won't see it? Can you say "THAT'S A BUG!"
I'm off to go camping for a couple of days. See you guys on Monday.
Dru Lee Parsec
07-02-2001, 10:52 AM
bump
OK guys, I'm back. Let's get coding. :D
TheLinuxDuck
07-02-2001, 02:28 PM
Dru:
I'm working on a version of HTW, however, I'm taking my time, trying to make it very OO. Hopefully, I'll be able to reuse some of the classes for other things down the road. (^=
I'm also trying to make sure and include the javadocs and the like. If I stick with java for a year, I imagine I'll be quite a bit better than I am now. (^= At least, I better be!
Stuka
07-02-2001, 10:26 PM
Dru-
I was checking out your site the other day, and it made me sorta tingly - I'd actually had some of the same ideas about how to set the game up. Of course, my total lack of knowledge regarding Java makes it more difficult to implement, but at least I'm on the right track. Hopefully after I finish this paper, I'll have some free time to play with the idea. I really need a decent reference on Swing - and while the online stuff is good, the old fashioned part of me likes paper for reference :D Anyone know a good reference book for Swing code?
Dru Lee Parsec
07-03-2001, 12:03 PM
Hmm, I learned it from the Java API docs and from working under a really good Gui designer.contractor.
When I need a reference I usually go to the Java Tutorial http://java.sun.com/docs/books/tutorial/uiswing/components/index.html
I don't have them, but I hear that "Java Swing" by Robert Eckstein and "Graphic Java 2, Volume 2, Swing" by David M. Geary are both suppose to be pretty good.
nanode
07-03-2001, 04:23 PM
re: Swing.
There are situations where the docs, APIs and tutorials don't have the answer. Most of those are highly specific and won't be an issue for people just starting out.
As you learn java better, coming up with solutions is easier. If you get proficient using SWING and AWT events, then you will learn tons about the Java language. SWING will introduce all kinds of design patterns and implementation techniques.
"Definitive Guide to Swing" - Zukowski
has good explanations to event models, and SWING components. I recommend going to a bookstore and just reading chapters 1 & 2 - then use the resources Dru Lee posted to go from there. :)
Stuka
07-03-2001, 09:08 PM
I'm not knocking the API documentation - it's very good. I guess I'm looking for some introductory stuff - more like what Dru Lee posted at CCAE, for example, but with a bit more explanation. All of my GUI coding to date has been done w/MFC, which does a lot of the dirty work for you, so I really need to get my hands dirty in doing the event hooks etc. I understand the theory, but the placement - for example, what is the best place to listen for a button press? Does that depend on what I want it to do? Those are the things that have me asking questions now.
gary_r_james
07-03-2001, 09:40 PM
If you are looking for a good Java book, Thinking in Java by Bruce Eckel gets great reviews from nearly everyone. Also the certification guide The Complete Java 2 Certification Study Guide: Programmer's and Developers Exams by Simon Roberts, Philip Heller, Michael Ernest, Roberts et al is a great book. Neither is a swing book but the second does a great job of teaching the concepts of layout managers. It is also the best book if you are considering certificaion.
Gary
Dru Lee Parsec
07-03-2001, 10:05 PM
OK, here's how I learned it from my guru. (This is going to sound very familier to nanode because it's the way we did it together at KES).
Every class that I write that extends a Swing class (for example if I have a cool dialog that extends JDialog) has a constructor. In that constructor I always have the same code:
public CoolDialog(Frame parent){
super(parent);
buildUI();
buildListeners();
}
Later in the code I have a private void buildUI() method that sets up all the GUI. But it doesn't hook up the listeners.
Then I have a private void buildListeners() method that hooks up the listeners to each of the gui components (which I know exist now because I'm calling this AFTER the buildUI() method).
The individual listeners in the buildListeners method call a set of other methods that I usually name do[something]. So a search button will have an action listener that calls the doSearch() method, an Open File button will have a listener attached that calls the doOpenFile() method and so on.
Once you start breaking it down it actually becomes pretty simple. You can have incredibly intelligent GUI components with lots of functionality and yet everything is in a place that makes sense.
Hope that helps.
So, is anyone working on their Wumpus program??? :)
Dru Lee Parsec
07-10-2001, 04:56 PM
Bump.
Any takers? This could be a fun project.
Stuka
07-10-2001, 05:09 PM
Well, I was working on this, but I've had a new fun-filled job dropped in my lap at work, and I'm trying to teach myself PHP and MySQL connectivity (OK, actually just learning SQL for real, instead of MS Access crap :rolleyes :) which really means I'm relearning HTML cuz I've been away from it for a while, and so other programming things have been put on hold. Oh, well, one of these days I'll finish it!
TheLinuxDuck
07-11-2001, 09:00 AM
Dru:
I'm still working on mine!!!
See... here's the thing.. I'm trying to make this have a completely reusage map class that allows the creator to design and implement any type of map setup they want. It also will have it's own random map building function.
Because of these things, I'm having to learn alot and really get detailed in some of the code.
So, mine will take a while. But, I am still working on it, albeit slowly.. (^=
My hope is to dazzle you. (^=
Gimme a few days dru, I've got my final exam tonight... i dunno, though. I really want to write a tetris applet. ..ah, being able to play tetris from anywhere in the world. :sigh: :) Uh, yeah, well I finally got one of those "online" things at home, you know "THE AOL", so now that I'm on the online I can internetwork throughout the world and.. oh sorry. :) I finally got roadrunner at my new place, so I'll be able to play around with stuff at home more, so maybe I'll do it. :D God, this whole post was useless wasn't it? Sigh, it's to early.
TheLinuxDuck
07-11-2001, 09:42 AM
Originally posted by kmj:
<STRONG>God, this whole post was useless wasn't it? Sigh, it's to early.</STRONG>
We've all pretty much gotten accustomed to that.
::hiding::
Dru Lee Parsec
07-11-2001, 11:36 AM
KMJ!!!!
You have THE AOL!!!!??
Sweet God in heaven.
Dood! U R So 1337 !!!!!!!!!!
:D