InputVerifer unable to exit with cancel button.

Just playing with the verifier and notice that I am unable to "cancel" when I failed the validation. I understand that I can not conintue to next field, but if I failed but how come I can't cancel out of the form? I could exit if use the [x] on the upper right side. which uses the WindowAdapter.
Any idea on how I can permit my cancel button to work under this situation also?
Here is my sample code. The basic code I got it from http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/InputVerifier.html
modified for my own test.
package verifier;
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
public class VerifierTest extends JFrame {
    public VerifierTest() {
        JTextField tf1 = new JTextField ();
        getContentPane().add (tf1, BorderLayout.NORTH);
        tf1.setInputVerifier(new PassVerifier());
        JTextField tf2 = new JTextField ("next field");
        getContentPane().add (tf2, BorderLayout.CENTER);
          JButton buttonCancel = new JButton("cancel");
          buttonCancel.addActionListener(new CancelListener());
          getContentPane().add(buttonCancel,BorderLayout.SOUTH);     
        WindowListener l = new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                 System.out.println(" win closing");
                dispose();
        addWindowListener(l);
    class PassVerifier extends InputVerifier {
        public boolean verify(JComponent input) {
            JTextField tf = (JTextField) input;
              if(tf.getText().equals(""))
                input.setInputVerifier(null);
                JOptionPane.showMessageDialog(null,"Error, textfield empty");
                input.setInputVerifier(this);
                return false;
              return true;
     protected class CancelListener implements ActionListener{
          public void actionPerformed(ActionEvent event) {
               System.out.println(" cacnelListener Action");
               dispose(); // Or System.exit(0) if you don't want to do
               // something on close.
    public static void main(String[] args) {
        JFrame f = new VerifierTest();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.pack();
        f.setVisible(true);
}

thank you both. I should of use search forums with the key word. I was getting too much return with jtextfield inputverifier.
oh well....

Similar Messages

  • Reg: save exit and cancel buttons

    Hi,
    In normal report programs when we enable the back , exit and cancel buttons they work fine without writing any code.but its not in the case of Module pool why?
    In thr normal reports where does the code come from?
    regards
    prasanth

    Hi....
    Module pool programs is nothing but screen flow + reports...
    Here we designing the screens....
    So we hav to to give every functionality.. for all buttons and menu items of the appeared screen...
    Where as in reports...,
    We are just using the standard screen (sellection screen and list output screen ) s mostly...,
    Here also some times we hav to go for created screens.. nothing but.... interactive reports...,
    There we need to give again all those functionalities...
    And..,
    To see the BACK button logic and other logics in the reports...,
    Ex: PAI event of SAPLWBABAP program..., 
    You can find that name with...
    By giving /H and enter before ur action...
    Thanks,
    Naveen.I

  • How to capture sy-ucomm BACK EXIT or CANCEL button in webdynpro from inbox

    I have a webdynpro which is triggerd by a inbox item (the inbox item is now reserved), on pressing BACK EXIT or CANCEL i want  to release the inbox item.
    In de webdynpro view methode WDDOEXIT i can do this butr i need to know if one of the three buttons ( BACK EXIT or CANCEL) is pressed by the user.
    sy-ucomm is empty.
    Is there a way to find out if a GUI button is preesed??
    Grtz and thanks
    RIchard

    hi, thanks for your response!
    I can't use your hint, because with the code:
    SELECTION-SCREEN BEGIN OF screen 100 as window.
    there will be a "GENERATED" screen. This means, there
    is a screen with all the input fields und the label 100 which I can't
    edit! Because if I edit this screen and activate my source again,
    my changes will be undone!
    So is my question, if there is another system-field than sy-ucom?

  • Error with "Open/Create/Replace File" function with cancel button

    I've attached a very simple VI that embodies what I want to do with my Open File function. I simply want to stop the rest of my program (theoretically encased in the Case Structure) from running if the user deigns not to specify a file location.
    However, if the Cancel button is clicked an error is produced before the rest of the program runs. If you ignore the error and continue, the "cancelled' variable is appropriately made true and the Case Structure runs properly. I simply want to remove the error message LabView gives me.
    Any ideas on why or how?
    Solved!
    Go to Solution.
    Attachments:
    Open file test.vi ‏34 KB

    The cancel button gives you error code 43 (if I remember correctly). After your file vi's, use the general error handler (GEH) to clear this error (and no other errors). Use
    [exception action]=Cancle Error on Match
    [exception code]=43
    type of dialog=no dialog
    Felix
    www.aescusoft.de
    My latest community nugget on producer/consumer design
    My current blog: A journey through uml

  • Processing Page with cancel button.

    Hi,
    I have implement Processing Page but client wants to have cancel button to cancel the process.
    Can anyone give suggestions how to implement this?
    SC

    My requirement is that i have a custom base page with submit button. When user clicks on submit button it would start long running process
    And I should show a dialog page with clock saying process in progress message and a cancel button. User should be able to stop the process by clicking cancel button and back to base page. OAF gives the processing page that i want but without cancel button.
    I try to add cancel button on the processing page programmatically but while it is processing and when i click on cancel button i cannot capture the event.
    how to add cancel button on it and capture event? Is this correct approach?
    Can any body could suggest the best approach and solution?
    Thanks
    SC

  • Exit using Cancel button from form preview.

    Hi
    I am looping into internal table and printing a smartform for every line.
    When I do the preview, and press back button, it takes me through the preview of all the items.
    Is there a way to come out of this preview.
    I am trying to use the cancel button in at user-command, but the program doesnot seem to recognise it.

    Hi,
    Regarding your qusetion about the preview.: In case you are calling the smartform inside a loop, the preview is going to get called. Incase you want just the 1st form to be shown, you could hardcode it in the program. Your logic could be:
    If its print preview, then exit in the 2nd pass of the internal table by checking the sy-tabix.
    Let us know if this suits your need. If it doesnt then throww more light on your question so that we cud suggest better!

  • Progress bar with Cancel button

    Hi Gurus,
    How to implement the Progressing bar with Cancel btn using the ScriptUI?, is it possible in script UI ?
    Thanks in advance.
    Regards,
    Imagine

    what i said is that you need to hava a reference to your thread ine the class that handle the progressBar.
    and in your Thread class you create a method like setCanceled(boolean b)...
    public MyThread extends Thread{
       private boolean canceled = false;
       public void setCanceled(boolean b){
          canceled = b;
       public void run(){
          while(!canceled){
            //do your stuff

  • Problem with cancel button in UIX

    I have a ADF UIX page(J Dev 10g Ver 1012) in which I have used a submit button as a Cancel button in case the user does not want to submit the record. For the cancel button I have set the property "unvalidated=true" and redirected it to a rollback action. Problem is when I create a record and then click on the cancel button it gives an error "value is required" for all the fields which are mandatory (but does not give validation errors). If however I type something into the mandatory fields it works fine. Is there a way to use cancel without forcing the user to type something when he does not want to do so.

    Does that help?
    ADF UIX cancel/rollback button?
    Sascha

  • What are logics for the SAP UI icons of "Back", "Exit" and "Cancel"?

    Hi SAP experts,
    This question may sound kind of strange - isn't that obvious?
    While, it is in fact a very important and difficult issue for UI app implementations when UI flow should be kept persistant. I have been feeling confused when doing UI implementations in Personas, specially when at some screens I need to add my own "BACK" button in order to go back to the previous screen (which can be different screens depending flow conditions.)
    Can anyone explain what the basic logic is used for the SAP "Back", "Exit" and "Cancel" buttons (see below)?
    Here are my understandings (which may not be accurate or correct):
    1. "Back" icon (left): By pressing this icon, all the changes made in the current screen are discarded, and UI moves back to the previous screen. If there are some fields already been filled with values in the previous screen, there can be two UI behaviours depending on the platforms used:
        a) Some platform will restore the values so the screen looks EXACTLY like before.
        b) Some others will leave all fields empty (While, this can be annoying if you have to re-fill all the fields).
    2. "Exit" icon (middle): By pressing this icon, all the changes made in the current screen are discarded, and UI moves back to the "Initial (or Home)" screen which in most time should be the first launching page of the app.
    3. "Cancel" icon(right): I am very confused by this key - what is the special functionality of this key compared to those of the "Back" key and "Exit" key?
    I have been working in many years on developing UI apps for mobile devices, and there were no such three types of keys for UI navigations. Maybe I missed some special points that is special only on SAP?
    Thanks a lot in advance!
    Dong Zhu

    This may not sound that interesting so I will close it to keep our track "clean".
    By the way, just want to share some finding - in Personas, when replacing the Exit or Cancel buttons by transactions, I found that "/n" and "SMEN" does not give the same result, and it depends on whether it is the Exit button or Cancel button that is to be replaced.
    Close this question.
    Dong Zhu

  • [JS CS4] ScriptUI Cancel button inoperant during process

    Hi,
    I made a small interface for exporting PDF. I create two buttons, one for launching the export, one to stop it.
    The launch button calls the exportPDF() function. This function sets two the values of the progressbar.
    The problem is that once the export is launched, the cancel button is no more cliackable. I would like my users to have the opportunity to stop the export process.
    I saw this thread but can't succeed in applying it.
    http://forums.adobe.com/message/1909296#1909296
    TIA Loic
    The script is build like this :
    win = new Window(...)
    +button export
    +button cancel
    +progressbar
    button export onClick > exportPDF();
    function exportPDF()
           doc.export(...);
           progressbar.value=...;

    Hi steven and thanks a lot for input.
    I was starting feeling desperate to get a hint on that topic.
    I tried your lead but it didn't do it. (I can assume I misused it however)
    I create the window on clicking the green button. The cancel window appears fine but I am still unable to switch the button. It's frozen like any other interactrive elements.
    That's ok, I am giving up this cancel button issue. It would be nice to get it but that's ok.
    For the record :
    main win
    green button
    onClick > Make new Window with cancel button and own interactive function
                    exportPDF(...)
    I wasn't any longer as the canceling window appears but still without interactivity.
    Thanks a lot for trying to help me anyway.
    Loic

  • Stopping a thread from "cancel" button

    Hello all,
    I have a problem trying to stop a thread. I have a class that hits database and retrieves lots of data. This retrieval can take a long time if lots of data, so I have a progress bar displayed. This progress bar has a cancel button. I am not sure how to link the cancel button to the thread so the thread can exit. See code below for example of whats going on:
    public class MainApp {
      public void doWork() {
        ProgressBar pbar = new ProgressBar();
        pbar.show();
        DatabaseThread dbThread = new DatabaseThread();
        dbThread.run();
    public class ProgressBar {
      // displays a progress bar with cancel button
    public class DatabaseThread extends Thread {
      public void run() {
        // hit database
    }So how am I to cancel the DatabaseThread class from the ProgressBar class. Thanks for all suggestions!

    what i said is that you need to hava a reference to your thread ine the class that handle the progressBar.
    and in your Thread class you create a method like setCanceled(boolean b)...
    public MyThread extends Thread{
       private boolean canceled = false;
       public void setCanceled(boolean b){
          canceled = b;
       public void run(){
          while(!canceled){
            //do your stuff

  • How to handle the "cancel" button and "close" icon of a popup ?

    Hi,
    I have a popup with "cancel button" and "close icon"(on the top right corner of the popup), I want the same operations to be performed on clicking of any of these two components.
    Is there a way to handle such situation ?
    I read about 2 cases to look into this but they didn't work too well for me.
    1. I read about the "popcancellistener" but that listener is called whenever the popup closes, so suppose I have an "ok button" on the popup to create a record, after the record is created, the popup closes and goes into the "popcancellistener", now the question is "how do we know if it came there because of the 'ok button' or 'some other event'".
    2. I even checked the "DialogListener", now I'm able to distinguish between the 'OK' and 'CANCEL' button in the dialoglistener using the "Dialog.Outcome.ok/cancel", but when a user clicks on the close icon, we do not enter the "DialogListener" at all, so in this case "how do we handle the close icon click event"
    Do let me know if you need any more information from my side.
    Thanks for the help in advance.

    The following mechanism responds to any of the following events: <Esc> key, Close icon ('x'), Cancel button
    JavaScript part:
    function popupClosedListener(event){
                  var source = event.getSource();
                  var popupId = source.getClientId();
                  var params = {};
                  params['popupId'] = popupId;
                  var type = "serverPopupClosed";
                  var immediate = true;
                  AdfCustomEvent.queue(source, type, params, immediate);
    }JSF part:
             <af:popup ....>
                  <af:clientListener method="popupClosedListener"
                                           type="popupClosed"/>
                  <af:serverListener type="serverPopupClosed"
                                          method="#{myBean.serverPopupClosedMetod}"/>
            </af:popup>Finally, Java part:
    public void serverPopupClosedMetod(ClientEvent event){
    }

  • Customize CANCEL button on ESS WD-ABAP

    Hi,
    Currently clicking the EXIT or CANCEL button on all ESS applications is opening a new window. We want the user to go back to initial screen while staying on the same window within the portal. Could anyone pls advise how to do this? I dont want to use the Workprotect mode as it is user specific.
    Please advise.
    Thanks.
    Aditya.

    Hi Aditya,
    Currently all the ESS/ MSS  applications are FPM based web dynpro applications . So if you need to to modify any of the functionality, even button actions, you need to modify the FPM based web dynpro code. Most of the buttons(like review/ Exit, etc) have the standard FPM based events triggered when ever they are clicked.
    One has to dig into the code and understand the flow of control in FPM. You can try to find out which event is being triggered when user clicks on the exit button, and  modify code accordingly.
    Thanks,
    Sonali.

  • I am walking through Apples tutorial getting started with iOS development. I am at the storyboard area and can't seem to drag the cancel button to the green exit. I am not sure why the exit button doesn't except it. Is anyone else having this issue?

    I am walking through Apples tutorial getting started with iOS development. I am at the storyboard area and can't seem to drag the cancel button to the green exit. I am not sure why the exit button doesn't except it. Is anyone else having this issue? Is there a work around? I have done this app twice and still cant get the exit to except the Cancel or Done  bar buttons

    Yes I checked it.  As far as I can see I did everything Apple said to do.  I took some screen shot so you can see how the screens are connected and what and where the code is, and what it does when I drag the cancel and done bar buttons to the exit

  • Strange Blank Services Page with a "Cancel" button

    Hi All!
    For some strange reason my Cisco IP Phone's "Services" button is associated, as default, to a blanck page with a single "Cancel" button as the 3rd softkey. For example, if I push the "Services" button, this default pag will be shown first and seconds later, the page I specified in Call Manager as associated to the "Services" button.
    Usually this is not a problem, only that when I try to push a CiscoIPPhoneImageFile object to the phone, in the 2-3 second while the phone is downloading the image, this blank page will be shown and it stays there untill the image is fully downloaded. It is especially annoying as my ImageFile object has a 3rd softkey button called "Exit", so the user will witness a button first appeared as "Cancel", and then suddenly changes to "Exit"!
    Any one know how do I remove this strange "default" blank page, or at least change its "Cancel" button to whatever I prefer? Thank you very much for your help!

    Could it be that on the phone you're using, you have signed up for a service that turns the service list into something the phone cannot handle (e.g. the application name is too long)? The empty page with a cancel suspciously reminds me of what you get when the phone chokes on an xml element.

Maybe you are looking for

  • Re-encode and send to Flash Media Server?

    Hi all, I hope this is not a basic question - I'm in a bit of a loop with this. I need to do two things: grab a live video feed from a professional DV camera - the feed would be a standard BNC (composite) video cable + XLR mic cable or similar. I nee

  • Lightroom 3 making duplicate copies of recent imported photos by itself?

    I use Lightroom 3 and recently it has started making multiple duplicates of recent imported (and exported) photos without me doing anything.... what happens is I import a batch of photos, make adjustments to them, export them... close lightroom. Then

  • LiveCycle Designer PDF file size

    Hello. I have the trial of LiveCycle Designer ES2 (v9.0.0.0.2009....) installed.  I created a seemingly simple PDF form, but the file size is over 1MB.  Is that "normal"?  It seems like it would/should only be a few hundred kb, if that.

  • Permission error with go

    This happened for me: $ go install packagename go install runtime: open /usr/lib/go/pkg/linux_amd64/runtime.a: permission denied $ pacman -Q go go 2:1.0.1-1 I didn't have this problem before updating Go. I searched and found a similar problem reporte

  • Wrong image refresh in java applet AND Windows 7

    I'm managing since few days a java applet that takes an image from an industrial product and shows it in a browser (simple web server). There is following issue: the image is not correctly loaded and refreshed in its own window if just opened but onl