Newbie question II - Still need help........

Thanks! But I'm still lost.....
Here's my entire program...
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class Lab10 extends Applet implements ActionListener {
private Button plusOne;
private Button minusOne;
private Button reset;
int buttonCount=0;
private Color myColor = Color.blue;
//Color myColor = Color.red;
public void init() {
Button plusOne=new Button ("Increase count by one");
add(plusOne);
plusOne.addActionListener(this);
Button minusOne=new Button ("Decrease count by one");
add(minusOne);
minusOne.addActionListener(this);
Button reset=new Button ("Reset the count");
add(reset);
reset.addActionListener(this);
add(plusOne);
add(minusOne);
add(reset);
}//end of init
public void paint(Graphics g){
g.setColor(myColor);
g.drawString("The count is:"+buttonCount+".",50,50);
}//end of paint
public void actionPerformed (ActionEvent e){
if (e.getSource()==plusOne); {
buttonCount=buttonCount+1;
g.setColor(myColor);
myColor=Color.blue;
else (e.getSource()==minusOne);{
buttonCount=buttonCount-1;
g.setColor(myColor);
myColor=Color.green;}
else {
(e.getSource()==reset);{
buttonCount=0;
g.setColor(myColor);
myColor=Color.red;}
}//end of else
}//end of if
}//end of actionPerformed
}//end of class Lab10
I'd appreciate any help!!!!!!!!!!!!!!!!!!!! Still getting the variable g error too!
Thanks

Hi!
In the actionPerformed method, you are trying to access a variable named "g" which is only accesible by the paint method. The point is that you CANT use g on actionPerformed.
To solve your problem, just delete the line where it says:
" g.setColor(myColor); "
Also take the semicolon out on every "if clause", like this one:
" if (e.getSource()==plusOne); { "
and finally...
after the line:
" myColor=Color.blue; "
just type:
repaint();
That way, you will call the paint method automatically, which is exactly what you need.
It should look like this:
if (e.getSource()==plusOne)
buttonCount=buttonCount+1;
//g.setColor(myColor);
myColor=Color.blue;
repaint();
Ok, that should do it. Take care and hope it works!!

