Another Simple Code Question... Please Help!

Hi!
I've stumbled across another problem with my coding, and I'm hoping that someone could help me out again. I've now got two classes, one with the code to draw a button, and the other which invokes the button and does a number of other things.
I'd like it so each button is assigned to a different sound, but I get these errors when I compile...
D:\java\Phone.java:8: cannot resolve symbol
symbol : class AudioClip
location: class Phone
private AudioClip sound1;
D:\java\Phone.java:64: cannot resolve symbol
symbol : variable myButton1
location: class Phone
if (event.getSource() == myButton1)
Could anyone suggest as to why this is?? Here is the source code (I've trimmed it down for the sake of these pages...)
>>>>>>>
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
public class Phone extends Applet implements ActionListener {
private Image image;
private AudioClip sound1;
public void init() {
setLayout(null);
image = getImage(getDocumentBase(), "phone.jpg");
sound1 = getAudioClip(getDocumentBase(), "sound.wav");
PhoneButton myButton1;
myButton1 = new PhoneButton(322,180, 1);
add(myButton1);
myButton1.addActionListener(this);
public void paint (Graphics g) {
g.drawImage(image, 0, 0, 700, 530, this);
super.paint(g);
public void actionPerformed(ActionEvent event)
if (event.getSource() == myButton1)
sound1.play();
>>>>>>>
Again, I'm sorry about the indentation.
Cheers in advance!

To answer your post...instance variables mean you should put your variable declarations
just below the class declaration like u have done with this...
public class Phone extends Applet implements ActionListener {
private Image image;
private AudioClip sound1;Just add here...
PhoneButton myButton1;
this.
That would make myButton1 an instance variable.
sorry, i don't understand. And now, since you've put up dukes for answering your question...you have to reward them
else they go waste. But only if you thought my reply was helpful to you. The choice is yours.
cheers.

Similar Messages

  • A very simple voicemail question - please help!

    Hi
    My iphone 3G cuts into voicemail after only 3 rings, which isn't enough time to get it out of my pocket let alone answer!!
    How do I lengthen the amount of rings before it goes to voicemail. I've tried everything (seemingly) and there doesn't seem to be any voicemail settings anywhere on the phone.
    Many thanks

    This is controlled by your carrier, not the phone. Most carriers have a max of about 30 seconds they can set before going to voicemail. Call your carrier and ask them to extend the time to voicemail.

  • What's wrong with my code? please help....

    when display button is clicked it must diplay the remarks but it didn't happen...
    what's wrong with my code? please help
    here is my code.....
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    public class Area extends Applet implements ItemListener,ActionListener
         {Label arlbl = new Label("AREA");
          Choice archc = new Choice();
          Label extlbl = new Label("EXPENDITURE TYPE");
          CheckboxGroup extchk = new CheckboxGroup();
              Checkbox fchk = new Checkbox("FOOD",extchk,true);
              Checkbox schk = new Checkbox("SHELTER",extchk,false);
              Checkbox echk = new Checkbox("EDUCATION",extchk,false);
              Checkbox uchk = new Checkbox("UTILITIES",extchk,false);
          Label exalbl = new Label("EXPENDITURE AMOUNT");
          TextField exatf = new TextField("",20);
          Label remlbl = new Label("REMARKS");
          TextField remtf = new TextField("",30);
          Button disbtn = new Button("DISPLAY");
          Button resbtn = new Button("RESET");
          String display;
          public void init()
              {add(arlbl);
               archc.add("MANILA");
               archc.add("MAKATI");
               archc.add("QUEZON");
               archc.add("PASAY");
               add(archc);
               archc.addItemListener(this);
               add(extlbl);
               add(fchk);
               fchk.addItemListener(this);
               add(schk);
               schk.addItemListener(this);     
               add(echk);
               echk.addItemListener(this);
               add(uchk);
               uchk.addItemListener(this);
               add(exalbl);
               add(exatf);
               add(remlbl);
               add(remtf);
               add(disbtn);
               disbtn.addActionListener(this);
               add(resbtn);
               resbtn.addActionListener(this);
         public void itemStateChanged(ItemEvent ex)
              {int n = archc.getSelectedIndex();
               if(n==0)
                   {if(fchk.getState())
                         {exatf.setText("10000.00");
                         display = archc.getSelectedItem();
                   if(schk.getState())
                        {exatf.setText("15000.00");
                        display = archc.getSelectedItem();
                   if(echk.getState())
                        {exatf.setText("24000.00");
                        display = archc.getSelectedItem();
                   if(uchk.getState())
                        {exatf.setText("8500.00");
                        display = archc.getSelectedItem();
              if(n==1)
                   {if(fchk.getState())
                        {exatf.setText("5000.00");
                        display = archc.getSelectedItem();
                   if(schk.getState())
                        {exatf.setText("11000.00");
                        display = archc.getSelectedItem();
                   if(echk.getState())
                        {exatf.setText("7500.00");
                        display = archc.getSelectedItem();
                   if(uchk.getState())
                        {exatf.setText("24000.00");
                        display = archc.getSelectedItem();
              if(n==2)
                   {if(fchk.getState())
                        {exatf.setText("13000.00");
                        display = archc.getSelectedItem();
                   if(schk.getState())
                        {exatf.setText("7000.00");
                        display = archc.getSelectedItem();
                   if(echk.getState())
                        {exatf.setText("27000.00");
                        display = archc.getSelectedItem();
                   if(uchk.getState())
                        {exatf.setText("6000.00");
                        display = archc.getSelectedItem();
              if(n==3)
                   {if(fchk.getState())
                        {exatf.setText("6000.00");
                        display = archc.getSelectedItem();
                   if(schk.getState())
                        {exatf.setText("9000.00");
                        display = archc.getSelectedItem();
                   if(echk.getState())
                        {exatf.setText("15000.00");
                        display = archc.getSelectedItem();
                   if(uchk.getState())
                        {exatf.setText("19000.00");
                        display = archc.getSelectedItem();
         public void actionPerformed(ActionEvent e)
              {if(e.getSource() == disbtn)
                    {String amtstr = exatf.getText();
                     int amt = Integer.parseInt(amtstr);
                        {if(amt > 8000)
                             {remtf.setText(display + " IS ABOVE BUDGET");
                        else
                             {remtf.setText(display + " IS BELOW BUDGET");
              if(e.getSource() == resbtn)
                   {archc.select(0);
                   fchk.setState(true);
                   schk.setState(false);
                   echk.setState(false);
                   uchk.setState(false);
                   exatf.setText("");
                   remtf.setText("");
    Edited by: lovely23 on Feb 28, 2009 11:24 PM

    Edit: thanks for cross-posting this question on another forum. I now see that I wasted my time trying to study your code in the java-forums to help you with an answer that had already been answered elsewhere (here). Do you realize that we are volunteers, that our time is as valuable as yours? Apparently not. Cross-post again and many here will not help you again. I know that I won't.

  • I want to change my apple id password but I forgot the security questions please help me some using my icloud I'd

    I want to change my apple id password but I forgot the security questions please help me some using my icloud I'd and if confirmation is must so please phone number is mine please send a code please help me my apple

    Welcome to the Apple community.
    If you are unable to remember your password, security questions, don’t have access to your rescue address or are unable to reset your password for whatever reason, your only option is to contact AppleCare, upon speaking to an operator you should explain that your problem is related to your Apple ID, this way you will not be charged for assistance, even if you don’t have an AppleCare plan.
    The operator will take you through some steps you may have already tried, however they need to be sure they have exhausted all usual approaches before trying to reset your account, so you should try to be helpful and show patience with the procedure.
    The operator will need to verify they are speaking to the account holder and may ask you some questions that only the account holder could know, and you will need to answer them if the process is to proceed.
    Once the operator has verified your identity they will send a message through to your device which contains an alpha numeric code, which you will need to read back to them.
    Once this has been completed they will send an email to your iCloud email address after a period of 24 hours, so you should check that mail is enabled in your devices iCloud settings.
    Upon receipt of the email, use the reset link provided to reset your password, after which you should be able to make the adjustments to iCloud that you wish to do.

  • I do forgot my Apple ID security question, please help me how to rescue email address or how to reset Apple ID security questions?

    I do forgot my Apple ID security question, please help me how to rescue email address or how to reset Apple ID security questions?

    From another post:
    On your browser, whether Safari, Google Chrome or otherwise, navigate tohttps://appleid.apple.com.
    Once here click Manage your Apple ID button and sign into your iCloud account. Here, on the left side select Password and Security and this will list options on the right side. You should be able to see an option to reset your security questions.
    Note other links in realtion to rescue email address:http://support.apple.com/kb/HT5312
    If you cannot see or reset your security question, or even obtaining an error, then you would have to contact Apple directly: http://support.apple.com/kb/HE57. Here you would explain the issue, transfer you to an Account Security Agent who will be able to veritfy your identity and assist you in the resetting of you security questions.

  • Hey. i just restored my iphone and now it says your apple id is disabled then i forgot everything about my email and security questions please help me enable my apple id

    hey. i just restored my iphone and now it says your apple id is disabled then i forgot everything about my email and security questions please help me enable my apple id
    i dont think there is another way to unlock my apple but i need to

    Hello there, Th3FoX98.
    The following Knowledge Base article is a great resource for what to do if you've forgotten the answers to your Apple ID security questions:
    If you forgot the answers to your Apple ID security questions
    http://support.apple.com/kb/HT6170
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • HT2968 I can not update several of my apps that i have purchased a while back in my Apps Store on my MacPro. Because it keeps using my old @me account for iTunes and i don't remember the password or security question, Please help?

    I can not update several of my apps that i have purchased a while back in my Apps Store on my MacPro. Because it keeps using my old @me account for iTunes and i don't remember the password or security question, Please help?

    Hi AlphaCentori,
    If you are having issues accessing the Apple ID that was used to originally purchase those apps, you may find the following article helpful:
    Apple Support: Rescue email address and how to reset Apple ID security questions
    http://support.apple.com/kb/ht5312
    Regards,
    - Brenden

  • Photoshop CS6 could not update successfully.  Error codes Adobe Photoshop 13.0.1.3 Installation failed. Error Code: U44M1P7  Extension Manager 6.0.8 Update Installation failed. Error Code: U44M1P7  Please help me figure out how to call customer service. 

    Photoshop CS6 could not update successfully.  Error codes Adobe Photoshop 13.0.1.3 Installation failed. Error Code: U44M1P7  Extension Manager 6.0.8 Update Installation failed. Error Code: U44M1P7  Please help me figure out how to call customer service.  I would prefer to talk to someone directly.

    Are you using any disk cleaner or optimization tools like CleanMymac or Mackeeper?
    Regards,
    Ashutosh

  • Why isn't my email verify even if I did it so many  times then it says your email is verify for another account can  someone please help me

    I created an apple ID with iTunes gift card
    Then i signed in
    I tried to download a game and it said that
    My email is not verifyed then I to verify it but
    It said that my email is already verifyed for another email
    Can someone please help me with this problem

    Make sure there is no other account using that email. (Try going to https://appleid.apple.com/cgi-bin/WebObjects/MyAppleId.woa/ hitting Reset your password, and then enter the email address.

  • My apple id have been blocked an i do not remember the identity or security question please help what can i do?

    my apple id have been blocked an i do not remember the identity or security question please help what can i do?

    If your account is disabled you might be able to re-enable it via this page : http://appleid.apple.com, then 'reset your password'
    You might then need to log out of your account on your iPhone and iPad by tapping on your id in Settings > iTunes & App Storeand then log back in so as to 'refresh' the account on it.
    For your security questions, if you have a rescue email address (which is not the same thing as an alternate email address) on your account then the steps half-way down this page will give you a reset link on your account : http://support.apple.com/kb/HT5312
    If you don't have a rescue email address then you will need to contact Support in your country to get the questions reset.
    Contacting Apple about account security : http://support.apple.com/kb/HT5699 (you can also try this link if you can't get your account enabled via the above)
    When they've been reset (and if you don't already have a rescue email address) you can then use the steps half-way down the HT5312 link above to add a rescue email address for potential future use

  • Cannot restore my brand new iphone 4s ,got stuck in DFU mode and itunes shows error code (-1) please help?

    Cannot restore my brand new iphone 4s ,got stuck in DFU mode and itunes shows error code (-1) please help?
    repeatedly tried from diffierent computers and the same error code pops up (error -1)

    That's a hardware problem which will require a trip to the Apple store for evaluation, unless your phone has been jailbroken, then it's a corrupt hosts file (and we can't help you with that here as it is against the forum's terms of use).

  • I cannot restore my Iphone 4, I keep getting the error code 1611, please help and the Iphone keeps displaying the "Plug-In Itunes Symbol!??

    I cannot restore my Iphone 4, I keep getting the error code 1611, please help and the Iphone keeps displaying the "Plug-In Itunes Symbol!??

    http://tinyurl.com/nyj36v

  • Hi, I have traveled the country and have forgotten my security questions please help me thank you

    Hi, I have traveled the country and have forgotten my security questions please help me thank you

    Call Apple to help reset your Security Question.
    http://support.apple.com/kb/HT5699

  • HT201303 I forgotten my answer of security questions, please help me. Thank you !

    I forgotten my answer of security questions, please help me. Thank you !

    You need to ask Apple to reset your security questions; as described in this article, it can be done in Vietnam by phoning 1-201-0288 and then 800-708-5413.
    (107433)

  • Why when I change my debit card banking details and the postal code of where I stay is rejected,yet I know it is the correct postal code?please HELP me.

    Why is it that when I'm changing my debit card details and my postal address I receive a message that says my postal code is not valid?and yet I'm certain of what my postal code is.Please help.Regards,

    Ztshosane wrote:
    ... I receive a message that says my postal code is not valid?...
    Try here  >  http://support.apple.com/kb/TS1646
    If necessary... Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

Maybe you are looking for

  • Not able to install BB Link - maybe solved for now

    Hi Guys,  first - please excuse my english if there are maybe some mistakes, it´s not my foreign language - i´m from Germany and want to give some response for all of those, who got the problem with the install-problem for this software. I also got t

  • Macbook Air can no longer find camera

    Kinda goofy, but I had covered the camera on my Macbook Air  (v. 10.7.5) awhile back and now Photo Booth, Ichat, and Skype all say that the camera is not connected.  (I did remove the cover first!)  Have tried all recommended fixes.  Thoughts?

  • Is this method good or I need to use another way

    I am making designing and developing my report in Report Builder 3.0 and by using this method http://technet.microsoft.com/en-us/library/aa337089.aspx I am showing the report in Windows Form. I want to know is this a right way or I have to use any ot

  • Using Tabs in Generated Pages - Validation Issue

    Hi, We're using JHS 10.1.3.0.97 and are using the "stacked" regions functionality to make the form less cluttered. The problem we're having now is that whenever a user wants to view the items on a tab (that is not currently the selected one), a valid

  • Why do some videos appear distorted or grainy?

    I have first generation iPad. Why do some videos appear distorted or grainy?  Is there a fix for this? I am using only WiFi portion of product.