Confused: easy applet has a bug I cant fix

//This program requires the user to guess a number between 1 and
//1000(that had been generated by random function).
//Integer.parseInt method seems to generate an exception but i
//don't get why cause everything seems fine.
//please help!
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class GuessTheNumber extends JApplet implements ActionListener {
JLabel guess;
JTextField userNoT;
JButton guessB;
int number, userNo = 0;
int tries;
boolean guessed = false;
boolean continuePlay = false;
public void init()
Container c=getContentPane();
c.setLayout(new FlowLayout());
guess = new JLabel("Guess a number between 1 and 1000");
c.add(guess);
userNoT= new JTextField(8);
c.add(userNoT);
guessB = new JButton("Guess!");
guessB.addActionListener(this);
c.add(guessB);
}//end method init
public void actionPerformed(ActionEvent e)
if (continuePlay == false)
number = 1+ (int)(Math.random()*1000);
tries=1;
else
tries++;
play();
}//end method actionPerformed
public void play()
String userNoS = userNoT.toString();
userNo = Integer.parseInt( userNoS );
if (userNo == number)
guessed = true;
else if (userNo < number)
showStatus(userNoS + " is too high. Try again!");
userNoT.setText("");
else
showStatus(userNoS + " is too low. Try again!");
userNoT.setText("");
if(guessed==true)
if (tries < 10)
showStatus(Integer.toString(userNo) + "is correct!Either you know " +
"the secret or you got lucky!");
else if (tries==10)
showStatus(Integer.toString(userNo) + "is correct!Ahah! You know " +
"the secret!");
else
showStatus(Integer.toString(userNo) + "is correct!You should be able to"+
" do better!");
userNoT.setText("");
continuePlay=false;
guessed = false;
}//if(guessed==true)
else if (continuePlay==false)
continuePlay=true;
}//end method play
}//end class

What exception is it throwing?Exception occurred during event dispatching:
java.lang.NumberFormatException: javax.swing.JTextField[,65,30,88x21,layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,alignmentX=null,alignmentY=null,border=javax.swing.plaf.basic.BasicBorders$FieldBorder@46c1d4,flags=1184,maximumSize=,minimumSize=,preferredSize=,caretColor=javax.swing.plaf.ColorUIResource[r=0,g=0,b=0],disabledTextColor=javax.swing.plaf.ColorUIResource[r=0,g=132,b=255],editable=true,margin=javax.swing.plaf.InsetsUIResource[top=0,left=0,bottom=0,right=0],selectedTextColor=javax.swing.plaf.ColorUIResource[r=255,g=255,b=255],selectionColor=javax.swing.plaf.ColorUIResource[r=255,g=156,b=112],columns=8,columnWidth=11,command=,horizontalAlignment=LEADING]
     at java.lang.Integer.parseInt(Integer.java:405)....

