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 8372317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:23:57+00:00 2026-06-09T14:23:57+00:00

I have a Class that extends JTextField where I’d like to have CTRL-Shift-O do

  • 0

I have a Class that extends JTextField where I’d like to have CTRL-Shift-O do something. I had been listening for it in

JTextFieldExtension.addKeyListener(new KeyAdapter() {

public void keyReleased(KeyEvent e)
{
}

}

with the help of e.isControlDown() and e.isShiftDown(), and that worked fine. But I noticed that the text in the field was also shifting from the left to the right side. Apparently this is a default behavior of the JTextField. So I found this thread on SO which appeared to be helpful:

How to disable default textfield shortcuts in JTextField

From that thread, calling jtextField.getInputMap().setParent(null); did deactivate that behavior. But it also got rid of Ctrl-C and other useful mappings I still want to keep. So I tried the suggested methods for removing just the KeyStroke “ctrl shift O”. But none of them seem to work.

Currently in the class’s constructor I have the following:

     this.getInputMap().put(KeyStroke.getKeyStroke("shift ctrl pressed O"), null);
     KeyStroke[] strokes = this.getInputMap().allKeys();
     for (KeyStroke ks : strokes)
     {
        System.out.println(ks.toString());
     } 

It doesn’t work despite the System.out.Println showing “shift ctrl pressed O” as one of the allKeys that it lists. I also tried calling InputMap.remove instead of Put(), without success.

What am I missing?

  • 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-09T14:23:59+00:00Added an answer on June 9, 2026 at 2:23 pm

    Removing keys from the input map does not seem to be working as I would expect in this case, but you can override the installed action to effectively disable the ‘switch component orientation’ thing. In Swing, the input map maps keystrokes to objects (usually Strings) which work as identifiers for the action map, which again holds the corresponding action. A simple way of disabling ctrl+shift+O would therefore be as follows:

    myComponent.getInputMap().put(KeyStroke.getKeyStroke("shift ctrl pressed O"), "Nothing");
    

    This simply remaps the keystroke to something not contained in the action map (the String “Nothing”, might as well be “Foo”), therefore nothing happens when you press ctrl+shift+O.

    Edit: I can see that this was proposed in the thread you linked. I did, however, confirm that the above code will work for a text field. If it doesn’t for you, please provide a short example of the call in your code.

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

Sidebar

Related Questions

I have a Java class that extends JTextField and covers it with a JLayer
I have a class that extends AsyncTask , which fetches the gps cordinates from
I have a class that extends Application. The class is fairly extensive. When the
I have a class that extends View. I override the onDraw method and allow
I have a class that extends android.app.Dialog, the layout is done in an xml
i have a class that extends another. when i iterate the current object i
I have a class that extends AsyncTask. In the doInBackground() method, I connect to
I have a class that extends JPanel. On the panel I have added an
In my Android app, I have a class that extends Thread that runs when
I am facing a problem. I have a Class that extends listactivity and its

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.