• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Applet help

 
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Candy Bortniker
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where should addMouseMotionListener(new MouseMotionHandler()); addMouseListener(new MouseHandler()); be?
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 123
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

This looks to be the same as:

which does nowt to topX and topY.
 
reply
    Bookmark Topic Watch Topic
  • New Topic