List of usage examples for java.awt.event FocusEvent getSource
public Object getSource()
From source file:org.nuclos.client.wizard.util.NuclosWizardUtils.java
public static FocusAdapter createWizardFocusAdapter() { return new FocusAdapter() { @Override// w w w . ja v a 2 s .c o m public void focusGained(FocusEvent e) { if (e.getSource() instanceof JTextComponent) { JTextComponent tf = (JTextComponent) e.getSource(); tf.setSelectionStart(0); tf.setSelectionEnd(tf.getText().length()); } } }; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java
/** * Resets the default text of the text fields if <code>null</code> or * length <code>0</code>.//from w w w .j a v a 2 s . c om * @see FocusListener#focusLost(FocusEvent) */ public void focusLost(FocusEvent e) { Object src = e.getSource(); if (src == namePane) { String text = namePane.getText(); editNames(); if (StringUtils.isBlank(text)) { namePane.getDocument().removeDocumentListener(this); namePane.setText(modifiedName); namePane.getDocument().addDocumentListener(this); firePropertyChange(EditorControl.SAVE_PROPERTY, Boolean.valueOf(false), Boolean.valueOf(true)); } } else if (src == descriptionWiki) { String text = descriptionWiki.getText(); editNames(); if (StringUtils.isBlank(text)) { descriptionWiki.removeDocumentListener(this); descriptionWiki.setText(DEFAULT_DESCRIPTION_TEXT); descriptionWiki.addDocumentListener(this); firePropertyChange(EditorControl.SAVE_PROPERTY, Boolean.valueOf(false), Boolean.valueOf(true)); } } }
From source file:org.openmicroscopy.shoola.agents.util.SelectionWizard.java
/** * Resets the values when losing the focus * @see FocusListener#focusLost(FocusEvent) *///w ww . ja v a 2 s . c o m public void focusLost(FocusEvent evt) { Object src = evt.getSource(); if (src == addField) { String value = addField.getText(); if (StringUtils.isBlank(value)) { setTextFieldDefault(addField, DEFAULT_TEXT); } } else if (src == descriptionField) { String value = descriptionField.getText(); if (StringUtils.isBlank(value)) { setTextFieldDefault(descriptionField, DEFAULT_DESCRIPTION); } } }
From source file:org.openmicroscopy.shoola.agents.util.SelectionWizard.java
/** * Resets the values when losing the focus * @see FocusListener#focusGained(FocusEvent) */// ww w. j a v a2 s. com public void focusGained(FocusEvent evt) { Object src = evt.getSource(); if (src == addField) { String value = addField.getText(); if (DEFAULT_TEXT.equals(value)) { addField.setCaretPosition(0); setTextFieldDefault(addField, null); } } else if (src == descriptionField) { String value = descriptionField.getText(); if (DEFAULT_DESCRIPTION.equals(value)) { descriptionField.setCaretPosition(0); setTextFieldDefault(descriptionField, null); } } }
From source file:org.trianacode.gui.hci.ApplicationFrame.java
/** * Invoked when a component gains the keyboard focus. *//*from w w w . j a v a2 s.co m*/ public void focusGained(FocusEvent event) { if (event.getSource() == toolboxTree) { selected = leaflistener; } else { selected = event.getSource(); } }