Results 1 to 7 of 7
  1. #1
    laxtrappa is offline Member
    Join Date
    Mar 2012
    Posts
    13
    Rep Power
    0

    Default NumberFormatException

    i have this in an applet:

    JButton restartButton = new JButton();
    restartButton.setBorder(whiteBorder);
    restartButton.setBackground(Color.black);
    restartButton.setBounds(1120, 20, 100, 30);
    restartButton.setForeground(Color.white);
    restartButton.setText("restart");
    restartButton.setName("restart");
    restartButton.addMouseListener(this);
    add(restartButton);

    when this button is pressen i get this, and it makes no sense to me:

    DrakBorgen [Java Application]
    cyberdyne.DrakBorgen at localhost:59287
    Daemon Thread [AWT-XAWT] (Running)
    Thread [AWT-Shutdown] (Running)
    Thread [AWT-EventQueue-0] (Suspended (exception NumberFormatException))
    EventDispatchThread.run() line: 172
    Thread [DestroyJavaVM] (Running)
    Thread [AWT-EventQueue-0] (Running)
    /usr/lib/jvm/java-6-openjdk/bin/java (Mar 28, 2012 4:05:51 PM)

    i have similar buttons, that work fine so the class implements MouseListener
    and has a mouseClicked method.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,939
    Rep Power
    8

    Default Re: NumberFormatException

    If you want help, you'll have to provide an SSCCE that demonstrates only the problem at hand- this looks like a problem with a formatter of some kind, so you only need to post that code, not even a gui. Also include the full text of the stack trace along with the exact line it's occurring on.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    laxtrappa is offline Member
    Join Date
    Mar 2012
    Posts
    13
    Rep Power
    0

    Default Re: NumberFormatException

    the applet is here: http://213.21.66.155/Drakborgen/bin/drakborgen.html
    the code is here: Index of /Drakborgen/src/cyberdyne, problem class is "DrakBorgen.java"

    now this is an attempt for a computer version of an old swedish board game, so it's all in swedish sorry
    (fortunately for you, i always write the code in english :)
    but basically, you first get to select a player, then a ring and then the game board is drawn. the problem
    button is located at the top right, named "nytt spel".
    Last edited by laxtrappa; 03-28-2012 at 06:14 PM.

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,939
    Rep Power
    8

    Default Re: NumberFormatException

    I don't want to be rude, but you just ignored my request. I would suggest you make it easier for people to help you. Asking people to run applets, download code, and translate Swedish isn't making it easy for people to help you.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    laxtrappa is offline Member
    Join Date
    Mar 2012
    Posts
    13
    Rep Power
    0

    Default Re: NumberFormatException

    sorry, if i ignored, i mi ght have read your post too quickly and hasted in my response.
    i interpreted it as if you wanted to see the code, so i provided it in the way i figured was
    most convenient. the applet i just threw in as a bonus
    Last edited by laxtrappa; 03-28-2012 at 06:31 PM.

  6. #6
    laxtrappa is offline Member
    Join Date
    Mar 2012
    Posts
    13
    Rep Power
    0

    Default Re: NumberFormatException

    as for the stack trace, i find no way to put a try/catch somewhere to catch the exception as it just happens
    at a mouseEvent. that was my 2nd intention bby supplying the applet, the stack trace appears
    in the java console
    Last edited by laxtrappa; 03-28-2012 at 06:33 PM.

  7. #7
    laxtrappa is offline Member
    Join Date
    Mar 2012
    Posts
    13
    Rep Power
    0

    Default Re: NumberFormatException

    I solved this now.. i'd just been staring myself blind at my own code... when i got that mouseEvent, i'd simply forgotten
    to make a "return", so the method went ahead with a
    String[] coord = b.getName().split(",");
    Integer x = Integer.parseInt(coord[0]);
    so theres, nothing strange about this. you actually helped me tho, by suggesting to look at the stack trace more carefully
    Last edited by laxtrappa; 03-28-2012 at 06:49 PM.

Similar Threads

  1. NumberFormatException error
    By saran87 in forum New To Java
    Replies: 3
    Last Post: 08-24-2009, 04:51 PM
  2. NumberFormatException
    By Manfizy in forum New To Java
    Replies: 13
    Last Post: 07-09-2009, 11:59 AM
  3. NumberFormatException raised
    By venkatallu in forum New To Java
    Replies: 1
    Last Post: 06-02-2009, 09:27 PM
  4. NumberFormatException problem
    By bluebarca in forum New To Java
    Replies: 1
    Last Post: 02-06-2009, 07:39 AM
  5. Error: NumberFormatException
    By coco in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 07:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •