Showing message after catching Exception

Hi,
I'm having some troubles while trying to show a message after catching an Exception, the thing I want to do, is after they enter the values (Integer values in this case) if they didn't entered integer values shows a message that they input the wrong thing and then clear the fields.
Here's the code:
private void EnviarActionPerformed(java.awt.event.ActionEvent evt) throws Exception {                                      
        int dir=0, ranuras=0, mp=0, conjunto=0;
        String algoritmo=null;
        try {
            dir = Integer.parseInt(fieldDireccion.getText());       
            ranuras = Integer.parseInt(fieldRanura.getText());
            mp = Integer.parseInt(fieldMP.getText());
            conjunto = Integer.parseInt(fieldConjunto.getText());
            algoritmo = (String)(algoritmos.getSelectedItem());   
        } catch (Exception e) {
            JOptionPane.showmessageDialog(null,"Wrong values");
        }The error I have is: unreported exception java.lang.Exception; must be caught or declared to be thrown.
Thanks in advance

Ok well now I have another problem =S since that actionPerformed is made by netbeans itself I cant put it inside a "try".That is incorrect. You could create another method, which does all the work. Then in the original method do nothing but the try/catch and call that other method.
But it doesn't matter because logically the code is still incorrect. Which hints by me an others have suggested.
The method should not have a throws clause. That is the problem. If the code in the catch block can throw an exception then the solution to that is to put a try catch block around that code (inside the original catch.)

Similar Messages

  • Resend message after catching JMS Exception

    Hi,
    If i resend message after catching JMS Exception is there any chance that the message will be send to the destination queue? (without reconnecting to the queue).
    thanks!

    The problem is you don't really know if its already been sent or not. Then if the broker's gone down you need to recreate your connection, sessions, producers, consumers etc.
    Its much easier to just use a JMS provider which supports auto-reconnection for you which totally hides and fixes all these problems
    http://activemq.apache.org/how-can-i-support-auto-reconnection.html
    James
    http://logicblaze.com/
    Open Source SOA

  • Auto submit input text doesnt show message after enter

    I have a page in jdeveloper 11 an input text with the attribute autosubmmit=true...
    When I write error entrance in the inputtext and press enter, the message is shown and the alert is given. but if I press enter again, the alert message disappears.
    What can I do For this message not to disappear?
    islam.

    Thanks for your reply. I don't know why there is another topic from me, but it is already solved
    Input text components become blank after Submit button clicked

  • How can I show message from server?

    Has anyone idea, how can I show message from server? I want to show message after some files are uploaded via FTP.

    Hi,
    You can use OPEN DATASET for this purpose.
    Try this code:
    <b>****************************************</b>
    Data:
    A_FILE TYPE RLGRAP-FILENAME,   "Application server
    P_FILE TYPE RLGRAP-FILENAME.   "Presentation server
    DATA: BEGIN OF ITAB OCCURS 0,
    LINE TYPE STRING,
    END OF ITAB.
    DATA: FILENAME TYPE STRING.
    FILENAME = P_FILE.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                = FILENAME
      TABLES
        DATA_TAB                = ITAB[]
      EXCEPTIONS
        FILE_OPEN_ERROR         = 1
        FILE_READ_ERROR         = 2
        NO_BATCH                = 3
        GUI_REFUSE_FILETRANSFER = 4
        INVALID_TYPE            = 5
        NO_AUTHORITY            = 6
        UNKNOWN_ERROR           = 7
        BAD_DATA_FORMAT         = 8
        HEADER_NOT_ALLOWED      = 9
        SEPARATOR_NOT_ALLOWED   = 10
        HEADER_TOO_LONG         = 11
        UNKNOWN_DP_ERROR        = 12
        ACCESS_DENIED           = 13
        DP_OUT_OF_MEMORY        = 14
        DISK_FULL               = 15
        DP_TIMEOUT              = 16
        OTHERS                  = 17.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    OPEN DATASET A_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    LOOP AT ITAB.
      TRANSFER ITAB-LINE TO A_FILE.
    ENDLOOP.
    <b>*****************************************</b>
    Hope this helps,
    Regards,
    Pragya

  • How to catch exception of JMS when call onMessage()?

    I write a consumer client implement onMessage(),
    in my main() method ...
    try {
    _adapter = new Adapter(checkConsumer,env);
    _adapter.setSelector("client = 'Receive1'");
    _adapter.start();
    System.out.println("Hello...");
    } catch(Exception e) {
    _adapter = null;
    System.out.println("Unable to start adapter: " + e.getMessage());
    _adapter.start() will call onMessage() my onMessage like this
    public void onMessage(Adapter adpt, Message message) {
    try {
    if(message instanceof TextMessage) {
    // Write the text out as read String text = ((TextMessage)message).getText();
    // Do CHECK Process adpt.demoOut("Receive CHECK Text is :" + text);
    //System.out.println("class name is " + consumerName);
    } else {
    // This is just a message (no particular type) } } catch (Exception e) {
    try {
    adpt.warn("Error outputing data: " + message.getJMSMessageID());
    } catch(Exception ignore) {
    } adpt.warn("\tError: " + e.getMessage());
    // Do some exception process }
    If the JMS Server shutdown, how can I catch the exception?

    You might want to try with exception listener that JMS specification provides.

  • I am not able to send messages to multiple person from my iphone 5s after updating to ios 8.1.2. It shows message not delievered

    I am not able to send messages to multiple person from my iphone 5s after updating to ios 8.1.2. It shows message not delievered

    Hi waqaskhan91,
    Thank you for visiting Apple Support Communities.
    If you're not able to send text or iMessages to certain contacts after updating your iPhone, start with the troubleshooting tips in this article:
    iOS: Troubleshooting Messages - Apple Support
    If you only see this behavior with a few contacts, you may want to try these steps first:
    If the issue occurs with a specific contact or contacts, back up or forward important messages and delete your current messaging threads with the contact. Create a new message to the contact and try again.
    If the issue occurs with a specific contact or contacts, delete and recreate the contact from the Contacts app. Send a new message to the contact.
    Best Regards,
    Jeremy

  • SFTP adapter error : Catching exception calling messaging system

    Error: com.aedaptive.sftp.adapter.SFTPException : Not all messages were delivered succesfully
      Could not deliver message to XI: com.sap.aii.af.lib.mp.module.ModuleException: senderChannel 'ca09269447583427adc545f8c23d244b': Catching exception calling messaging system
    This is error message which i get in sender communication channel while working  with SFTP adapter.

    Hi Pooja,
    I think it would be better to add getcause() to get the cause of the issue.
    Ref: http://help.sap.com/javadocs/pi/SP3/xpi/com/sap/aii/af/lib/mp/module/ModuleException.html
    Thanks,

  • LR4.1 - after publish photos to flickr, then show message of can't update this collection

    LR4.1 - after publish photos to flickr, then show message of can't update this collection. how to solve

    See this: http://feedback.photoshop.com/photoshop_family/topics/lr_4_1_rc_flickr_publishing_broken

  • Stop a method after catching an exception

    I'm facing the following situation.
    I have a method that is used in the actionPerformed from a JButton.
    In this method there is a try block:
    try{
        sl1 = Integer.parseInt(Text1.getText());
        gh1 = Integer.parseInt(Text2.getText());
    }in the catch block i handle a NumberFormatException if there is one.
            catch(NumberFormatException e){
                e.printStackTrace();
                headerLabel.setText("Use numbers only");
            }However, i call several other methods after the try / catch block.
    I only want this to happen when there isn't an Exception.
    Example:
      private void buttonAction(){
          try{
              //Do something
          catch(Exception e){
              e.printStackTrace();
          //Do this if there isn't an Exception
          method1();
          method2();
      }What is the "common" way to handle this situation?

    Encephalopathic wrote:
    One way: Put method1 and method2 in your try block at the bottom, under the line that can cause the exception. e.g.,
    private void buttonAction(){
    try{
    //Do something
    //Do this if there isn't an Exception
    method1();
    method2();
    catch(Exception e){
    e.printStackTrace();
    }Then you can see at a glance that these methods are not supposed to run if the exception is tripped.
    Edited by: Encephalopathic on May 1, 2010 5:46 AMOk, so if there's an Exception, the complete try block is reversed?
    Can i compare it to a ROLLBACK in sql?

  • Application crash on showing alert message after closing document in CS5

    My application crashes when I show alert message after  standard close using IDocFileHandler's close method i.e
    Close( doc, uiFlags, allowCancel, cmdMode );
    Before calling this method there is no crash on showing alert messages.
    i.e just one line before Close() method is called I am able to show alert message. And just one line after close method call , after showing alert message when I  click on OK button of alert message  my application crashes.
    I tried to use errorcode but returned value was fine i.e no error.(Checked GlobalErrorCode and GlobalErrorString before and after close).
    I also tried CanClose method to check but it worked fine.
    I also used IDocumentCommand methods but application crashed without showing  alert message.

    I used PMSetGlobalErrorCode(kCancel) after closing document and it worked.

  • Hello am using ios 7.0.4 I have a question about messages that it does not show the time of a particular message after first message that I recive form a paricular person so please in the next version change this and with every message show time and date

    hello am using ios 7.0.4 I have a question about messages that it does not show the time of a particular message after first message that I recive form a paricular person so please in the next version change this and with every message show time and date

    Hi,
    How is everything going? Have you checked this issue from OWA? If so, please let me know the result.
    In adition, please also try to use the following powershell commands to check if the assistant has right permissions:
    Get-MailboxFolderPermission -Identity
    CEO’s email address:\Calendar -User assistant’s email address
    Also check with:
    Get-Mailbox -Identity CEO’s mailbox
    | fl *GrantSendOnBehalfTo
    Please let me know the result.
    Best Regards,
    Steve Fan
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please click
    here

  • After updating my ipad 4 to ios 7, i cannot charge my ipad with the charger supplied with it,showing messages of errors of the accessories. what can I do to resolve it? my ipad now has only 2% of charge.

    After updating my ipad 4 to ios 7, I cannot charge my ipad with the charger supplied with it,showing messages of errors. what can I do to resolve it? my ipad now has only 2% of charge.Tried with lots of chargers with the same tresult.Somebody told me that it's due to the software upgradation, I have to wait for the next upgrade. need help. my ipad is dying!!!

    Frozen or unresponsive iPad
    Resolve these most common issues:
        •    Display remains black or blank
        •    Touch screen not responding
        •    Application unexpectedly closes or freezes
    http://www.apple.com/support/ipad/assistant/ipad/http://www.apple.com/support/ipad/assistant/ipad/
    iPad Frozen, not responding, how to fix
    http://appletoolbox.com/2012/07/ipad-frozen-not-responding-how-to-fix/http://appletoolbox.com/2012/07/ipad-frozen-not-responding-how-to-fix/
    iPad Frozen? How to Force Quit an App, Reset or Restart Your iPad
    http://ipadacademy.com/2010/11/ipad-frozen-how-to-force-quit-an-app-reset-or-res tart-your-ipadhttp://ipadacademy.com/2010/11/ipad-frozen-how-to-force-quit-an-app-reset-or-res tart-your-ipad
    Black or Blank Screen on iPad or iPhone
    http://appletoolbox.com/2012/10/black-or-blank-screen-on-ipad-or-iphone/http://appletoolbox.com/2012/10/black-or-blank-screen-on-ipad-or-iphone/
    What to Do When Your iPad Won't Turn On
    http://ipad.about.com/od/iPad_Troubleshooting/ss/What-To-Do-When-Your-Ipad-Wo-No t-Turn-On.htmhttp://ipad.about.com/od/iPad_Troubleshooting/ss/What-To-Do-When-Your-Ipad-Wo-No t-Turn-On.htm
    iOS: Not responding or does not turn on
    http://support.apple.com/kb/TS3281http://support.apple.com/kb/TS3281
    Home button not working or unresponsive, fix
    http://appletoolbox.com/2013/04/home-button-not-working-or-unresponsive-fix/http://appletoolbox.com/2013/04/home-button-not-working-or-unresponsive-fix/
    Fixing an iPad Home Button
    http://tinyurl.com/om6rd6uhttp://tinyurl.com/om6rd6u
    iPad: Basic troubleshooting
    http://support.apple.com/kb/TS3274http://support.apple.com/kb/TS3274
    If you can't update or restore your iOS device
    http://support.apple.com/kb/ht1808http://support.apple.com/kb/ht1808
     Cheers, Tom

  • I just bought an iPhone 4s and synched it yesterday.  I backed up the old phone (a 3GS), then restored all that to the 4S.  It generally worked well, except it truncated all SMS messages after October 20.  Can I get the new messages on the new phone?

    I just bought an iPhone 4s and synched it yesterday.  I backed up the old phone (a 3GS), then restored all those files to the 4S.  It generally worked well, except all SMS messages after October 20 were not there.  How do I get the newest messages from the old phone on the new phone?  (I wouldn't mind getting ALL the SMS messages...)
    Thanks for any help.
    Arthur in VA

    Basics from the manual are restrt, reset, restore.
    Have you tried each of these?

  • Can you re-show push notifications for messages after unlocking iPhone?

    Is it possible to re-show push notifications for messages after unlocking an iPhone? If I open my phone, but want to re-see the same message push notifications after closing my phone would that be possible? In other words is there a way to customize a lock screen or to restore it?

    Confirmed. I did upgrade my phone and then "restore from backup" rather than setting up a new phone.
    Would setting up as a new phone delete my extra carrier profiles, or are these untouched? I could try that as well.               

  • Can we show information messages after triggring IDOC's in background

    Hi friends,
    Iam executing one custom transaction for sales cycle in background, in that iam trigging IDOC's, user are getting the messages like
    1. Idoc No: 0000014254 despatched to client -
    2. 1Output  were processed.
    3. 1 IDOC's selected.
    user has to enter 3 times while the transaction is running in background.
    But requirement is "can i set all 3 information messages after trigging IDOC's to background.
    any body suggest the solution.
    regards,
    vamsy krishna.

    Nope nope, I don't work for Apple - I'm just a Level 3 Discussions pleb...! ;-))
    I'd been in touch with the senior tiers of Apple Support on the phone to diagnose the chkdsk incidents of 2004-2005.
    Following that, I also negotiated (part-)resolution to the Smart Playlist issue.
    Since Updater 2006-01-10 (part-)fixed the Smart Playlist problem, but seemed to introduce some other issues for folks, I've been continuing to pass feedback from my Level 2 contact who is handling investigation of the latest problems. In turn, he is working with US Engineering to handle this issue.
    So no, I'm not Apple, but I (and some others) pass commentary to and fro between Discussions and Level 2 Support, and by by-passing Front Line phone support, it helps us to get serious issues investigated and resolved more quickly. I find that such an approach for serious problems works well to help the Community.
    I'm not sure if my message gives hope - but I do hope that having reported this on up to Level 2, and having been told that US Engineering have teams watching Discussions, that maybe we can expect some attention from Apple R&D on this matter. However, the official line is for individuals to contact Apple directly themselves via the phone and website feedback, so US Engineering have an idea of the number of people affected. The more people who report to Apple directly, the more likely the problem is to be noticed, and hence the priority for investigation and resolution increases. I can start an unofficial ball rolling, as I have done, but we cannot keep the momentum up unless users use these official routes to let Apple know they are affected.
    Sorry it's all a bit foggy, but it's the best I've got! Hope this little explanation helps to clarify things a bit more. Feel free to post back if you'd like to discuss this further. Best for now.
    Kind regards,
    Gopha.

Maybe you are looking for