Similar Messages

  • CRAZY BUG! CANT FIX! HELP!

    I have a 5th Gen 60G iPod. I recently updated the software, and ever since then some crazy stuff has been happening. When I turn the iPod on, it seems to work just fine, until I either start playing a song or scrolling through the menus. Then all of the sudden, I get a crazy buggy digitized looking screen all jumbled where I cant see anything and my iPod freezes to where I can't do anything. I tried resetting it, and it will reset most of the time and SEEM to go back to normal, but then the whole thing starts over again. It looks like it is working fine again, but as soon as I try to do anything, it goes all buggy again. I tried restoring to factory settings, and it didn't help. I don't know what else to do....anyone else have any ideas???

    Ratman, I'd like to personally welcome you to the club. Sorry I don't think you can do anything until apple releases a firmware update, it seems it's a problem with the firmware. There are a lot of people also experiencing this same problem including myself. I've been waiting so long for them to fix this, I would have to recommend that you revert back to the old 1.1.2 firmware. Unfortunately this means that videos won't look as good (and maybe in some cases not available?), and the games won't work, neither does the new brightness control work, but hey at least you can listen to music.

  • Has JDK bug 6569768 been fixed in 1.6?

    I am wondering if bug 6569768 (CMS: System.gc() may hang with -XX:+ExplicitGCInvokesConcurrent upon concurrent mode failure) been fixed in JDK 1.6 upgrade 13. According to bug report, it is fixed in release 'hs11(b01)'. Not sure if this is in JDK 1.6.
    -J

    jzhang_wmc wrote:
    I am wondering if bug 6569768 (CMS: System.gc() may hang with -XX:+ExplicitGCInvokesConcurrent upon concurrent mode failure) been fixed in JDK 1.6 upgrade 13. According to bug report, it is fixed in release 'hs11(b01)'. Not sure if this is in JDK 1.6.
    Yes, the fix for 6569768 is in jdk 1.6 update 13 (it's in 1.6 update 10 and later). Run java -version to see version information for both the JDK and the HotSpot JVM:
    $ jdk1.6.0_10/bin/java -version
    java version "1.6.0_10"
    Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
    Java HotSpot(TM) Server VM (build 11.0-b15, mixed mode)

  • Got my iphone 4s today but the camera has a bug that i cant find reported anywhere

    Got my iphone 4s today but the camera has a bug that i cant find reported. When i take a picture or filming the camera screen shows the buttons in landscape mode( the buttons are at the bottom in landscapemode instead of the bottom end of the phone) and the object i am filming shows up 90 degrees rotated. If i hold the phone in landscapemode the object moves 90degrees rotated too. In i pan the phone the image on the screen goes up and down insted. Very weird.
    But when i check the video there is nothing wrong with the movie. Please help....

    Contact Apple and inform them you have AppleCare +. If your phone is working correctly they may or may not replace it, only they can anwer that question.

  • Confusion about applet

    sir
    i have confusion about applet that if an applet compile successfully but on running it shows a exception message about "main"that no such method exist.help me out please

    The full text of the error message would make it easier for us to see what is wrong BUT it sounds like you are trying to run the Applet as an applicaiton from the comand line rather than through an HTML tag in an HTML page loaded into your browser!
    Though you can make Applets run as applications it not normal to do so.

  • HT201412 After ios7, My iphone4 has gone dead twice in a time frame of around two months...even though its not happening very often but a two month Old phone going dead just after a New update is not acceptable.probably ios7 still has sum bugs dat need to

    After ios7, My iphone4 has gone dead twice in a time frame of around two months...even though its not happening very often but a two month Old phone going dead just after a New update is not acceptable.probably ios7 still has sum bugs dat need to be fixed...Can this bug expected to be fixed in the next update...

    Hi 1283ar.
    Unfortunately, iOS 7 is too hard to push for the iPhone 4 and therefore has a lot of effects turned off to try to get it to run as smoothly as possible.
    However, it becomes better and better with each update coming but it's hard to do anything about the hardware on an already released phones.
    If you still have trouble or think they are too hard. My tip is, if so, to restore your iPhone 4 and make a clean setup with no iCloud backup. But all your photos in a photostream so you can access it later.

  • Can I use an AE as a Bridge allowing me to hardwire my iMac and offer a wifi to my MacBook? The Ethernet in my office is hard wired but does come in from a router on the other end of the building that has a wifi that cant reach my office...

    Can I use an AE as a Bridge allowing me to hardwire my iMac and offer a wifi to my MacBook? The Ethernet in my office is hard wired but does come in from a router on the other end of the building that has a wifi that cant reach my office...

    Thanks, I thought so but wanted to be sure before running out and buying one...  I also called Apple Joint Venture and they helped me set it up without the Airport by using my iMac as the wifi!  Thanks again!

  • HT2305 when connecting to the itunes store i get a mess: (itunes has stopped working) all i can do is close the peogram. i was on the phoine with apple today over 2 hrs still cant fix it

    when connecting to the itunes store i get a mess: (itunes has stopped working) all i can do is close the peogram. i was on the phoine with apple today over 2 hrs still cant fix it. unistalled it 3x and in the proper order. reset all internet connection to default setting, turned off virus programs ect. Even the tech at apple by remote access couldnt fix it. use microsoft fix it also no good....\

    I am having the same problem now also. It happened after I updated my version. I have NEVER had this problem before as a windows user and have had iTunes for 5 years. So, I would have to say it is an Apple problem. I have not changed anything on my computer. I still have Internet Explorer and I have not even updated windows. The only thing I updated was iTunes. Now, I am not getting any response from Apple and if you call you have to pay for support. What a joke. An iPod costs $400 you would think that after paying that much you would at least get some type of help. This will now be the last time I ever by anything apple.

  • I found my old ipod touch and it says the ipod is disabled and to connect it to itunes but when i try to connect it to itunes it says cannot connect cause ipod has passcode but i cant unlock passcode cause ipod disabled. Please anyone have an idea?

    I found my old ipod touch and it says the ipod is disabled and to connect it to itunes but when i try to connect it to itunes it says cannot connect cause ipod has passcode but i cant unlock passcode cause ipod disabled. Please anyone have an idea?

    See Here  >  http://support.apple.com/kb/HT1808
    You may need to try this More than Once...

  • Version 3.6.14 has a bug & does not support Java to play Pogo games - How do I install a earlier version?

    Pogo games plays on Java - the last version of Firefox 3.16.14 has a bug that does not support Java - I have been instructed by Pogo to install an earlier version of Firefox. How do I do that?

    Firefox 3.6.15 was just released to fix that Bug.
    You can use Help > '''Check for Updates''' to trigger an update to Firefox 3.6.15.

  • Why does auto brightness has a bug in iOS 7.1.1 . The brightness switches automatically to higher in bright places but not returns to lower brightness in dark places but when you lock and unlock it becomes normal

    Why does auto brightness has a bug in iOS 7.1.1 . The brightness switches automatically to higher in bright places but not returns to lower brightness in dark places but when you lock and unlock it becomes normal

    Hello,
    Same problem for me. Really a pain in the *** this bug ! Does Apple fixed it. I'm really suprised noone reports this problem  and apple does not adress this.
    Because of that, I cannot give it anymore to children because it hurts the view. Really a shame on the part of apple !
    Regards

  • XML NameSpace Issue Confused whether it is a bug

    Hi,
    The issue is that the generated XML and Actual XML vary as the following: -
    The namespace which is used in the Actual XML is globally used and whereas In the generated XML It is used locally wherever the corresponding element or type is used in the XML Actually, which should not happen.
    I am confused whether it is a bug or an issue if this is an issue can somebody please suggest me a solution
    Generated XML
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <namespace1:utilAuthenticate xmlns:namespace1="http://NAMESPACE1Services.com">
        <namespace2:ccInfo xmlns:namespace2="http://Namespace2CompanionElements.com">
            <namespace2:UKCreditCard>visa</namespace2:UKCreditCard>
            <namespace2:ccAttributes houseNo="koramangala" cardIssueNumber="321" postCode="533201" cardExpDate="01/01/2006" cardNumber="999999999999998" cardIssueDate="01/01/2005" cv2="123" cardHolderName="murali"/>
        </namespace2:ccInfo>
        <namespace2:ourReference xmlns:namespace2="http://Namespace2CompanionElements.com">reference3</namespace2:ourReference>
    </namespace1:utilAuthenticate>
    Actual XML
    <?xml version="1.0" encoding="UTF-8"?>
    <namespace1:utilAuthenticate xmlns:namespace1="http://NAMESPACE1Services.com"
        xmlns:namespace2="http://Namespace2CompanionElements.com">
        <namespace2:ccInfo>
            <namespace2:UKCreditCard>VISA</namespace2:UKCreditCard>
            <namespace2:ccAttributes cardNumber="4627851535817358"
                cardExpDate="05/08" cardHolderName="testnamecard" cv2="482"
                houseNo="75" postCode="NW1 2PL"/>
        </namespace2:ccInfo>
        <namespace2:ourReference>gm-002025004</namespace2:ourReference>
    </namespace1:utilAuthenticate>The code to give the namespaces is the following line: -
    schemaMarshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper",new NamespacePrefixMapperImpl());
    The complete code to Generate the XML is :-
    Marshaller schemaMarshaller = jaxbContext.createMarshaller();
    schemaMarshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper",new NamespacePrefixMapperImpl());
    schemaMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    schemaMarshaller.marshal(bizObj, baos);
    NamespacePrefixMapperImpl is the class written by me which should implement the interface NameSpacePrefix (A JAXB Runtime Class)
    And the code for the class is : -
    import com.sun.xml.bind.marshaller.NamespacePrefixMapper;
    class NamespacePrefixMapperImpl extends NamespacePrefixMapper {
         * This method returns prefix for a given namespace uri.
        public String getPreferredPrefix(String namespaceUri, String suggestion,
                boolean requirePrefix) {
            if ("http://gshop.eai.o2c.ibm.com".equals(namespaceUri))
                return "gshop";
            if ("http://Namespace2CompanionElements.com"
                    .equals(namespaceUri))
                return "namespace2";
            if ("http://NAMESPACE1Services.com".equals(namespaceUri))
                return "namespace1";
            if ("http://www.w3.org/2001/XMLSchema".equals(namespaceUri))
                return "xs";
            return suggestion;
        public String[] getPreDeclaredNamespaceUris() {
            return new String[] {};
    }Thanks in Advance for any suggestion.
    Thanks
    Manjith Kumar A.

    Hi Suren7669,
    Welcome to the Support Communities!
    To resolve this issue, I would suggest updating your iOS to the latest, which is 7.0.3.
    iOS 7.0.3
    http://support.apple.com/kb/DL1691
    iOS: How to update your iPhone, iPad, or iPod touch
    http://support.apple.com/kb/HT4623
    Cheers,
    - Judy

  • My Iphone 6 Screen has been bugging Please Help

    My Iphone 6 Screen has been bugging out lately it bounces up and down and just gets really blurry. Does anyone know how to fix this?

    Hi,
    By "Bounces up and Down", do you mean this:
    The content of the screen drops down and about a third of the top of the screen is blank.
    When you press the home button or any icon, the content moves back to the top of the screen.
    If this is what you are seeing, it is intentional. It is meant as a way for you to be able to easily reach the icons at the top row of the screen.
    Double tap the home button. Do not press the button, just lightly tap it.
    All the content should drop down.
    Pressing the home button or any icon will shift the content back up again.
    This is a new feature designed for the larger screens in the 6 and 6+.

  • My ipod touch wont conect with my computer ..i dont know y ..becas it has be for i cant evan find it in m y computer no where

    my ipod touch wont conect with my computer ..i dont know y ..becas it has be for i cant evan find it in m y computer no where ..but it will charge from my usb when pluged n to my cumputer.. wat to do?i dont have a clue

    Here:
    iOS: Device not recognized in iTunes for Windows
    or
    iOS: Device not recognized in iTunes for Mac OS X

  • How do i get message+  on my pc... my phone has crashed and i cant get my text messages from it.... please help

    how do i get message+  on my pc... my phone has crashed and i cant get my text messages from it.... please help

    mandingo8005,
    Look no further help is here! Let's get those text messages going on your computer. You need to download the desktop client http://www.verizonwireless.com/wcms/consumer/products/verizon-messages.html to your computer to use Message +. Were you already using Message + on your phone?
    What phone do you have? You mentioned the phone crashed. What issues are you having with the phone?
    JohnB_VZW
    Follow us on Twitter @VZWSupport
    If my response answered your question please click the �Correct Answer� button under my response. This ensures others can benefit from our conversation. Thanks in advance for your help with this!!

Maybe you are looking for

  • Working with files on mobile devices

    Hi everybody, at the moment we are running a Vibe 3.4 server which is used most of the time by normal pc clients with the users using the browser or the Vibe desktop client to connect. Now we are getting a tablet project using Vibe more via mobile ac

  • IMac slowed to unusable. Steps to diagnose?

    Symptoms: Long boot time. Keystrokes buffered for many words when typing. Long appliactaion startup. Spinning beachball a lot of the time. Actions to date: Freed up drive space. Added 8 Gigs Ram. Brought to genius bar for testing. Set up new user acc

  • Oracle.DataAccess.Client

    I am having problem using "Imports Oracle.DataAccess.Client" on my code. When I put Imports Oracle.DataAccess.Client at the begining of the page, it will underline it and show sign of error. When I use OracleCommand, OracleConnection, OracleDataReade

  • [SOLVED] netctl DHCP IP (client) and Static IP on a single interface

    Description="enp1s0" Interface=enp1s0 Connection=ethernet IP=dhcp DNS=('127.0.0.1') I have a server I have configured as a NATed router.  enp1s0 is assigned a public ip via my modem, but I also want to add a 192.168.100.0/24 address so I can configur

  • My Favorites aren't staying synced.

    The first time I set up my Watch the favorites synced perfectly from my iPhone. Since then I deleted one and added one on the iPhone yet it did not send that info to my Watch. Is there a way to force this to happen?