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

  • Home
  • SEARCH
  • 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 8365609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:42:00+00:00 2026-06-09T12:42:00+00:00

I want to remap the decimal comma (German keyboard) to a point for certain

  • 0

I want to remap the decimal comma (German keyboard) to a point for certain JTextFields. I have experimented with getInputMap() and getActionMap, but so far nothing worked. Best result I got so far was that the comma didn’t work at all.

I think there should be some way using the input map, but how?

Below is a small example program, could someone give me a hint as to what to fill in at the location of the comment? Or is this completely wrong anyway?

import javax.swing.InputMap;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.KeyStroke;

public class KeyTest extends JFrame {

    private JTextField textField;

    public KeyTest() {
        textField = new JTextField();
        add(textField);

        InputMap map = textField.getInputMap();
        map.put(KeyStroke.getKeyStroke(','), /* what to do here? */);
    }

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                KeyTest test = new KeyTest();
                test.pack();
                test.setVisible(true);
            }
        });
    }
}

EDIT:
Perhaps I was not clear enough with my question. There is no problem with normal numbers. I’m just looking to make user input more convenient when entering dates. these are in the format "DD.MM.YYYY" in Germany. That means, you cannot enter dates using just the numeric keypad because we do not have a decimal point, but a comma. That’s why I want to replace comma with point in the textfields used for entering dates.

All the input fields for plain text and numbers already work fine, and even the date inputs work. I just want to make typing easier. Just yesterday I noticed a similar functionality in Libreoffice, where the comma on the numeric keypad (I have a German keyboard) gets replaced automatically in numerical cells (My locale is set to English), but only in cells containing numerical values. This also happens as you type.

  • 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-09T12:42:02+00:00Added an answer on June 9, 2026 at 12:42 pm

    Use the following

    textField.addKeyListener(new KeyListener(){
    
      public void keyTyped(KeyEvent e) {
        char c = e.getKeyChar();
         if (c== ',')
           e.setKeyChar('.');
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a USB keyboard, and am trying to use Ukulele to remap certain
I have a url for ex : example.com/site/anyFolderName and i want to remap it
I have a program in which I want to be able to store certain
Want to run javascript function from parent window in child window Example I have
want to have a Hyperlink-Button in a gridView in which I can display a
Want the function to sort the table by HP but if duplicate HPs then
I have a (pre-existing) table witha column 'foo'. I want the model to have
EDIT: I understand there is keyboard-quit (which is normally bound to C-g); but I'm
You may have read my earlier question about remapping my keyboard at a low
I want to have the reverse of Ctrl + O to be Shift +

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.