Examples of JTextComponent


Examples of javax.swing.text.JTextComponent

        char c = e.getKeyChar();
       
        // as a coding convenience, create a reference to the text component
        // that is typecast to JTextComponent.  this is not essential, as we
        // could typecast every reference, but this makes the code cleaner
        JTextComponent _theComponent = (JTextComponent)DataTypeInteger.this._textComponent;
        String text = _theComponent.getText();
 
        // look for illegal chars
        if ( ! DataTypeInteger.this._isSigned && c == '-') {
          // cannot use '-' when unsigned
          _beepHelper.beep(_theComponent);
View Full Code Here

Examples of javax.swing.text.JTextComponent

        char c = e.getKeyChar();
       
        // as a coding convenience, create a reference to the text component
        // that is typecast to JTextComponent.  this is not essential, as we
        // could typecast every reference, but this makes the code cleaner
        JTextComponent _theComponent = (JTextComponent)DataTypeBinary.this._textComponent;
        String text = _theComponent.getText();
                       
        // tabs and newlines get put into the text before this check,
        // so remove them
        // This only applies to Popup editing since these chars are
        // not passed to this level by the in-cell editor.
View Full Code Here

Examples of javax.swing.text.JTextComponent

        char c = e.getKeyChar();

        // as a coding convenience, create a reference to the text component
        // that is typecast to JTextComponent.  this is not essential, as we
        // could typecast every reference, but this makes the code cleaner
        JTextComponent _theComponent = (JTextComponent)DataTypeClob.this._textComponent;
        String text = _theComponent.getText();


        // handle cases of null
        // The processing is different when nulls are allowed and when they are not.
        //
View Full Code Here

Examples of javax.swing.text.JTextComponent

        this.nextFocusListener = listener;
    }

    public void keyPressed(KeyEvent e) {
      if ((toSetIn != null) && (e.getKeyCode() == KeyEvent.VK_ENTER)) {
            JTextComponent comp = (JTextComponent) e.getSource();
            int end = comp.getSelectionEnd();
            comp.select(end, end);
            e.consume();
            return;
        }
        // Cycle through alternative completions when user presses PGUP/PGDN:
        else if ((e.getKeyCode() == KeyEvent.VK_PAGE_DOWN) && (lastCompletions != null)) {
View Full Code Here

Examples of javax.swing.text.JTextComponent

    }

    public void keyTyped(KeyEvent e) {       
        char ch = e.getKeyChar();
        if (Character.isLetter(ch)) {
            JTextComponent comp = (JTextComponent) e.getSource();
           
            if ((toSetIn != null) && (toSetIn.length() > 1) &&
                    (ch == toSetIn.charAt(1))) {
                // User continues on the word that was suggested.
                toSetIn = toSetIn.substring(1);
                if (toSetIn.length() > 0) {
                    int cp = comp.getCaretPosition();
                    //comp.setCaretPosition(cp+1-toSetIn.);
                    //System.out.println(cp-toSetIn.length()+" - "+cp);
                    comp.select(cp + 1 - toSetIn.length(), cp);
                    lastBeginning = lastBeginning + ch;

                    e.consume();
                    lastCaretPosition = comp.getCaretPosition();

                    //System.out.println("Added char: '"+toSetIn+"'");
                    //System.out.println("LastBeginning: '"+lastBeginning+"'");

                    lastCompletions = findCompletions(lastBeginning, comp);
                    lastShownCompletion = 0;
                    for (int i = 0; i < lastCompletions.length; i++) {
                        Object lastCompletion = lastCompletions[i];
                        //System.out.println("Completion["+i+"] = "+lastCompletion);
                        if (((String)lastCompletion).endsWith(toSetIn)) {
                            lastShownCompletion = i;
                            break;
                        }

                    }
                    //System.out.println("Index now: "+lastShownCompletion);
                    if (toSetIn.length() < 2)
                        toSetIn = null;
                    return;
                }
            }

            if ((toSetIn != null) && ((toSetIn.length() <= 1) ||
                    (ch != toSetIn.charAt(1)))) {
                // User discontinues the word that was suggested.
                lastBeginning = lastBeginning + ch;
                Object[] completed = findCompletions(lastBeginning, comp);
                if ((completed != null) && (completed.length > 0)) {
                    lastShownCompletion = 0;
                    lastCompletions = completed;
                    String sno = (String) (completed[0]);
                    int lastLen = toSetIn.length() - 1;
                    toSetIn = sno.substring(lastBeginning.length() - 1);
                    String text = comp.getText();
                    //Util.pr(""+lastLen);
                    comp.setText(text.substring(0, lastCaretPosition - lastLen)
                            + toSetIn
                            + text.substring(lastCaretPosition));
                    comp.select(lastCaretPosition + 1 - lastLen,
                            lastCaretPosition + toSetIn.length() - lastLen);

                    lastCaretPosition = comp.getCaretPosition();
                    e.consume();
                    return;
                } else {
                    toSetIn = null;
                    return;
                }
            }


            StringBuffer currentword = getCurrentWord(comp);
            if (currentword == null)
                return;
            currentword.append(ch);

            Object[] completed = findCompletions(currentword.toString(), comp);

            int no = 0; // We use the first word in the array of completions.
            if ((completed != null) && (completed.length > 0)) {
                lastShownCompletion = 0;
                lastCompletions = completed;
                String sno = (String) (completed[no]);
                toSetIn = sno.substring(currentword.length() - 1);
                //Util.pr("AutoCompListener: Found "+completed[0]);
                StringBuffer alltext = new StringBuffer(comp.getText());
                int cp = comp.getCaretPosition();
                alltext.insert(cp, toSetIn);
                //Util.pr(alltext.toString());
                comp.setText(alltext.toString());
                comp.setCaretPosition(cp);
                comp.select(cp + 1, cp + 1 + sno.length() - currentword.length());
                e.consume();
                lastCaretPosition = comp.getCaretPosition();
                lastBeginning = currentword.toString();
                return;
            }
        }
        //Util.pr("#hm");
View Full Code Here

Examples of javax.swing.text.JTextComponent

            nextFocusListener.focusGained(event);
    }

    public void focusLost(FocusEvent event) {
        if (lastCompletions != null) {
            JTextComponent comp = (JTextComponent)event.getSource();
            clearCurrentSuggestion(comp);
        }
        if (nextFocusListener != null)
            nextFocusListener.focusLost(event);
    }
View Full Code Here

Examples of javax.swing.text.JTextComponent

      this.textActn = textActn;
      this.direction = direction;
    }

    public void actionPerformed(ActionEvent e) {
      JTextComponent c = getTextComponent(e);

      if (c.getParent() instanceof JViewport) {
        JViewport viewport = (JViewport) c.getParent();
        Point p = viewport.getViewPosition();

        if (this.direction == SwingConstants.NORTH) {
          c.setCaretPosition(c.viewToModel(p));
        } else {
          p.y += viewport.getExtentSize().height;
          c.setCaretPosition(c.viewToModel(p));
        }
      }

      textActn.actionPerformed(e);
    }
View Full Code Here

Examples of javax.swing.text.JTextComponent

     * returned.
     *
     * @return the unselected text of the combobox's textfield.
     */
    protected String getUnselectedText() {
        JTextComponent comp = getTextComponent();
        String selected = comp.getSelectedText();
        if (selected != null)
            return comp.getText().substring(0,
                    comp.getText().length() - comp.getSelectedText().length());
        return comp.getText();
    }
View Full Code Here

Examples of javax.swing.text.JTextComponent

            if (pressed == '/' || pressed == '\\') {
                pathEditListener.enabled = true;
            }
            if (e.getModifiers() == 0) {
                if (pressed == '\t') {
                    JTextComponent textComp = (JTextComponent) getEditor()
                            .getEditorComponent();
                    textComp.setCaretPosition(textComp.getText().length());
                }
                if (pressed == '\n') {
                    System.out.println("Enter");
                    File tmp = new File(getText());
                    if (tmp.exists() && tmp.isDirectory() && tmp.canRead()) {
View Full Code Here

Examples of javax.swing.text.JTextComponent

            if (!enabled || isPopupVisible()) {
                validateAndNotify();
                return;
            }
            stateModify = true;
            JTextComponent comp = getTextComponent();
            String input = getText().replaceAll("\\\\", "/");
            if (oldValue.equals(input)) {
                return;
            }
            if (comp.getCaretPosition() == input.trim().length()) {
                int pos = input.lastIndexOf('/');
                String[] sorted = getSuggestions();
                if (sorted != null && sorted.length != 0) {
                    int caretPos = comp.getCaretPosition();
                    String tillComplete = input.substring(pos + 1);
                    tillComplete = sorted[0].substring(tillComplete.length());
                    comp.setText(input + tillComplete);
                    comp.setCaretPosition(comp.getText().length());
                    if (tillComplete.length() > 0) {
                        comp.moveCaretPosition(caretPos);
                    } else {
                        comp.setCaretPosition(comp.getText().length());
                    }
                    comboModel.update();
                }
            }
            validateAndNotify();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.