Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8448875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:32:33+00:00 2026-06-10T10:32:33+00:00

I am working on a Java application and interfacing with an RFID reader that

  • 0

I am working on a Java application and interfacing with an RFID reader that acts as a keyboard input device.

The application will be used for employee time tracking, so the employee should not see the code that his/her RFID tag contains.

Currently, the application opens a jFrame that asks the employee to scan their tag. This is where I would like to listen for the keyboard input.

All of the RFID tags are 10 digits, so I would like to use some kind of regex to detect when a card is scanned if possible.

If someone could point me in the right direction, or contribute some code I would be grateful.

Thanks in advance.

UPDATE:

I was able to read the input of the scanner by adding the following to the constructor of my JFrame.

addKeyListener(new KeyListener(){
    @Override
    public void keyPressed(KeyEvent e){ System.out.print(e.getKeyChar());}
    @Override
    public void keyReleased(KeyEvent e) { }
    @Override
    public void keyTyped(KeyEvent e) { }
});

So it is now confirmed that the Reader is just standard Keyboard input.

Here is an example of what I get for a tag: 0006459027

Now, the big question is, how do I take the characters that I got, and detect that it is a 10 digit string, and from there trigger an event to open a new frame?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:32:34+00:00Added an answer on June 10, 2026 at 10:32 am

    First, I’d see if the RFID reader is triggering an ActionEvent to be fired when the tag is scanned. This would be the simplest approach.

    Failing that, you would need to attach a DocumentListener to the fields underlying document and monitor for changes.

    You’ll need to decide how best to interrupt the results (as you’re likely to get each letter of the RFID at a time). You could monitor the length of the document or have a javax.swing.Timer which triggers after a short delay (you’d reset the timer on each update event triggered by the DocumentListener)

    Check out

    • JTextField.addActionListener
    • JTextField.getDocument().addDocumentListener

    I’d suggest taking a look at DocumentFilter as well, but your interested in the final result, not modifying it.

    UPDATED with DocumentListener Example

    // In the classes variable decleration section...
    private JTextField rfidField;
    
    // In the classes constructor or UI init method...
    rfidField = new JTextField(12);
    rfidField.getDocument().addDocumentListener(new DocumentListener() {
    
        public void handleUpdate(DocumentEvent e) {
    
            if (e.getDocument().getLength() == 10) {
    
                System.out.println("Trigger me happy...");
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        rfidField.setText(null);
                    }
                });
    
            }
    
        }
    
        @Override
        public void insertUpdate(DocumentEvent e) {
            handleUpdate(e);
        }
    
        @Override
        public void removeUpdate(DocumentEvent e) {
            handleUpdate(e);
        }
    
        @Override
        public void changedUpdate(DocumentEvent e) {
            handleUpdate(e);
        }
    });
    
    // Now don't forget to add the field to your forms container ;)
    //////
    

    One of things I would be do when you “trigger” the code event is, once you’ve read it from the text field, is clear the text field (JTextField.setText(null)) – IMHO

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a Java application that will use some Hibernate (annotated by
I'm working on application in Java that will maintain database of song lyrics in
Im working on a Java Application that edits Pdf files. Furthermore a shell script
I'm working on a Java application that uses JavaSpace. We're developing this in Eclipse.
I am working on a Java Web Application that exposes a web service. This
I am working on a Java UI application that uses JDBC. I assume the
I am working on a java application that targets both mac and PC. Recently
Actually I am working on a Java application that requires an ODBC. I created
I'm working on a Java web application in which files will be stored in
I'm working with a Java application that is going to write a .dat file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.