Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: how to flush the keyboard buffer in java?

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy how to flush the keyboard buffer in java?

    hi,
    i write a program that management the input ( from keyboard) but my keyboard buffer is full & even keys pressed for install app is in buffer.So i have to flush the keyboard buffer in java & i do not know how , i tried a lot but i couldn't find any answer.i tried this code:

    m=Input.KEYPAD;
    if(m>-1){
    box=new TextBox("MyProgram", "!!!!!!", 20, 0);
    display.setCurrent(box);
    }

    best Regard.


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: how to flush the keyboard buffer in java?

    What did you try?
    What happened?
    Where is the code it happened to?

  3. #3
    Junior Member
    Join Date
    Jun 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: how to flush the keyboard buffer in java?

    that is my code for getting the first key pressed. but lines before this never run because a key always is in buffer & i want to flush the keyboard before this line.
    m=Input.KEYPAD;
     if(m>-1){
            box=new TextBox("MyProgram", "!!!!!!", 20, 0);
            display.setCurrent(box);
        }

  4. #4
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: how to flush the keyboard buffer in java?

    Quote Originally Posted by zara-t View Post
    ... i have to flush the keyboard buffer in java & i do not know how , i tried a lot ...
    I can not tell from the code snippet what you tried, (in terms of the question, how to clear the buffer), so I do not have much to go on.
    Do some research and make an attempt at clearing the buffer, if it does not work, post the code and your question.

Similar Threads

  1. Java String Buffer
    By anonb in forum Object Oriented Programming
    Replies: 3
    Last Post: December 19th, 2012, 02:59 AM
  2. flush()
    By Purple01 in forum Java Theory & Questions
    Replies: 3
    Last Post: October 11th, 2012, 08:47 AM
  3. java buffer problem florida tech
    By computerbuff in forum What's Wrong With My Code?
    Replies: 11
    Last Post: December 12th, 2011, 09:40 PM
  4. Java Frame Buffer Line drawing
    By tcmei in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 17th, 2011, 06:55 AM