Results 1 to 4 of 4
  1. #1
    oinca is offline Member
    Join Date
    Aug 2011
    Posts
    6
    Rep Power
    0

    Default Creating a selective InputVerifier

    Hi, i´ve been struggling with a piece of code on wich i have a JFormattedTextField with an InputVerifier set in. The case is this...as long as the JPanel, on wich this TextField is placed in, is active the InputVerifier should verify the input :)...however if the user select a JMenu placed in the JMenuBar this InputVerifier should be deactivated...avoiding to launch an OptionDialog. Below is the InputVerifier´s code. Any ideas?. Thank you.
    Java Code:
    private InputVerifier verifier_leg = new InputVerifier() {
    		
    		@Override
    		public boolean verify(JComponent input) {
    			Boolean aux = !txt.getText().isEmpty();
    			if (!(aux)){ 
    				getToolkit().beep();
    				txt.selectAll();
    				JOptionPane.showConfirmDialog(null, "El Numero de legajo ingresado no se encuentra en el registro", "Error", JOptionPane.PLAIN_MESSAGE, JOptionPane.INFORMATION_MESSAGE);
    			}
    			return aux;
    		}
    	};
    PS: I´ve tried to reset the TextField´s InputVerfier to null, to overried the shouldYieldFocus(), to disable everything (JPanel, TextField, etc)...please anyone...HELP!
    Last edited by sunde887; 08-08-2011 at 02:39 AM. Reason: review; Added code tags, [code]...[/code]

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

    Default

    You can try this when you create your menus:

    Java Code:
    menu.setVerifyInputWhenFocusTarget( false );

  3. #3
    oinca is offline Member
    Join Date
    Aug 2011
    Posts
    6
    Rep Power
    0

    Default

    Quote Originally Posted by camickr View Post
    You can try this when you create your menus:

    Java Code:
    menu.setVerifyInputWhenFocusTarget( false );
    Hi again, it worked half way sort to speak...now i get the focus out of the textfield but it still make the beep...do you know some way to get the object wich is requesting the focus whitin the input verifier?

  4. #4
    oinca is offline Member
    Join Date
    Aug 2011
    Posts
    6
    Rep Power
    0

Similar Threads

  1. selective image encryption
    By anjalirag in forum New To Java
    Replies: 1
    Last Post: 04-20-2013, 06:28 AM
  2. Replies: 9
    Last Post: 07-29-2011, 02:18 PM
  3. Replies: 3
    Last Post: 04-05-2011, 02:46 PM
  4. Send selective objects in a class over network
    By RDReavis in forum Advanced Java
    Replies: 2
    Last Post: 01-18-2010, 08:45 AM
  5. Go-back-N & Selective repeat protocol
    By Engineera in forum Networking
    Replies: 3
    Last Post: 01-14-2009, 11:18 PM

Tags for this Thread

Posting Permissions

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