Here you can find the source of installKeyBindings()
public static void installKeyBindings()
//package com.java2s; /*// www . j a v a 2 s . c o m * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import javax.swing.InputMap; import javax.swing.KeyStroke; import javax.swing.UIManager; import javax.swing.text.DefaultEditorKit; public class Main { public static void installKeyBindings() { if (isMacOSX()) { final KeyStroke copyKeyStroke = KeyStroke.getKeyStroke("meta pressed C"); final KeyStroke pasteKeyStroke = KeyStroke.getKeyStroke("meta pressed V"); final KeyStroke cutKeyStroke = KeyStroke.getKeyStroke("meta pressed X"); final KeyStroke allKeyStroke = KeyStroke.getKeyStroke("meta pressed A"); InputMap textFieldMap = (InputMap) UIManager.get("TextField.focusInputMap"); textFieldMap.put(copyKeyStroke, DefaultEditorKit.copyAction); textFieldMap.put(pasteKeyStroke, DefaultEditorKit.pasteAction); textFieldMap.put(cutKeyStroke, DefaultEditorKit.cutAction); textFieldMap.put(allKeyStroke, DefaultEditorKit.selectAllAction); InputMap formattedTextFieldMap = (InputMap) UIManager.get("FormattedTextField.focusInputMap"); formattedTextFieldMap.put(copyKeyStroke, DefaultEditorKit.copyAction); formattedTextFieldMap.put(pasteKeyStroke, DefaultEditorKit.pasteAction); formattedTextFieldMap.put(cutKeyStroke, DefaultEditorKit.cutAction); formattedTextFieldMap.put(allKeyStroke, DefaultEditorKit.selectAllAction); InputMap textAreaMap = (InputMap) UIManager.get("TextArea.focusInputMap"); textAreaMap.put(copyKeyStroke, DefaultEditorKit.copyAction); textAreaMap.put(pasteKeyStroke, DefaultEditorKit.pasteAction); textAreaMap.put(cutKeyStroke, DefaultEditorKit.cutAction); textAreaMap.put(allKeyStroke, DefaultEditorKit.selectAllAction); InputMap editorPaneMap = (InputMap) UIManager.get("EditorPane.focusInputMap"); editorPaneMap.put(copyKeyStroke, DefaultEditorKit.copyAction); editorPaneMap.put(pasteKeyStroke, DefaultEditorKit.pasteAction); editorPaneMap.put(cutKeyStroke, DefaultEditorKit.cutAction); editorPaneMap.put(allKeyStroke, DefaultEditorKit.selectAllAction); InputMap passwordFieldMap = (InputMap) UIManager.get("PasswordField.focusInputMap"); passwordFieldMap.put(pasteKeyStroke, DefaultEditorKit.pasteAction); } } public static boolean isMacOSX() { String osname = System.getProperty("os.name"); return osname == null ? false : osname.startsWith("Mac OS X"); } }