org.netbeans.editor.Utilities.keySequenceToString()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(92)

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

Utilities.keySequenceToString介绍

[英]Creates nice textual description of sequence of KeyStrokes. Usable for displaying MultiKeyBindings. The keyStrokes are delimited by space.
[中]创建击键序列的良好文本描述。可用于显示多键绑定。按键由空格分隔。

代码示例

代码示例来源:origin: net.java.abeille/abeille

public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    setText(Utilities.keySequenceToString((KeyStroke[]) value));
    setBackground(isSelected ? list.getSelectionBackground() : list.getBackground());
    setForeground(isSelected ? list.getSelectionForeground() : list.getForeground());
    return this;
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    setText( Utilities.keySequenceToString( (KeyStroke[])value ) );
    setBackground(isSelected ? list.getSelectionBackground() : list.getBackground() );
    setForeground(isSelected ? list.getSelectionForeground() : list.getForeground() );
    return this;
  }        
}

代码示例来源:origin: net.java.abeille/abeille

String getCollisionString(KeyStroke[] seq) {
  if (seq.length == 0)
    return null; // NOI18N not valid sequence, but don't alert
            // user
  Settings.KitAndValue[] kv = Settings.getValueHierarchy(kitClass, SettingsNames.KEY_BINDING_LIST);
  for (int i = 0; i < kv.length; i++) {
    Iterator iter = ((List) kv[i].value).iterator();
    while (iter.hasNext()) {
      MultiKeyBinding b = (MultiKeyBinding) iter.next();
      KeyStroke[] ks = b.keys;
      if (ks == null && b.key != null) {
        ks = new KeyStroke[1];
        ks[0] = b.key;
      }
      if (ks != null && isOverlapingSequence(ks, seq)) {
        Object[] values = { Utilities.keySequenceToString(ks), b.actionName };
        return MessageFormat.format(LocaleSupport.getString("MSP_FMT_Collision"), values); // NOI18N
      }
    }
  }
  return null; // no colliding sequence
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

String getCollisionString( KeyStroke[] seq ) {
  if( seq.length == 0 ) return null; // NOI18N   not valid sequence, but don't alert user
  Settings.KitAndValue[] kv = Settings.getValueHierarchy( kitClass, SettingsNames.KEY_BINDING_LIST );
  for (int i = 0; i < kv.length; i++)
  {
    Iterator iter = ((List)kv[i].value).iterator();
    while( iter.hasNext() ) {
      MultiKeyBinding b = (MultiKeyBinding)iter.next();
      KeyStroke[] ks = b.keys;
      if (ks == null && b.key != null)
      {
        ks = new KeyStroke[1];
        ks[0] = b.key;
      }
      if( ks !=  null && isOverlapingSequence( ks, seq ) ) {
        Object[] values = { Utilities.keySequenceToString( ks ), b.actionName };
        return MessageFormat.format( LocaleSupport.getString( "MSP_FMT_Collision" ), values ); // NOI18N
      }
    }
  }
  return null;  // no colliding sequence
}

相关文章