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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:46:54+00:00 2026-06-11T07:46:54+00:00

Hello I’m trying to add the select-all, cut, copy and paste command in my

  • 0

Hello I’m trying to add the select-all, cut, copy and paste command in my application, I managed to work out the cut, copy and paste command but I don’t seem to have figured out how to add the cmd–a command…

this worked for my cmd–x command

text.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),  "cut");

but when I try this for cmd–a:

text.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),  "select");

it doesn’t seem to work…

I read something about using this void to select the text, but I don’t know how to bind it to the command+a command

  myTextfield.selectAll(); 

Anyone got an idea on how to correctly implement this?

  • 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-11T07:46:55+00:00Added an answer on June 11, 2026 at 7:46 am

    Use the correct String: "select-all" instead of "select".

    You can discover these Strings by investigating the InputMap, for example by using:

      public static void main( String[] args ) {
        EventQueue.invokeLater( new Runnable() {
          @Override
          public void run() {
            JTextField textField = new JTextField();
            InputMap inputMap = textField.getInputMap( JComponent.WHEN_FOCUSED );
            KeyStroke[] keyStrokes = inputMap.allKeys();
            for ( int i = 0; i < keyStrokes.length; i++ ) {
              KeyStroke keyStroke = keyStrokes[ i ];
              Object value = inputMap.get( keyStroke );
              System.out.println(keyStroke + "-\"" + value + "\"");
            }
          }
        } );
      }
    

    which prints out (not the complete output pasted here)

    ctrl pressed BACK_SPACE-"delete-previous-word"
    ctrl pressed A-"select-all"
    shift pressed KP_RIGHT-"selection-forward"
    

    This shows the String you are looking for is "select-all".

    Note that it might be really counter-intuitive for a user to switch the function of the ctrl key and the cmd key . For example on a Mac the cmd+A by default does select all (which is expected), but I would never expect that on a Windows/Linux machine

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

Sidebar

Related Questions

Hello Guys I am trying to figure out why i am gettings this error
Hello All I am trying to flatten a list in Ocaml. I am a
. Hello, I am trying to add a UIButton and other items to my
Hello i been trying to get a tokenizer to work using the boost library
Hello all in my iphone application after sending login xml request am getting following
hello I build application with google maps api , the apk work fine till
Hello guys i am trying attempt a dynamic select here. as soon as i
Hello! I've been programming for a long time but just started developing for android,
Hello all I am working on javascript jquery and svg.I want to ask a
Hello all I am working on html and javascript.And I am going to ask

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.