aspose file tools*
The moose likes Beginning Java and the fly likes Applet help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Applet help" Watch "Applet help" New topic
Author

Applet help

Candy Bortniker
Ranch Hand

Joined: Mar 17, 2003
Posts: 123
I am just learning Java and I found this site while searching for help. I am so glad I found you. I am taking a course in college to learn Java. My instructor has given us an assignment to write an applet and to change the code of one of our projects to work with the applet. The first applet is suppose to pass any arguments. It sounded really simple but I find myself completely lost. Can you offer any suggestions that would help?
Here is the applet:
<applet code="BallProject.class" width = "800" height = "400">
</applet>
Here is the code:
[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ March 20, 2003: Message edited by: Dirk Schreckmann ]
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
You have quite a bit of code there. What exactly are you lost about? It seems that you've put most of it together. I can't compile the code currently, but if you explain what happens when you do, and what happens when you run it, there are many people here that will be willing to help you out.
Good luck!
Layne


Java API Documentation
The Java Tutorial
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Candy,
First off please don't post the same topic in multiple forums.
Now to your code. You have quite a few problems here. For one thing, in the BallProject class you are calling addMouseMotionListener(new MouseMotionHandler()); MouseMotionHandler is a private inner class of the package level class BallPanel. BallProject does not have access to that class. I think you have gotten confused as to what needs to be done here. Just looking at the code it looks like you need to create a BallFrame (which BTW should extend JPanel or some other component or you won't be able to add it to your content pane) in the BallProject constructor and add that to its content pane. In the BallFrame constructor you need to create one (or two, it isn't clear from your code) BallPanels and add it (them) to the BallFrame's layout. Try doing that and if you need more help, just post back.
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Candy Bortniker
Ranch Hand

Joined: Mar 17, 2003
Posts: 123
Where should addMouseMotionListener(new MouseMotionHandler()); addMouseListener(new MouseHandler()); be?
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Well, since MouseMotionHandler and MouseHandler are private member classes of BallPanel, I should assume it would go there.
[ March 19, 2003: Message edited by: Michael Morris ]
Candy Bortniker
Ranch Hand

Joined: Mar 17, 2003
Posts: 123
Thank you for your help. I've gotten to where the panel will show with the ball but I can't drag it. Any suggestions?
[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ March 20, 2003: Message edited by: Dirk Schreckmann ]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Candy,
When posting code, please be sure to surround the code with the [code] and [/code] UBB Tags. This will help to preserve the formatting of the code, thus making it easier to read and understand.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729

This looks to be the same as:

which does nowt to topX and topY.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Applet help