Package javax.swing.text

Examples of javax.swing.text.JTextComponent$CaretEventImpl


    private final TextUIChangeHandler uiChangeHandler = new TextUIChangeHandler();

    private final class TextUIChangeHandler extends AbstractUIChangeHandler {
        public void propertyChange(PropertyChangeEvent evt) {
            JTextComponent txt = (JTextComponent) evt.getSource();

            replaceUIIfNeeded(txt);
        }
View Full Code Here


     */
    @Override
    public void installUI(JComponent c) {
        delegate.installUI(c);

        JTextComponent txt = (JTextComponent) c;

        // repaint to correctly highlight text if FocusBehavior is
        // HIGHLIGHT_LABEL in Metal and Windows LnF
        txt.addFocusListener(focusHandler);
    }
View Full Code Here

     * {@link #getPromptComponent(JTextComponent)} and it's preferred size is
     * returned. Otherwise super{@link #getPreferredSize(JComponent)} is called.
     */
    @Override
    public Dimension getPreferredSize(JComponent c) {
        JTextComponent txt = (JTextComponent) c;
        if (shouldPaintPrompt(txt)) {
            return getPromptComponent(txt).getPreferredSize();
        }
        return delegate.getPreferredSize(c);
    }
View Full Code Here

     * {@link #getPromptComponent(JTextComponent)} and painted. Then the caret
     * of the given text component is painted.
     */
    @Override
    public void paint(Graphics g, final JComponent c) {
        JTextComponent txt = (JTextComponent) c;

        if (shouldPaintPrompt(txt)) {
            paintPromptComponent(g, txt);
        } else {
            delegate.paint(g, c);
View Full Code Here

            delegate.paint(g, c);
        }
    }

    protected void paintPromptComponent(Graphics g, JTextComponent txt) {
        JTextComponent lbl = getPromptComponent(txt);
        lbl.paint(g);

        if (txt.getCaret() != null) {
            txt.getCaret().paint(g);
        }
    }
View Full Code Here

        comboBox.setEditable(true);
        // fix the popup location
        MacOSXPopupLocationFix.install(comboBox);

        // configure the text component=editor component
        JTextComponent editorComponent = (JTextComponent) comboBox.getEditor().getEditorComponent();
        final AbstractAutoCompleteAdaptor adaptor = new ComboBoxAdaptor(comboBox);
        final AutoCompleteDocument document = createAutoCompleteDocument(adaptor, strictMatching,
                stringConverter, editorComponent.getDocument());
        decorate(editorComponent, document, adaptor);
       
        editorComponent.addKeyListener(new AutoComplete.KeyAdapter(comboBox));
       
        //set before adding the listener for the editor
        comboBox.setEditor(new AutoCompleteComboBoxEditor(comboBox.getEditor(), document.stringConverter));
       
        // Changing the l&f can change the combobox' editor which in turn
View Full Code Here

            }
        }
    }

    static void undecorate(JComboBox comboBox) {
        JTextComponent editorComponent = (JTextComponent) comboBox.getEditor().getEditorComponent();
       
        if (editorComponent.getDocument() instanceof AutoCompleteDocument) {
            AutoCompleteDocument doc = (AutoCompleteDocument) editorComponent.getDocument();
           
            if (doc.strictMatching) {
                ActionMap map = comboBox.getActionMap();
               
                for (String key : COMBO_BOX_ACTIONS) {
                    map.put(key, null);
                }
            }
           
            //remove old property change listener
            for (PropertyChangeListener l : comboBox.getPropertyChangeListeners("editor")) {
                if (l instanceof AutoComplete.PropertyChangeListener) {
                    comboBox.removePropertyChangeListener("editor", l);
                }
            }
           
            AutoCompleteComboBoxEditor editor = (AutoCompleteComboBoxEditor) comboBox.getEditor();
            comboBox.setEditor(editor.wrapped);
           
            //remove old key listener
            for (KeyListener l : editorComponent.getKeyListeners()) {
                if (l instanceof AutoComplete.KeyAdapter) {
                    editorComponent.removeKeyListener(l);
                    break;
                }
            }
           
            undecorate(editorComponent);
View Full Code Here

           
            AutoCompleteComboBoxEditor acEditor = (AutoCompleteComboBoxEditor) evt.getOldValue();
            boolean strictMatching = false;
           
            if (acEditor.getEditorComponent() != null) {
                JTextComponent textComponent = (JTextComponent) acEditor.getEditorComponent();
                strictMatching = ((AutoCompleteDocument) textComponent.getDocument()).strictMatching;
               
                undecorate(textComponent);
               
                for (KeyListener l : textComponent.getKeyListeners()) {
                    if (l instanceof KeyAdapter) {
                        textComponent.removeKeyListener(l);
                        break;
                    }
                }
            }

            JTextComponent editorComponent = (JTextComponent) comboBox.getEditor().getEditorComponent();
            AbstractAutoCompleteAdaptor adaptor = new ComboBoxAdaptor(comboBox);
            AutoCompleteDocument document = createAutoCompleteDocument(adaptor, strictMatching,
                    acEditor.stringConverter, editorComponent.getDocument());
            decorate(editorComponent, document, adaptor);
           
            editorComponent.addKeyListener(new AutoComplete.KeyAdapter(comboBox));
           
            //set before adding the listener for the editor
            comboBox.setEditor(new AutoCompleteComboBoxEditor(comboBox.getEditor(), document.stringConverter));
        }
View Full Code Here

         * {@inheritDoc}
         */
        @Override
        public void actionPerformed(ActionEvent e) {
            JComboBox comboBox = (JComboBox) e.getSource();
            JTextComponent textComponent = (JTextComponent) comboBox.getEditor().getEditorComponent();
            AutoCompleteDocument doc = (AutoCompleteDocument) textComponent.getDocument();
           
            // doing this prevents the updating of the selected item to "" during the remove prior
            // to the insert in JTextComponent.setText
            doc.strictMatching = true;
            try {
View Full Code Here

    @Override
    public void installUI(JComponent c) {
        super.installUI(c);

        JTextComponent textComponent = (JTextComponent) c;

        textComponent.setOpaque(false);
        textComponent.setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createLineBorder(HudPaintingUtils.BORDER_COLOR),
                BorderFactory.createEmptyBorder(1, 2, 1, 2)));
        textComponent.setBackground(new Color(0, 0, 0, 0));
        textComponent.setForeground(HudPaintingUtils.FONT_COLOR);
        textComponent.setFont(HudPaintingUtils.getHudFont());
        textComponent.setSelectedTextColor(Color.BLACK);
        textComponent.setSelectionColor(HudPaintingUtils.FONT_COLOR);
        textComponent.setCaretColor(HudPaintingUtils.FONT_COLOR);
    }
View Full Code Here

TOP

Related Classes of javax.swing.text.JTextComponent$CaretEventImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.