Similar Messages

  • Easy questions, but still need help!

    The first question is how do I change a ring tone? I have been able to change the ring tone before, but sometimes the ring tone doesn't even play. Instead of a ring tone playing, I get the phone vibrating. Is there something I must disable for the ring tone to play? Also, is there a way to change text messages alert as well? I also get vibrate on that one.
    The 2nd question is about the camera. When I take a photo on the camera, the image comes out distorted. Not the real image, but the preview of it. It seems stretched out. I think that's actually how it's suppose to be, but is there a way to change that?
    3rd question: is there a way I can add an e-mail to the address book? To text images to my e-mail mostly. If so, would they charge me for that (am thinking if texting to your e-mail is considered using internet or something like that).

    1st question, go to "profiles" it should look like a speaker.  Select which one you want.  If you choose loud it will vibrate for a second and then ring.
    2nd question, my camera sucks so I have never even really used it.  As much as I love my phone, the camera is the worst.  Sorry, can't help you there.
    3rd question, click on the contact you want to add the additional email to, select menu, edit, then menu again, choose "add email address" and type it in.
    I hope this helps. 

  • HT5312 I forgot my answers to my security questions? I need help ASAP

    I forgot my answers to my security questions? I need help ASAP

    You need to ask Apple to reset your security questions; ways of contacting them include clicking here and picking a method for your country, phoning AppleCare and asking for the Account Security team, and filling out and submitting this form.
    They wouldn't be security questions if they could be bypassed without Apple verifying your identity.
    (102690)

  • Still need help with flash player download

    I'm still having a problem with the flash player, please read my last post below:
    "I've tried everything here & still can't download the flash player. Anytime I try to download it asks me to install ADM add-on and then when I click on that, my computer freezes. How do I enable this add-on without my computer freezing? Can anyone help pls?"

    Thanks a lot for your help, it is truly appreciated.
    Date: Thu, 29 Oct 2009 18:52:38 -0600
    From: [email protected]
    To: [email protected]
    Subject: Still need help with flash player download
    You can set Flash Player to check for updates on the Global Settings Manager panel:
    http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager05.htm l
    >

  • Still need help with case sensitive strings

    Hello guy! Sorry to trouble you with the same problem again,
    but i still need help!
    "I am trying to create a scrypt that will compare a String
    with an editable text that the user should type to match that
    String. I was able to do that, but the problem is that is not case
    sensitive, even with the adobe help telling me that strings are
    case sensitive. Do you guys know how to make that comparison match
    only if all the field has the right upper and lower case letters?
    on exitframe
    if field "t:texto1" = "Residencial Serra Verde"then
    go to next
    end if
    end
    |----> thats the one Im using!"
    There were 2 replys but both of them didnt work, and the
    second one even made the director crash, corrupting even previously
    files that had nothing to do with the initial problem..
    first solution given --
    If you put each item that you are comparing into a list, it
    magically
    makes it case sensitive. Just put list brackets around each
    item.
    on exitframe
    if [field "t:texto1"] = ["Residencial Serra Verde"] then
    go to next
    end if
    end
    Second solution given--
    The = operator is not case-sensitive when used on strings,
    but the < and > operators are case-sensitive.
    So another way to do this is to check if the string is
    neither greater than nor less than the target string:
    vExpected = "Residencial Serra Verde"
    vInput = field "t:texto 1"
    if vExpected < vInput then
    -- ignore
    else if vExpected > vInput then
    -- ignore
    else
    -- vExpected is a case-sensitive match for vInput
    go next
    end if
    So any new solutions??
    Thanks in advance!!
    joao rsm

    The first solution does in fact work and is probably the most
    efficient way
    of doing it. You can verify that it works by starting with a
    new director
    movie and adding a field named "t:texto1" into the cast with
    the text
    "Residencial Serra Verde" in the field. Next type the
    following command in
    the message window and press Enter
    put [field "t:texto1"] = ["Residencial Serra Verde"]
    You will see it return 1 which means True. Next, make the R
    in the field
    lower case and execute the command in the message window, it
    will return 0
    (true).
    Now that you know this works, you need to dig deeper in your
    code to find
    what the problem is. Any more info you can supply?

  • I still need help with the Dictionary for my Nokia...

    I still need help with the Dictionary for my Nokia 6680...
    Here's the error message I get when trying to open dictionary...
    "Dictionary word information missing. Install word database."
    Can someone please provide me a link the where I could download this dictionary for free?
    Thanks!
    DON'T HIT KIDS... THEY HAVE GUNS NOW.

    oops, im sorry, i didnt realised i've already submitted it
    DON'T HIT KIDS... THEY HAVE GUNS NOW.

  • Loading External SWF Files: Making Things Simple... Still need help here =)

    Hello everyone! First of all, sorry for my english... I'm Brazilian and english is not my first language.
    This is my first post meant to be my first post and I'm learning AS3. Didn't know about this forum but now I hope to have the time to visit it a lot to help and be helped! =)
    Well, I'm trying to import some external files to my main flash file with buttons. Yes, this is a newbie question, but I'm learning... I click button 1 and content 1 is loaded, click button 2 and content 2 is loaded, and so on. So, I got two ways for doing it:
    edit: The code below is working fine now...
    montreal.addEventListener(MouseEvent.MOUSE_UP, loadCity);
    dublin.addEventListener(MouseEvent.MOUSE_UP, loadCity);
    sydney.addEventListener(MouseEvent.MOUSE_UP, loadCity);
    var box:MovieClip = new MovieClip();
    addChild(box);
    box.x=20;
    box.y=20;
    function loadCity (event:MouseEvent):void {
        var currentCity = event.target.name;
        // remove all the children of the box
        while (box.numChildren > 0) {box.removeChildAt(0);}
        var swfRequest:URLRequest=new URLRequest(currentCity+".swf");
        var swfLoader:Loader = new Loader();
        swfLoader.load(swfRequest);
        box.addChild(swfLoader);}
    The problem with this first option is that whenever I click a button, it don't renew the content of the "box"... instead, the content loaded is stacked over the last one and I don't know how to clean it... The user Andrei did the trick with the "while statement" so the above code is working but I don't know how to use tween with it...
    So here comes the second option:
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    montreal.buttonMode=true;
    dublin.buttonMode=true;
    sydney.buttonMode=true;
    rio.buttonMode=true;
    paris.buttonMode=true;
    london.buttonMode=true;
    home.buttonMode=true;
    var box:MovieClip = new MovieClip();
    addChild(box);
    box.x=20;
    box.y=20;
    var cityLoader:Loader = new Loader();
    var cityURL:URLRequest=new URLRequest("montreal.swf"); //I use this to show a city when the site is opened
    cityLoader.load(cityURL);
    box.addChild(cityLoader);
    **Here I add the listeners to button, each one calling its own function like:
    montreal.addEventListener(MouseEvent.CLICK, loadMontreal);
    function cityTweens():void {
        var cityIn:Tween = new Tween(box, "y", Strong.easeOut, -350, 20, 1, true);}
    function loadMontreal(event:MouseEvent):void {
        var cityURL:URLRequest=new URLRequest("montreal.swf");
        cityLoader.load(cityURL);
        cityTweens();}
    function loadDublin(event:MouseEvent):void {
        var cityURL:URLRequest=new URLRequest("dublin.swf");
        cityLoader.load(cityURL);
        cityTweens();}
    function loadSydney(event:MouseEvent):void {
        var cityURL:URLRequest=new URLRequest("sydney.swf");
        cityLoader.load(cityURL);
        cityTweens();}
    function loadRio(event:MouseEvent):void {
        var cityURL:URLRequest=new URLRequest("rio.swf");
        cityLoader.load(cityURL);
        cityTweens();}
    function loadParis(event:MouseEvent):void {
        var cityURL:URLRequest=new URLRequest("paris.swf");
        cityLoader.load(cityURL);
        cityTweens();}
    function loadLondon(event:MouseEvent):void {
        var cityURL:URLRequest=new URLRequest("london.swf");
        cityLoader.load(cityURL);
        cityTweens();}
    function loadHome(event:MouseEvent):void {
        var cityURL:URLRequest=new URLRequest("home.swf");
        cityLoader.load(cityURL);
        cityTweens();}
    Well, the second option "is" working but I have some problems with the Tween... I have to wait the tween to finish before clicking another button or the tween will bug... I don't know how to disable the buttons until the tween is finished =/
    Now, I used to have one tween for each function but now I got it inside a function and just call it inside each function. Simple for you but I was like WOW when I had the idea and put it to practice! But I'm still repeating a lot of codes here with the "cityLoader.load(cityURL);" but when I try to put it inside the function "cityTweens" it will just open the Montreal City, maybe because I'm calling it as soon as the site opens...
    I'm almost sure I can make things simple, like mixing the idea of the first code (currentCity+".swf") so I don't need to call a function for each button. I just don't know how to do it...
    Could anyone help me? I'll also be VERY happy if you point me to any tip like good practices that I'm not following.
    Thanks in advance!
    Message was edited by: newToAS3

    As I said in your previous post, removing the child would not do the trick. Technically, you need to remove it after the tween is finished.
    In any case there are several issues with how you approach the whole thing. First of all, if you target your application to be on Internet - swf loading will not happen instantly - thus you, perhaps, need to consider waiting for swfs to be loaded before you doing anything with them. But if you just do it on local machine - you don't really need for them to show up. On the other hand, even with local environment it makes sense to take into account asynchronous/unpredicatable nature of external file loading.
    Also, your code can be more comact and the same functionality delegated to a single function. The code below demonstrates one of the ways. This is not the bes way though because it forces to load objects again although they were loaded already. But this is another story. I did not check code in action, of course (this is just an idea) - it is up to your to work out bugs:
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    import fl.transitions.TweenEvent;
    import flash.display.DisplayObject;
    import flash.display.Loader;
    import flash.events.Event;
    montreal.buttonMode = true;
    dublin.buttonMode = true;
    sydney.buttonMode = true;
    rio.buttonMode = true;
    paris.buttonMode = true;
    london.buttonMode = true;
    home.buttonMode = true;
    var box:MovieClip = new MovieClip();
    addChild(box);
    box.x=20;
    box.y=20;
    var cityLoader:Loader = new Loader();
    // this line will allow to wait untill content is loaded
    cityLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
    var cityURL:URLRequest = new URLRequest("montreal.swf"); //I use this to show a city when the site is opened
    cityLoader.load(cityURL);
    // don't need the following line
    // box.addChild(cityLoader);
    // make it a single listener
    montreal.addEventListener(MouseEvent.CLICK, loadSWF);
    dublin.addEventListener(MouseEvent.CLICK, loadSWF);
    sydney.addEventListener(MouseEvent.CLICK, loadSWF);
    rio.addEventListener(MouseEvent.CLICK, loadSWF);
    paris.addEventListener(MouseEvent.CLICK, loadSWF);
    london.addEventListener(MouseEvent.CLICK, loadSWF);
    home.addEventListener(MouseEvent.CLICK, loadSWF);
    // the single function handles all the loading
    function loadSWF(e:MouseEvent):void {
         switch(e.currentTarget) {
              case montreal:
                  cityURL = new URLRequest("montreal.swf");
              break;
              case dublin:
                  cityURL = new URLRequest("dublin.swf");
              break;
              case sydney:
                  cityURL = new URLRequest("sydney.swf");
              break;
              case rio:
                  cityURL = new URLRequest("rio.swf");
              break;
              case paris:
                  cityURL = new URLRequest("paris.swf");
              break;
              case london:
                  cityURL = new URLRequest("london.swf");
              break;
              case home:
                  cityURL = new URLRequest("home.swf");
              break;
         cityLoader.load(cityURL);
    function onLoadComplete(e:Event):void {
         loadedContent = e.target.content;
         // assuming that previous content will be moved out -
         // place new content behind previous one
         box.addChildAt(e.target.content, 0);
         // now you can start tweening
         // if there are more than one child
         if (box.numChildren > 1) {
              cityTweens();
    function cityTweens():void {
         // tween the topmost object
          var cityIn:Tween = new Tween(box.getChildAt(box.numChildren - 1), "y", Strong.easeOut, -350, 20, 1, true);
         // wait until motion finished
         cityIn.addEventListener(TweenEvent.MOTION_FINISH, tweenFinished);
    function tweenFinished(e:TweenEvent):void {
         // make Tween instance eligible for arbage collection
         e.target.removeEventListener(TweenEvent.MOTION_FINISH, tweenFinished);
         // now you can remove tweened object from the box
         box.removeChild(e.target.obj);
         e.target.obj = null;
    Edited some code.

  • I had to remove Mavericks and do a reinstall on 10.8.5 but still need help...

    I have been trying to undo my Mavericks upgrade in October and after considerable effort I am mostly got back to 10.8.5 OS but still need a bit of help. I just want the previous OS back in place then I'll try Mavericks soon....
    1)               I never seem to pay attention so is 10.8.5 the last OSX prior?  As long as it isn't Mavericks, I want to get it installed.
    2)               I had to reformat my iMac so I have a residual elements from 10.9 and one issue that I had before was permissions. Every number of files either on other hard drives or sometimes in my same user folder was asking for permission and authentication to simply move a file.. A popular one you'll see at the bottom the person/whatever/ problem known as fetching.  Could someone just give me the general reason of this fetching and permissions problem that I ran into?  Better yet since I just want to avoid it altogether into the future tell me what's the best way to assure it disappears forever.
    3)          Another, which is kind of a big ticket item for me is the backup/restore/cover your (!!!) system. I was a good little iMac User and had Time Machine backed up for a period prior to the Mavericks install. I'm a little bit upset that TM isn't 100%....but what is...?  I need another backup/restore system in place and that's what I am looking for recommendations on.  An item that saved me a bit was that I had OS 10.8.3 on an external hard drive.  The problem with that one was it was on a partition, on one of the drives requiring to be reformatted.  It worked as a bridge consolidating files and all but was a big headache as a partition on the external. Recovery Disk did it's part but wasn't enough as well.   Is there a simple/easy idea...clone, disk images, boot from an external drive… ?
    4)          iPhoto (9.4.3) currently will not open the libraries which iPhoto (9.5) converted. Is there way to go back?  Seems the App Store and Software update don't like something. I'm getting into a loop with App Store, iPhoto and the OS. Either the software needs operating system ... then the App Store says it's incompatible or some other complaint.  Right now I have 9.4.3 iPhoto installed for OSX 10.8.5 and was only able to create a new library and the converted ones currently do not open.
    Thanks to your help

    10.8.5 is the lates ML edition.  I use TM and also carbon copy cloner as my second backup.  If I were you and you have a TM backup prior to Mavericks I would try another restore at bootup.  You should erase your drive first in that process using disk utitlites and then use TM to put back you apps and files.  The other choice is to do an internet recovery and then use TM to restore your apps and files.  That should fix the permissions issue.  I did the same thing and all was OK including getting my original iPhoto progam (9.4.3), iphoto11 and photos back.

  • Flashing folder with a question mark. NEED HELP!

    i opened my laptop today and it started making little noises and showed a folder wit ha question mark. I've read some posts and it seems like a hard drive crash...I have the apple care and i purchased my macbook in july of 2007. I was wondering does that cover the problem that i have right now?? NEED help!!

    Same thing happened to me the other day. In fact, it started making little popping noises, I installed the update 10.5.3, when it restarted I got the Folder with Question Mark. The drive was dead as a doornail. I could not get it to show up with disk utility. In fact, when I removed the drive, if I shook the drive you could hear the arm flopping around inside. I have heard reports of this happening to a lot of people. What brand and size drive did you have in your MacBook?
    I ordered a new 160gb 7200RPM drive and it will be here on the 5th. It is real easy to install the drive on these MacBooks. The original equipment hard drives are 5400RPM, so I should see some real snappy performance increases, plus a lot more storage space. Lost everything on the drive, but It was backed up.

  • ITunes Error Message. Still need help. Please.

    I still haven't been able to use my ITunes for about two months. I need help to fix the problem. Here's what it says when I try to start ITunes:
    Microsoft Visual C+ + runtime library
    Runtime Error!
    Program: C:\program files\itunes\itunes.exe
    This application has requested to terminate in an unusual way. Please contact the application’s support team for more information.
    If anyone can help me with this I would greatly, greatly appreciate it. Thanks.
      Windows XP  

    Have you tried un-installing iTunes, downloading the program again from Apple, and re-installing?
    It's always worth a try, as it should help you clear off anything causing the problem and start again.

  • I just bought my MacBook Pro 13" and I tried to install an anti virus but then it went into a grey folder with a question mark I need help with restoring the iOS please

    I need help taking out the grey folder with the question mark and I've try everything except the CD thing because my MacBook didn't come with one so I really need help please

    What anti-virus software did you install? Although there's a lot of bad anti-virus software out there, no anti-virus software should cause such a problem. A gray screen with a flashing question mark on a folder means that no bootable system could be found, which means that the system was badly damaged or corrupt. Even installing bad software would not normally cause that, so either there was something badly wrong with the system already or the anti-virus software you tried to install was really, really bad!
    As mende1 says, you need to reinstall the system at this point. After your system is back up and running, read my Mac Malware Guide. If, after reading that, you want anti-virus software, use one of the programms recommended in that guide.

  • Still needing help downloading program and using the redemption code given to me on the card I purchased at Home Depot two days ago.

    Still need ing help downloading and installing program from card I purchased at Home Depot two days ago.

    It isn't a good idea to start a second thread on the same topic. You have had responses under the first post. I suggest you go there and continue this discussion.

  • Read every font topic, but I still need help

    I have been at this for about 4 hours, and I need help.
    I read Flash Help and every font forum topic, which say
    Static Text need not use embedded fonts.
    Links to .fla and .swf files below.
    Everything shows up fine in 'Control/Test Movie'
    Using Arial font, I cannot see static text in my test .swf
    file.
    I then embedded Arial (24 pt, bold, italic - 'ArialEmbedded'
    in the library).
    Using that font on Static text, can see the text, but not in
    Arial. It is in TimesNewRoman, regular, non-italic.
    I then used the embedded font in text I described as dynamic,
    but could not see any text.
    Everything shows up fine in Control/Test Movie.
    I get around this by building .gifs using graphics packages
    and importing them,
    but the results are less than desirable. (see layer ".gif
    from outside appl."
    Links:
    http://www.ph4d.com/FlashFonts/TestingText3.fla,
    and
    http://www.ph4d.com/FlashFonts/TestingText3.swf
    I hope it's something I overlooked, and I appreciate any help
    provided.
    Thanks,
    vinceg

    Update.....
    I still cannot see text in .swf on my local machine, but I
    can see it on the web, after posting it, but the text looks awful.
    (The same text in Word lookas fine -
    http://ph4d.com/FlashFonts/TestingText3.doc)

  • I still need help. i am technically challanged.  i up graded my phonr to a 5 s.  i backed up my phone on icloud.  i cAn not get my notes or photos.   it looks like the icloud email address is wrong. how can i change it or get my missing items

    I need help. I am not good with technology. I upgraded phone today to 5 s I am missing notes and photos  it looks like the cloud address is not correct. Any suggestions

    Have you forgotten your password? - if so, you have a problem if the email address has gone dead.
    If you know your password, go to the iTunes Store, click on Account. log in and you can change the associated email address.
    If you don't know your password, and have no email address, you are going to have problems because it's difficult to see how Apple are going to identify you as the authorised owner of the account. Contact iTunes Support: go to http://www.apple.com/support/itunes/ - click on 'Other iTunes Store Features' in the list and then on 'Podcasts'. You will see a link to either 'Express Lane', which will guide you eventually to some contact options, or you may see a link to email them.

  • Sorry if this is a stupid question, but I need help

    I would like to e-mail songs that I bought on my iTunes account from one computer to another. I am really computer challenged and I need help doing this. Can anyone give me basic instructions on how to e-mail songs? Thanks!!

    Hi Gabee,
    Welcome to Apple Discussions
    You may want to look at Knowledge Base Document #93063 on How to copy music between authorized computers. You can only have 5 authorized computers.
    Jon
    Mac Mini 1.42Ghz, iPod (All), Airport (Graphite & Express), G4 1.33Ghz iBook, G4 iMac 1Ghz, G3 500Mhz, iBook iMac 233Mhz, eMate, Power Mac 5400 LC, PowerBook 540c, Macintosh 128K, Apple //e, Apple //, and some more...  Mac OS X (10.4.5) Moto Razr, iLife '06, SmartDisk 160Gb, Apple BT Mouse, Sight..

Maybe you are looking for

  • Frequent disconnection from services

    Hi, for years I've been a satisfied customer, but recently my internet, (along with my television signal and phone) would stop working. Strangely enough it happens at exactly XX:05 and XX:33, about every thirty minutes. I'm not completely sure what i

  • How do i recompile whole system with glibc and gcc from test

    I always run testing and hence upgraded all my system a couple of days back. How ever one pprogram i use very often, BLENDER isn't working after i upgraded glibc and gcc4. I have recompiled it but when I get all this errors when i start it http://bbs

  • Jump to Slide not working correctly

    I created quiz questions in Captivate (5.5) that are interspersed throughout the content and  I want to to jump back to the beginning of the section that contains the relevant content for review if the user gets the question incorrect. I created cust

  • I can't create a new mailbox, doesn't show up

    When I create a new mailbox, it does not show up in the left column of mail boxes.  I read in another email on the same topic that the newly created mailboxes (I created or tried to create five or six of them that all never showed up), that they are

  • I cannot open a keynote presentation sent to me.

    I need to update and work on a Keynote presentation that was sent to me, but for some reason I cannot open it. I recently downloaded v6.1. Any suggestions would be greatly appreciated.