本文整理了Java中javax.swing.JTextField.getActionMap()
方法的一些代码示例,展示了JTextField.getActionMap()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextField.getActionMap()
方法的具体详情如下:
包路径:javax.swing.JTextField
类名称:JTextField
方法名:getActionMap
暂无
代码示例来源:origin: stackoverflow.com
final JList list = new JList(Locale.getAvailableLocales());
final JPopupMenu popup = new JPopupMenu();
popup.add(new JScrollPane(list));
popup.setFocusable(false);
final JTextField field = new JTextField(20);
Action down = new AbstractAction("nextElement") {
@Override
public void actionPerformed(ActionEvent e) {
int next = Math.min(list.getSelectedIndex() + 1,
list.getModel().getSize() - 1);
list.setSelectedIndex(next);
list.ensureIndexIsVisible(next);
}
};
field.getActionMap().put("nextElement", down);
field.getInputMap().put(
KeyStroke.getKeyStroke("DOWN"), "nextElement");
代码示例来源:origin: ron190/jsql-injection
textFilter.getActionMap().put("close", actionCloseSearch);
textFilter.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close");
代码示例来源:origin: stackoverflow.com
JTextField field = new JTextField();
Action action;
a = field.getActionMap().get(DefaultEditorKit.beepAction);
a.setEnabled(false);
代码示例来源:origin: stackoverflow.com
JTextField field = new JTextField();
Action action;
a = field.getActionMap().get(DefaultEditorKit.beepAction);
a.setEnabled(false);
代码示例来源:origin: stackoverflow.com
JTextField field = new JTextField();
Action action;
action = field.getActionMap().get(DefaultEditorKit.beepAction);
action.setEnabled(false);
代码示例来源:origin: stackoverflow.com
JTextField normal = new JTextField("just a normal field", 10);
final Action selectAll = normal.getActionMap().get("select-all");
final Action cut = normal.getActionMap().get("cut-to-clipboard");
Action combine = new AbstractAction() {
@Override
public void actionPerformed(final ActionEvent e) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
selectAll.actionPerformed(e);
cut.actionPerformed(e);
}
});
}
};
normal.getActionMap().put("magic-delete-all", combine);
normal.getInputMap().put(KeyStroke.getKeyStroke("A"), "magic-delete-all");
代码示例来源:origin: stackoverflow.com
final JButton btn = new JButton("Click Me!");
JTextField txt = new JTextField(10);
InputMap inputMap = txt.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
ActionMap actionMap = txt.getActionMap();
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), 13);
actionMap.put(13, new AbstractAction()
{
public void actionPerformed(ActionEvent e)
{
btn.doClick();
}
});
代码示例来源:origin: stackoverflow.com
final JTextField textfield = new JTextField();
Action enterAction = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
//do something
}};
String key = "ENTER";
KeyStroke keyStroke = KeyStroke.getKeyStroke(key);
textfield.getInputMap().put(keyStroke, key);
textfield.getActionMap().put(key, enterAction);
代码示例来源:origin: stackoverflow.com
JTable table = new JTable(myModel);
JTextField cell = new JTextField();
final TableCellEditor cellEditor = new DefaultCellEditor(cell);
table.getColumnModel().getColumn(column).setCellEditor(cellEditor);
InputMap iMap = cell.getInputMap(JComponent.WHEN_FOCUSED);
iMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), KeyEvent.getKeyText(KeyEvent.VK_ENTER));
ActionMap aMap = cell.getActionMap();
aMap.put(KeyEvent.getKeyText(KeyEvent.VK_ENTER), new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
if(callSomeOperationsIsOk()){
cellEditor.stopCellEditing();
}else{
cellEditor.cancelCellEditing();
}
}
});
}
代码示例来源:origin: com.eas.platypus/platypus-js-launcher
/**
* Creates new form LoginDialog
*
*/
public CredentialsSelector() {
super((java.awt.Frame) null, true);
initComponents();
tfUserName.getActionMap().put(OK_ACTION_ID, okAction);
tfUserName.getActionMap().put(CANCEL_ACTION_ID, cancelAction);
tfPassword.getActionMap().put(OK_ACTION_ID, okAction);
tfPassword.getActionMap().put(CANCEL_ACTION_ID, cancelAction);
tfUserName.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), OK_ACTION_ID);
tfUserName.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_ACTION_ID);
tfPassword.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), OK_ACTION_ID);
tfPassword.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_ACTION_ID);
String userName = Preferences.userRoot().node(SETTINGS_NODE).get(LOGIN_SETTING, "");
if (userName != null && !userName.isEmpty()) {
tfUserName.setText(userName);
String password = Preferences.userRoot().node(SETTINGS_NODE).get(PASSWORD_SETTING, "");
tfPassword.setText(password);
checkRememberPassword.setSelected(true);
}
}
代码示例来源:origin: stackoverflow.com
AbstractAction action = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() instanceof JButton){
JButton button = (JButton) e.getSource();
button.doClick();
} else if(e.getSource() instanceof JComponent){
JComponent component = (JComponent) e.getSource();
component.transferFocus();
}
}
};
JTextField textField1 = new JTextField();
textField1.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "TransferFocus");
textField1.getActionMap().put("TransferFocus", action);
JTextField textField2 = new JTextField();
textField2.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "TransferFocus");
textField2.getActionMap().put("TransferFocus", action);
JButton button1= new JButton();
button1.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "Enter");
button1.getActionMap().put("Enter", action);
代码示例来源:origin: stackoverflow.com
text1.getActionMap().put("copyAll", new AbstractAction() {
代码示例来源:origin: org.apache.jmeter/ApacheJMeter_components
private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
setLayout(new BorderLayout(10,10));
searchTF = new JTextField(20); //$NON-NLS-1$
InputMap im = searchTF
.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
im.put(KeyStrokes.ENTER, SEARCH_TEXT_COMMAND);
ActionMap am = searchTF.getActionMap();
am.put(SEARCH_TEXT_COMMAND, new EnterAction());
isRegexpCB = new JCheckBox(JMeterUtils.getResString("search_text_chkbox_regexp"), false); //$NON-NLS-1$
isCaseSensitiveCB = new JCheckBox(JMeterUtils.getResString("search_text_chkbox_case"), false); //$NON-NLS-1$
isRegexpCB.setFont(FONT_SMALL);
isCaseSensitiveCB.setFont(FONT_SMALL);
searchButton = new JButton(JMeterUtils.getResString("search")); //$NON-NLS-1$
searchButton.addActionListener(this);
resetButton = new JButton(JMeterUtils.getResString("reset")); //$NON-NLS-1$
resetButton.addActionListener(this);
JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
searchPanel.add(new JLabel(JMeterUtils.getResString("search_text_field")));
searchPanel.add(searchTF);
searchPanel.add(isCaseSensitiveCB);
searchPanel.add(isRegexpCB);
searchPanel.add(searchButton);
searchPanel.add(resetButton);
add(searchPanel);
}
代码示例来源:origin: aterai/java-swing-tips
ActionMap am = pf1.getActionMap();
Action beep = new DefaultEditorKit.BeepAction();
am = pf2.getActionMap();
am.put(DefaultEditorKit.pasteAction, new AbstractAction() {
@Override public void actionPerformed(ActionEvent e) {
代码示例来源:origin: com.numdata/numdata-swing
/**
* Construct spinner component.
*
* @param textField Text field with value to control.
* @param minValue Minimum value allowed.
* @param maxValue Maximum value allowed.
*/
public Spinner( final JTextField textField, final int minValue, final int maxValue )
{
super( new GridLayout( 1, 2, 0, 0 ) );
setBorder( null );
_textField = textField;
_minValue = minValue;
_maxValue = maxValue;
add( new Button( false ) );
add( new Button( true ) );
final InputMap inputMap = textField.getInputMap();
inputMap.put( KeyStroke.getKeyStroke( '+' ), "incrementValue" );
inputMap.put( KeyStroke.getKeyStroke( '-' ), "decrementValue" );
final ActionMap actionMap = textField.getActionMap();
actionMap.put( "incrementValue", new IncrementAction() );
actionMap.put( "decrementValue", new DecrementAction() );
}
代码示例来源:origin: stackoverflow.com
// "early" in the app instantiate a textField
JTextField text = new JTextField();
ActionMap map = text.getActionMap();
// get a reference to the default binding
final Action notify = map.get(JTextField.notifyAction);
while (map.getParent() != null) {
// walk up the parent chain to reach the top-most shared ancestor
map = map.getParent();
}
// custom notify action
TextAction tab = new TextAction(JTextField.notifyAction) {
@Override
public void actionPerformed(ActionEvent e) {
// delegate to default if enabled
if (notify.isEnabled()) {
notify.actionPerformed(e);
}
// trigger a focus transfer
getTextComponent(e).transferFocus();
}
};
// replace default with augmented custom action
map.put(JTextField.notifyAction, tab);
代码示例来源:origin: pentaho/pentaho-reporting
public PropertyCellEditorWithEllipsis() {
setLayout( new BorderLayout() );
this.eventListenerList = new EventListenerList();
ellipsisButton = new EllipsisButton( "..." );
ellipsisButton.addActionListener( new ExtendedEditorAction() );
textField = new JTextField();
textField.getInputMap().put
( Messages.getInstance().getKeyStroke( "PropertyCellEditorWithEllipsis.PopupEditor.Accelerator" ), POPUP_EDITOR );
textField.getActionMap().put( POPUP_EDITOR, new ExtendedEditorAction() );
textField.setBorder( BorderFactory.createEmptyBorder() );
add( textField, BorderLayout.CENTER );
add( ellipsisButton, BorderLayout.EAST );
nullable = false;
}
代码示例来源:origin: pentaho/pentaho-reporting
public ArrayCellEditor() {
setLayout( new BorderLayout() );
this.eventListenerList = new EventListenerList();
ellipsisButton = new EllipsisButton( "..." );
ellipsisButton.setDefaultCapable( false );
ellipsisButton.addActionListener( new ExtendedEditorAction() );
textField = new JTextField();
textField.setDocument( new NonFilteringPlainDocument() );
textField.getInputMap().put( Messages.getInstance().getKeyStroke
( "PropertyCellEditorWithEllipsis.PopupEditor.Accelerator" ), POPUP_EDITOR );
textField.getActionMap().put( POPUP_EDITOR, new ExtendedEditorAction() );
textField.setBorder( BorderFactory.createEmptyBorder() );
textField.setEditable( false );
add( textField, BorderLayout.CENTER );
add( ellipsisButton, BorderLayout.EAST );
nullable = false;
}
代码示例来源:origin: org.jspresso.framework/jspresso-swing-components
/**
* {@inheritDoc}
*/
@Override
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition,
boolean pressed) {
if (super.processKeyBinding(ks, e, condition, pressed)) {
return true;
}
Object binding = textField.getInputMap(condition).get(ks);
if (binding != null && textField.getActionMap().get(binding) != null) {
textField.dispatchEvent(e);
return true;
}
return false;
}
代码示例来源:origin: org.jspresso/jspresso-swing-components
/**
* {@inheritDoc}
*/
@Override
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition,
boolean pressed) {
if (super.processKeyBinding(ks, e, condition, pressed)) {
return true;
}
Object binding = textField.getInputMap(condition).get(ks);
if (binding != null && textField.getActionMap().get(binding) != null) {
textField.dispatchEvent(e);
return true;
}
return false;
}
内容来源于网络,如有侵权,请联系作者删除!