Here you can find the source of addEnterAction(JComponent c, Action a)
public static void addEnterAction(JComponent c, Action a)
//package com.java2s; // License: GPL. For details, see LICENSE file. import java.awt.event.KeyEvent; import javax.swing.Action; import javax.swing.JComponent; import javax.swing.KeyStroke; public class Main { public static void addEnterAction(JComponent c, Action a) { c.getActionMap().put("enter", a); c.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "enter"); }/*from w w w .j av a2 s. com*/ }