How to prevent the Toolkit.getDefaultToolkit().beep() in JTextField

Hi,
I use the JTextField in my application.
when the user type value in the field e.g. "123456"
if you press the backspace 5 times the value will be "1" , pressing it again results with ""
now.....
pressing it again results a system beep.
I want to prevent this beep how can I do it??
thanks

textField.getDocument().addDocuemntListener(docListener);
Then implement the removeUpdate(DocumentEvent evt)
Hope this helps
Sai Pullabhotla

Similar Messages

  • Substitute of java.awt.ToolKit.getDefaultToolKit.beep()

    Hello everybody. I am designing a Swing Application and there I am using java.awt.ToolKit.getDefaultToolKit.beep() method to generate sound in various operations. I want to know is it possible to generate own sound as a substitute of this method? I think it is possible. How can I do this? Thank you.

    Thank you for giving reply.
    As I wish to play .mp3 file I had downloaded an API from Javalobby . I tried it, here is my code :
    package player;
    import java.io.File;
    import java.io.IOException;
    import javax.sound.sampled.AudioFormat;
    import javax.sound.sampled.AudioInputStream;
    import javax.sound.sampled.AudioSystem;
    import javax.sound.sampled.DataLine;
    import javax.sound.sampled.SourceDataLine;
    * @author Tanmoy
    * @Super Scientific Calculator
    * @version 1.2010
    public class Player {
         private File audioFile;
         public Player(String path) {
              this.audioFile = new File(path);
         public void play() {
              AudioInputStream din = null;
              try {
                   AudioInputStream in = AudioSystem.getAudioInputStream(audioFile);
                   AudioFormat baseFormat = in.getFormat();
                   AudioFormat decodedFormat = new AudioFormat(
                        AudioFormat.Encoding.PCM_SIGNED,
                        baseFormat.getSampleRate(), 16, baseFormat.getChannels(),
                        baseFormat.getChannels() * 2, baseFormat.getSampleRate(),
                        false);
                   din = AudioSystem.getAudioInputStream(decodedFormat, in);
                   DataLine.Info info = new DataLine.Info(SourceDataLine.class, decodedFormat);
                   SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info);
                   if (line != null) {
                        line.open(decodedFormat);
                        byte[] data = new byte[4096];
                        line.start();
                        int nBytesRead;
                        while ((nBytesRead = din.read(data, 0, data.length)) != -1) {
                             line.write(data, 0, nBytesRead);
                        line.drain();
                        line.stop();
                        line.close();
                        din.close();
              } catch (Exception e) {
              } finally {
                   if (din != null) {
                        try {
                             din.close();
                        } catch (IOException e) {
    }And the calling, piece of code is :
    try {
                                  Parser parser = new Parser(parsingString, displayPanel.getCurrentBase(),
                                       displayPanel.getCurrentBase(), displayPanel.getTrigoMode(),
                                       displayPanel.getScale());
                                  String output = parser.solve();
                                  displayPanel.outputTextField.setText(output);
                                  displayPanel.outputTextField.setCaretPosition(displayPanel.outputTextField.getText().length());
                                  displayPanel.charLabel.setText((Integer.toString(output.length())));
                                  if (message == null) {
                                       message = "No Exception";
                             } catch (InvalidSyntaxException invalidSyntaxException) {
                                  message = invalidSyntaxException.getMessage();
                                  JOptionPane.showMessageDialog(null, message, "Error", JOptionPane.ERROR_MESSAGE);
                                  new Player("/resources/what_the_hell.mp3").play();
                                  displayPanel.outputTextField.setText("0");
                                  displayPanel.charLabel.setText("0");
                             }But I can not able to here the sound.
    What to do now?
    Thank you.

  • How to prevent the code viewing of jsp files

    hello friends
    How to prevent the code viewing on directly opening .jsp files at the server side
    Thanks in advance

    hello friends
    How to prevent the code viewing on directly opening
    .jsp files at the server side
    Thanks in advanceWhat exactly do you mean by code viewing? If by that you mean you don't want all the folders to show in the directory create a index.jsp file that has all the links to the pages you want to show
    If you mean something else please clarify

  • Hello , FMS is how to prevent the client into a large number of bytes?

    Hello , FMS how to prevent the client to pass a large number of bytes , such as one person put a 1G file in the argument , I also silly to receive ?Although there Client.setBandwidthLimit ( ) limit his maximum traffic per second , but is there a way , one more than the maximum amount of bytes to disconnect his.I assume that methods to determine the length is also obtained all of his transfer is finished , in order to determine out of it .

    How to limit the size of the parameters of the method.I wrote a method in the main.asc then the client NetConnection.call assignment, but if the client is malicious to upload very large data, how to limit it, I view the document did not find the clues, I hope that those parameters up to100KB.

  • Toolkit.getDefaultToolkit().beep() does not beep!

    Hi,everyone:
    I met a problem when I used Toolkit.getDefaultToolkit().beep() .
    When running, no beep can be heard!
    My Environment is as follows:
    Hardware: Dell dimension 2400
    OS : Windows 2003 Enterprise Edition
    JDK : J2SDK1.4.2
    Code :
    Toolkit.getDefaultToolkit().beep();
    (In java application)
    Does My enviornment not support this operation? Can anyone tell me?
    Thank you.

    Yes, its a bit buggy. Does this work for you?
    ** Will you please tell me where to find evidence that this is a bit buggy?
    Thank you.
    System.out.print ( "\007" );In my java application, System.out.print ( "\007" ) works.
    ** But when I write it in my applet, no beep can be heard!
    import java.applet.*;
    import java.awt.*;
    public class MyBeepApplet extends Applet
        int cx = 50;
        int cy = 50;
        String msg="";
        public boolean mouseDown(Event e, int x, int y)
            msg = " Beep?";
            cx = x;
            cy = y;   
            for(int i=0; i<260;i++){
                System.out.print("\007");
                System.out.flush();
            repaint();      
            return true;
        public void paint(Graphics g)
            g.drawString(msg, cx,cy);
    }

  • How to prevent the user to submit leave request?

    Hi all,
    If the employee has wrong setup in the AME approval,the error "ERROR: An Invalid Setup has been detected for the current Transaction Type in Approvals" will be raised, although the employee will be able to submit the request, the request will have pending for approval status.
    How to prevent the user to submit the request when the error raised?
    Any idea.
    Regards

    Hi,
    Is this possible?  Pl check the error and your Transaction type. Refer ID 420381.1(How to Create the Approval Transaction Type for AME.A?) and also refer Oracle White paper on
    "Approvals Management Responsibilities and Setups in AME.B".
    Hope this helps.
    Regards,
    Siva

  • How to prevent the transaction code

    Hi
    I want to remove the common transaction code like /n,/o and /nex for particular user.
    Is there any SAP standard role availble or how to prevent the authurization for the above client independed
    transaction code.
    Regards,
    Jayakumar

    Hi,
    I want to know why you need to restrict these features when there is no harm.
    These are not transactions. They are extra features in SAP.
    /nT-code --- takes you to the new T-code by ending the previous T-code.
    /oT-code -
    creates a new session with the given T-code.
    /nex -
    ends the session.
    Rgds
    Suman

  • How to prevent the Canon 6D to climb to higher ISOs when it works in automatic mode?

    How to prevent the canon from 6D climbing to higher ISOs when it works in automatic mode?
    I was shooting at a basketball game at ground level and I left it in automatic mode because the moves were too fast, but when I passed to Lightroom, the photos were grainy, due to high ISO.

    Under the settings menu (third menu over), select ISO settings, and then set the Auto ISO limits for max to whatever you consider the maximum acceptable ISO.

  • How to prevent the program not to skip the process when exception is genera

    Hi, friends.
    How to prevent the program not to skip the process when exception is generated?
    For example, I am doing a process for 100 records. If the 15th record causes a Java Exception, I want to be able to skip it and continue processing the remaining 85 records.
    How it is possible with Java Exception handling? Any sample code?
    Thanks,
    Jaykishan

    [http://java.sun.com/docs/books/tutorial/essential/exceptions/]
    while (there are more lines) {
      try {
        process the next line
      catch (...) {
        log the error
    }[http://java.sun.com/docs/books/tutorial/essential/exceptions/]
    You'll want to be careful about which exceptions you catch though. For instance, if there's an unchecked exception, like NullPointerException, it's a sign of a bug in your code. Continuing to process as if that bug weren't there is often a worse approach than just failing. In this particular case, however, as long as you log the exception and then followup by fixing the bug that caused it, it may be acceptable to continue trying to process the rest of the file, even if some lines bring out a bug in your code.

  • Does anyone know how to prevent the YouTube volume from going up automatically?  I keep my volume down and it increases automatically when I play a video.

    Does anyone know how to prevent the YouTube volume from going up automatically?  I keep my volume down and it increases automatically when I play a video.

    Have you tried Windows Update in the Control Panel?
    Many times it will find the newest supported drivers for Hardware.
    Just be sure to install everything not just the Important ones.
    Let us know if this helps.

  • How to set the maximum length in a JTextField component.

    Hi This is a basic doubt. How can i set the maximum lenght in a JTextField.. I tried the setColumns() method. It doesnt do anything.. Pls Help.
    Thanks
    Rajeev

    Here's an example using PlainDocument.
    textField.setDocuemnt( new TextFieldVerifier() );
    class TextFieldVerifier extends PlainDocument {
    int requiredLength = 10; // whatever length you want
    public void insertString( int offset, String str, AttributeSet attSet ) throws BadLocationException {           
    boolean valid = true;          
    if (str == null) {
    return;
    String old = getText( 0, getLength() );
    /* insert the new string at the given offset, into the old string */     
    String newStr = old.substring( 0, offset ) + str + old.substring( offset );
    if (newStr.length() > requiredLength)
    valid = false;
    Toolkit.getDefaultToolkit().beep();
    if ( valid )
    super.insertString( offset, str, attSet );
    }

  • How to disable the tab focusing for a JTextField object because those ...

    Hi All,
    Here I need some help. I want to disable the tab focusing( tab index) for a JTextField objects because those objects are set as setEditable(false). Also can u tell me about how to change the tab index orders for JTextFields.
    Many thanks,
    Vijaycanaan.

    I want to disable the tab focusing( tab index) for a JTextField objectsLook through the API and find methods with the word "focus" in the method name.
    Also can u tell me about how to change the tab index orders for JTextFields."How to Use the Focus Sub System":
    http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html

  • How to use the Toolkit???

    I would like to create a beep sound in my program. I know that there is a Toolkit that can implement the beep(), but how should I use it?
    Now, I am using iPAQ H3870 model with Jeode VM.
    Hope anyone can help me.
    Thanks

    How about this:
    import java.awt.Toolkit;
    void makeSomeNoise() {
       Toolkit.getDefaultTookit().beep();
    }kind regards

  • TS3276 On received mail, I delete sender's name, address, etc. then forward it.  The forwarded mail has a duplicate of the original mail, show original sender's name, etc.  How to prevent the duplicate from being sent?

    How to prevent duplicate of orginal mail (with original sender's name, address) being "attached" when forwarded?

    Maybe I am mis-understanding what you are seeing.
    When I forward a message, the receiver will see the original mail (unless I edit it, such as removing any previous sender's information) and the length will be the same as the message was before forwarding except for the added line "Begin forwarded message" (again, unless I edit bits out), and there will be no attached copy of the original message.
    So when you say in your reply above "The orginal email with the sender's name and address was also sent with my forwarded email." do you mean:
    a) that it is still visible at the head of the text of the message (which I was saying does not happen for me because "after hitting delete, the previous sender's information disappears." [and since] "it has disappeared, it cannot be in your forwarded mail." Disappeared means it is not there.
    b) another copy of the original message is attached to the forwarded email at the end, either as an included file or as repeated text.
    c) some other situation.
    Sorry about the previous mis-spellings! I hope that we can get to the bottom of this.

  • How to prevent the use of wild cards in select-option

    Hello experts,
    Is it possible to prevent the use of wild cards in a select-option? If yes, how is it done please?
    I have a
    SELECT-OPTIONS: o_comp  FOR dbtab-field OBLIGATORY DEFAULT 'FI'.
    and, I want to prevent the users for giving in some thing like FI* with the wildcard bc it would lead to dump.
    I want an error message to display and prevent the users for making such entry.
    Please I need your help and I would be very grateful.
    Thanks
    Nadin

    You have to use SELECT_OPTIONS_RESTRICT to restrict input allowed. Call this FM in INITIALIZATION or SELECTION-SCREEN OUPUT sections.
    Sample :
    TYPE-POOLS: sscr.
    INITIALIZATION.
    * Restrict SELECT-OPTIONS
      PERFORM restrict_select.
    FORM restrict_select.
      DATA: restrict TYPE sscr_restrict,
            opt_list TYPE sscr_opt_list,
            *** TYPE sscr_***.
    * Défine select-options modes (aka option list)
    * - ALL standard - all options allowed
      CLEAR opt_list.
      MOVE 'ALL' TO opt_list-name.
      MOVE 'X' TO: opt_list-options-bt,
                   opt_list-options-cp,
                   opt_list-options-eq,
                   opt_list-options-ge,
                   opt_list-options-gt,
                   opt_list-options-le,
                   opt_list-options-lt,
                   opt_list-options-nb,
                   opt_list-options-ne,
                   opt_list-options-np.
      APPEND opt_list TO restrict-opt_list_tab.
    * - EQU only equality allowed (list of values)
      CLEAR opt_list.
      MOVE 'EQU' TO opt_list-name.
      MOVE 'X' TO opt_list-options-eq.
      APPEND opt_list TO restrict-opt_list_tab.
    * Affect modes to parameters or block of parameters
    * ALL by default
      CLEAR ***.
      MOVE: 'A'          TO ***-kind,
            '*'          TO ***-sg_main,
            'ALL'        TO ***-op_main.
      APPEND *** TO restrict-***_tab.
    * EQU to internal material number
      CLEAR ***.
      MOVE: 'S'          TO ***-kind,
            'S-MATNR'    TO ***-name,
            'I'          TO ***-sg_main, " no exclusion
            'EQU'        TO ***-op_main. " only value list
      APPEND *** TO restrict-***_tab.
    * Call  FM
      CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
           EXPORTING
                restriction = restrict
           EXCEPTIONS
                OTHERS      = 1.
    ENDFORM.                    " restrict_select
    In the sample, only select-options for matnr is restricted to single value list.
    For your request build a mode with all options except "pattern" ones : CP and NP.
    Regards

Maybe you are looking for

  • Sender FTP Adapter not working with certain name

    Hello, We're facing the next problem within XI. We configured a sender FTP adapter within the central adapter engine. This adapter is configured correctly however for some reason it is not picking up any file from the FTP server. Changing status to i

  • PIN Code Problem on E51

    Hello guys... I want to change my pin code of my phone.. Currently I'm using Nokia E51. I change the PIN Code Request to "Yes" and it asked the PIN code. And so where can i get that pin code? My phone is new one and I already try "12345" and "01234"

  • HOW TO FIND UNUSED initialization blocks  IN OBIEE RPD

    Hi Gurus, I have a task to remove unused initialization blocks and subject areas from RPD. how to find them ?how to check whether any reports are using these initialization blocks? Please reply me. I need to complete this task.Pls help me Regards, si

  • How to remove the entries of the names of the previously read PDF files in order to not to leak privacy

    How to remove the entries of the names of the previously read PDF files in order to not to leak privacy

  • HT4325 3 Problems with iTunes

    After investing a lot of time to investigate, I am searching for solution for a) I am running iTunes on my iMac and I am able to airplay with my 1st Gen Apple TV (Audio only) but not with my MacBookPro (Early 2011) b) I am subscribing TV Series via a