javax.swing.AbstractButton.getInputMap()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(1.8k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中javax.swing.AbstractButton.getInputMap()方法的一些代码示例,展示了AbstractButton.getInputMap()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractButton.getInputMap()方法的具体详情如下:
包路径:javax.swing.AbstractButton
类名称:AbstractButton
方法名:getInputMap

AbstractButton.getInputMap介绍

暂无

代码示例

代码示例来源:origin: com.jalalkiswani/jk-desktop

final InputMap imap = btn.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);

代码示例来源:origin: de.sciss/scisslib

/**
 *  Convenience method that will add new
 *  corresponding entries in a button's input and action map,
 *  such that a given <code>KeyStroke</code> will cause a
 *  <code>DoClickAction</code> to be performed on that button.
 *  The key stroke is performed whenever the button is in
 *  the current focused window.
 *
 *  @param  comp    an <code>AbstractButton</code> to which a
 *                    a new keyboard action is attached.
 *  @param  stroke  the <code>KeyStroke</code> which causes a
 *                    click on the button.
 *
 *  @see    DoClickAction
 *  @see    javax.swing.JComponent#getInputMap( int )
 *  @see    javax.swing.JComponent#getActionMap()
 *  @see    javax.swing.JComponent#WHEN_IN_FOCUSED_WINDOW
 */
public static void createKeyAction( AbstractButton comp, KeyStroke stroke )
{
  comp.getInputMap( JComponent.WHEN_IN_FOCUSED_WINDOW ).put( stroke, "shortcut" );
  comp.getActionMap().put( "shortcut", new DoClickAction( comp ));
}

代码示例来源:origin: stackoverflow.com

public static void clickOnKey(
  final AbstractButton button, String actionName, int key )
{
  button.getInputMap( JButton.WHEN_IN_FOCUSED_WINDOW )
    .put( KeyStroke.getKeyStroke( key, 0 ), actionName );

  button.getActionMap().put( actionName, new AbstractAction()
  {
    @Override
    public void actionPerformed( ActionEvent e )
    {
      button.doClick();
    }
  } );
}

代码示例来源:origin: org.nuiton.jaxx/jaxx-application-swing

abstractButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStroke, key);
abstractButton.getActionMap().put(key, abstractButton.getAction());

相关文章

微信公众号

最新文章

更多

AbstractButton类方法