Component addFocusListener - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Component addFocusListener method.

This code example shows how to use the following methods:addFocusListener, setLineWrap, setRows, setWrapStyleWord, setDocument
     *            The text to display in the label. 
     * @param docModel the document for the text area 
     */ 
    public JLabeledTextArea(String pLabel, Document docModel) {
        super(); 
        mTextArea = new JTextArea();
        mLabel = new JLabel(pLabel);
        init(); 
        if (docModel != null) {
            mTextArea.setDocument(docModel);
        } 
    } 
 
    /** 
     * Get the label {@link JLabel} followed by the text field @link {@link JTextArea}. 
     */ 
    @Override 
    public List<JComponent> getComponentList() {
        List<JComponent> comps = new LinkedList<JComponent>();
        comps.add(mLabel);

7
CodeRank
This code example shows how to use the following methods:addFocusListener, hasFocus, isFocusable, requestFocusInWindow
        } 
        return true; 
    } 
 
    protected void checkFocusAndShowMenu(final Component component, final MouseEvent evt) {
        if (component != null && component.isFocusable() && !component.hasFocus() && component.requestFocusInWindow()) {
            component.addFocusListener(new FocusListener() {
                @Override public void focusLost(FocusEvent e) {}
                @Override public void focusGained(FocusEvent e) {
                    showMenu(evt);
                    component.removeFocusListener(this);
                } 
            }); 
        } else { 
            showMenu(evt);
        } 
    } 
 
    protected void showMenu(MouseEvent evt) {
        if (menu != null && evt != null) {
6
CodeRank
This code example shows how to use the following methods:addFocusListener, addActionListener, setActionCommand
        plotPanel.add(this.angleOffset);
        plotPanel.add(new JPanel());
 
        plotPanel.add(new JLabel(localizationResources.getString(
                "Manual_TickUnit_value"))); 
        this.manualTickUnit = new JTextField(Double.toString(
                this.manualTickUnitValue));
        this.manualTickUnit.setActionCommand("TickUnitValue");
        this.manualTickUnit.addActionListener(this);
        this.manualTickUnit.addFocusListener(this);
        plotPanel.add(this.manualTickUnit);
        plotPanel.add(new JPanel());
 
        return plotPanel;
    } 
 
    /** 
     * Does nothing. 
     * 
     * @param event  the event. 
6
CodeRank
This code example shows how to use the following methods:addFocusListener, setFont, setEditable
        return jscrollpane;
    } 
 
    private JComponent c() {
        JPanel jpanel = new JPanel(new BorderLayout());
        JTextArea jtextarea = new JTextArea();
        JScrollPane jscrollpane = new JScrollPane(jtextarea, 22, 30);
 
        jtextarea.setEditable(false);
        jtextarea.setFont(a);
        JTextField jtextfield = new JTextField();
 
        jtextfield.addActionListener(new ServerGuiCommandListener(this, jtextfield));
        jtextarea.addFocusListener(new ServerGuiFocusAdapter(this));
        jpanel.add(jscrollpane, "Center");
        jpanel.add(jtextfield, "South");
        jpanel.setBorder(new TitledBorder(new EtchedBorder(), "Log and chat"));
        Thread thread = new Thread(new ServerGuiThreadRunnable(this, jtextarea, jscrollpane));
 
        thread.setDaemon(true);
6
CodeRank
This code example shows how to use the following methods:addFocusListener, setName
 
        _prefix = new JTextField(5);
        _prefix.setName(PREFIX);
        panel.add(createLabeledField("id_prefix", _prefix)); //$NON-NLS-1$ resource name
 
        _lowerBound = new JTextField(ZERO, 5);
        _lowerBound.addFocusListener(this);
        _lowerBound.setName(LOWERBOUND);
        panel.add(createLabeledField("lower_bound", _lowerBound)); //$NON-NLS-1$ resource name
 
        _upperBound = new JTextField("10", 5);
        _upperBound.addFocusListener(this);
        _upperBound.setName(UPPERBOUND);
        panel.add(createLabeledField("upper_bound", _upperBound)); //$NON-NLS-1$ resource name
 
        _increment = new JTextField("1", 3);
        _increment.addFocusListener(this);
        _increment.setName(INCREMENT);
        panel.add(createLabeledField("increment", _increment)); //$NON-NLS-1$ resource name
 
6
CodeRank
This code example shows how to use the following methods:addFocusListener, addActionListener, setActionCommand
        } 
        else { 
            setLayout(new GridLayout(2, 1));
        } 
 
        fTextValue = new JTextField(width);
        fTextValue.setActionCommand(QUANTITY);
        add(fTextValue);
 
        fLabelUnits = new JLabel();
        setAbbreviate(fAbbreviate);
 
        add(fLabelUnits);
 
        updateText(); 
 
        Quantity.addDefaultUnitsChangeListener(fClass, this);
        addListeners(); 
 
    } 

5
CodeRank
This code example shows how to use the following methods:addFocusListener, setText
    protected JComponent doBindControl()
    { 
        final ValueModel valueModel = getValueModel();
        try 
        { 
            textComponent.setText((String) valueModel.getValue());
        } 
        catch (ClassCastException e)
        { 
            IllegalArgumentException ex = new IllegalArgumentException("Class cast exception converting '"
                    + getProperty() + "' property value to string - did you install a type converter?"); 
            ex.initCause(e);
            throw ex;
        } 
//        if (getPromptKey() != null) 
//            PromptSupport.setPrompt(RcpSupport.getMessage(getPromptKey()), textComponent); 
        new AsYouTypeTextComponentAdapter(textComponent, valueModel, convertEmptyStringToNull);
        if(selectAllOnFocus)
        { 
            textComponent.addFocusListener(new SelectAllFocusListener(textComponent));

6
CodeRank
This code example shows how to use the following methods:addFocusListener
        super.setEnabled(enable);
        mTextField.setEnabled(enable);
    } 
 
    protected JTextField createTextField(int size) {
        return new JTextField(size);
    } 
 
    /** 
     * Initialises all of the components on this panel. 
     */ 
    private void init() { 
        setLayout(new BorderLayout(5, 0));
        // Register the handler for focus listening. This handler will 
        // only notify the registered when the text changes from when 
        // the focus is gained to when it is lost. 
        mTextField.addFocusListener(this);
 
        // Add the sub components 
        add(mLabel, BorderLayout.WEST);

5
CodeRank
This code example shows how to use the following methods:addFocusListener, addActionListener
 
    /// 
    /// number of groups 
    Box xBox = Box.createHorizontalBox();
    xBox.add(new JLabel("Add Group:"));
    final JTextField newGroup = new JTextField(10);
    xBox.add(newGroup);
    newGroup.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e)
      { 
        addGroup(newGroup.getText().trim());
      } 
    }); 
    newGroup.addFocusListener(new java.awt.event.FocusAdapter() {
      public void focusGained(java.awt.event.FocusEvent evt) {
        SwingUtilities.invokeLater( new Runnable() {
          public void run() { 
            newGroup.selectAll();              
          } 
        }); 

6
CodeRank
This code example shows how to use the following methods:addFocusListener, addActionListener
addFocusListener Method Overview
Adds the specified focus listener to receive focus events from this component when this component gains input focus.
See Code Examples for other Java 8 Component Methods: