本文整理了Java中java.awt.event.KeyEvent.getSource()
方法的一些代码示例,展示了KeyEvent.getSource()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyEvent.getSource()
方法的具体详情如下:
包路径:java.awt.event.KeyEvent
类名称:KeyEvent
方法名:getSource
暂无
代码示例来源:origin: runelite/runelite
private void newAutocomplete(KeyEvent e)
{
final JTextComponent input = (JTextComponent)e.getSource();
final String inputText = input.getText();
final String nameStart = inputText.substring(0, input.getSelectionStart()) + e.getKeyChar();
if (findAutocompleteName(nameStart))
{
// Assert this.autocompleteName != null
final String name = this.autocompleteName;
SwingUtilities.invokeLater(() ->
{
try
{
input.getDocument().insertString(
nameStart.length(),
name.substring(nameStart.length()),
null);
input.select(nameStart.length(), name.length());
}
catch (BadLocationException ex)
{
log.warn("Could not autocomplete name.", ex);
}
});
}
}
代码示例来源:origin: runelite/runelite
@Override
public void keyTyped(KeyEvent e)
final JTextComponent input = (JTextComponent)e.getSource();
final String inputText = input.getText();
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@Override
public void keyReleased(KeyEvent e) {
String curText = ((JTextComponent) e.getSource()).getText();
curText = curText.replaceAll(allowedRegex, "");
((JTextComponent) e.getSource()).setText(curText);
}
});
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@Override
public void keyReleased(KeyEvent e) {
String curText = ((JTextComponent) e.getSource()).getText();
curText = curText.replaceAll(allowedRegex, "");
((JTextComponent) e.getSource()).setText(curText);
}
});
代码示例来源:origin: nodebox/nodebox
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_UP) {
if (e.getSource() == searchField)
moveUp();
} else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
if (e.getSource() == searchField)
moveDown();
} else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
selectAndClose();
}
}
}
代码示例来源:origin: winterDroid/android-drawable-importer-intellij-plugin
@Override
public void keyReleased(KeyEvent keyEvent) {
controller.setTargetRoot(((JTextField) keyEvent.getSource()).getText());
}
});
代码示例来源:origin: winterDroid/android-drawable-importer-intellij-plugin
@Override
public void keyReleased(KeyEvent keyEvent) {
controller.setTargetRoot(((JTextField) keyEvent.getSource()).getText());
}
});
代码示例来源:origin: tomighty/tomighty
@Override
public void keyTyped(KeyEvent e) {
if(!Character.isDigit(e.getKeyChar())) {
e.consume();
return;
}
JTextField field = (JTextField) e.getSource();
String text = field.getText();
if(text == null) return;
boolean reachedMaxLength = text.length() >= maxLength;
boolean noTextSelected = field.getSelectedText() == null;
if(reachedMaxLength && noTextSelected) {
e.consume();
}
}
代码示例来源:origin: igniterealtime/Spark
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_RIGHT &&
((JTextField)e.getSource()).getCaretPosition()==((JTextField)e.getSource()).getText().length())
{
getPopup().show(otherUsers,0,0);
}
}
代码示例来源:origin: otros-systems/otroslogviewer
@Override
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
if (keyCode == KeyEvent.VK_DELETE) {
ActionEvent actionEvent = new ActionEvent(e.getSource(), ActionEvent.ACTION_PERFORMED, "");
deleteAction.actionPerformed(actionEvent);
}
}
});
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-gsf
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_SPACE || e.getKeyCode() == KeyEvent.VK_ENTER ) {
if ( e.getSource() instanceof JTree ) {
JTree tree = (JTree) e.getSource();
TreePath path = tree.getSelectionPath();
if ( toggle( path )) {
e.consume();
}
}
}
}
代码示例来源:origin: elki-project/elki
@Override
public void keyPressed(KeyEvent e) {
if((e.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0) {
if(e.getKeyCode() == KeyEvent.VK_SPACE //
|| e.getKeyCode() == KeyEvent.VK_ENTER //
|| e.getKeyCode() == KeyEvent.VK_DOWN //
|| e.getKeyCode() == KeyEvent.VK_KP_DOWN) {
e.consume();
actionPerformed(new ActionEvent(e.getSource(), ActionEvent.ACTION_PERFORMED, "assist"));
}
}
}
代码示例来源:origin: infinitest/infinitest
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
JTree tree = (JTree) e.getSource();
Object lastPathComponent = tree.getSelectionPath().getLastPathComponent();
if (lastPathComponent instanceof TestEvent) {
TestEvent event = (TestEvent) lastPathComponent;
showInfoPane(event);
}
}
}
代码示例来源:origin: net.sf.jung/jung-visualization
@Override
public void keyTyped(KeyEvent event) {
char keyChar = event.getKeyChar();
if(keyChar == t) {
((Component)event.getSource()).setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
graphMouse.setMode(Mode.TRANSFORMING);
} else if(keyChar == p) {
((Component)event.getSource()).setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
graphMouse.setMode(Mode.PICKING);
}
}
}
代码示例来源:origin: mucommander/mucommander
/**
* Catches key events to automagically select custom folder radio button if it was not already selected.
*/
public void keyTyped(KeyEvent e) {
Object source = e.getSource();
if(source==leftCustomFolderTextField || source==rightCustomFolderTextField) {
if(!customFoldersRadioButton.isSelected())
customFoldersRadioButton.setSelected(true);
}
}
代码示例来源:origin: igniterealtime/Spark
@Override
public void keyReleased(KeyEvent e) {
JTextField textField = (JTextField)e.getSource();
String text = textField.getText();
List<RowFilter<Object,Object>> filters = new ArrayList<>();
filters.add(RowFilter.regexFilter(text, 1));
filters.add(RowFilter.regexFilter(text, 2));
filters.add(RowFilter.regexFilter(text, 3));
RowFilter<Object,Object> af = RowFilter.orFilter(filters);
sorter.setRowFilter(af);
}
});
代码示例来源:origin: org.nuiton.jaxx/jaxx-widgets
public void onKeyPressedOnUniverseList(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
int lastIndice = ui.getUniverseList().getSelectionModel().getLeadSelectionIndex();
select();
JList source = (JList) e.getSource();
if (source.getModel().getSize() > 0) {
source.setSelectedIndex(Math.min(lastIndice, source.getModel().getSize() - 1));
} else {
ui.getSelectedList().requestFocus();
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-j2ee-sun-appsrv
private void descFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_descFieldKeyReleased
ResourceConfigData data = this.helper.getData();
String value = data.getString(__Description);
String newValue = descField.getText();
if (!value.equals(newValue)) {
this.helper.getData().setString(__Description, newValue);
}
this.panel.fireChange(evt.getSource());
}//GEN-LAST:event_descFieldKeyReleased
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-j2ee-sun-appsrv
private void jndiNameFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jndiNameFieldKeyReleased
ResourceConfigData data = this.helper.getData();
String value = data.getString(__JndiName);
String newValue = jndiNameField.getText();
if (!value.equals(newValue)) {
this.helper.getData().setString(__JndiName, newValue);
}
this.panel.fireChange(evt.getSource());
}//GEN-LAST:event_jndiNameFieldKeyReleased
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-refactoring
@Override
public void processKeyEvent(KeyEvent evt) {
if (evt.getID() == KeyEvent.KEY_TYPED) {
JTextComponent component = (JTextComponent) evt.getSource();
int caretOffset = component.getSelectionEnd();
final int len = caretOffset - substitutionOffset;
if (len < 0) {
Completion.get().hideDocumentation();
Completion.get().hideCompletion();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!