Java 8 FocusListener - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 FocusListener class.

This code example shows how to use the following methods:focusGained
    class MainFocusListener implements FocusListener {
        public void focusGained(FocusEvent e) {
//      System.out.println("focusGained " + e.getSource()); 
            if (listenerMultiCast != null)
                if ((e.getSource() != lastFocus) || (isRepeating()))
                    listenerMultiCast.focusGained(e);
        } 
 
        public void focusLost(FocusEvent e) {
//      System.out.println(this  + " is firing"); 
            if (listenerMultiCast != null)
                if ((e.getSource() != lastFocus) || (isRepeating()))
                    listenerMultiCast.focusLost(e);
        } 
    } 
} 
4
CodeRank
This code example shows how to use the following methods:focusLost
        if (lastCompletions != null) { 
            JTextComponent comp = (JTextComponent)event.getSource();
            clearCurrentSuggestion(comp);
        } 
        if (nextFocusListener != null)
            nextFocusListener.focusLost(event);
    } 
 
    public void clearCurrentSuggestion(JTextComponent comp) {
         if (lastCompletions != null) { 
            int selStart = comp.getSelectionStart();
            String text = comp.getText();
            comp.setText(text.substring(0, selStart) + text.substring(comp.getSelectionEnd()));
            comp.setCaretPosition(selStart);
            lastCompletions = null; 
            lastShownCompletion = 0;
            lastCaretPosition = -1;
            toSetIn = null;
        } 
    } 
4
CodeRank
See Code Examples for Java 8 FocusListener Methods: