This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Swing/Applet question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing/Applet question" Watch "Swing/Applet question" New topic

Swing/Applet question

Chris Stewart
Ranch Hand

Joined: Sep 14, 2002
Posts: 184
I'm doing a homework assignment (not due until the 26th) and I've run into a problem with the display. The homework is to code an applet that uses the JOptionPane object showing the user some messages and allowing text input. There is also a number guessing game involved (the project reqs, I know how to do everything this project asks, I'm just having an issue with the display.
Just to let you all know, I really only have to use the JOptionPane object to do all of the given tasks, but our professor said if we do extra stuff with the homework we'll get really high grades (i.e., 110 out of 100). So I wanted to create a nice looking swing application containing objects for each aspect of the project (a label for the current amount of money in your account, a label showing the option screens as you encounter them, etc). The problem is I'm not able to view the JPanel code when I view it on my webspace. If I run my program in JBuilder, everything runs and shows up fine. When I run it in IE from my webspace, the login part runs fine but when it should show the panel, submit button, and such it doesn't. Can anyone please look over this and tell me why this happens?
Here is my applet in current form: - btw, the password is casino.
Here is the code:

[ February 15, 2003: Message edited by: Chris Stewart ]
[ February 15, 2003: Message edited by: Chris Stewart ]
Chris Stewart
Ranch Hand

Joined: Sep 14, 2002
Posts: 184
Damn, I feel like a moron. When I compiled, it created two class files (Hw2Casino$1.class and Hw2Casino.class). When I uploaded to my webspace, I only uploaded Hw2Casino.class. After uploading the second one, everything works out fine.
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Glad we could help
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299

It's usually a good idea to use a JAR file when delivering applets. That way, as long as you JAR'd all the classes, you only have one file to upload to the web server.
Additionally, I would suggest using Java Web Start (JWS) instead of an applet. I realize this was a homework assignment and you were required to use an applet, but JWS apps are much more efficient and they perform better than applets.
Let me know if you would like any additional information.
BTW - I often post questions and realize I made a stupid mistake, luckily before anyone repsponds pointing out my idiotic mistake. So don't be too hard on yourself.

GenRocket - Experts at Building Test Data
Chris Stewart
Ranch Hand

Joined: Sep 14, 2002
Posts: 184
Thanks guys.
I got a good ways into what I wanted to do today, but I ran into an issue. I need help capturing the events from the submit button. I really can't figure out how to handle that. I went ahead and started to code just the bare reqs of my homework (in case I don't get the "fluff" version finished). Could anyone help me understand how I can handle this?
Bare req code:

Here is how far I got with the "fluff" version.
I agree. Here's the link:
subject: Swing/Applet question
Similar Threads
Creating and opening a window if the button is clicked in an applet
JSplitterView treats panes differently
Mouse shift event coding - to trigger a predetermined sequence of images to a GUI
Not refreshing...