Package javax.swing.text

Examples of javax.swing.text.Document


    }

    private void addListeners() {

        // Respond to document changes with verification and model changes:
        Document doc = getDocument();
        doc.addDocumentListener(this);

        // Update text when the model changes:
        model.addChangeListener(this);

        // Select-all when we gain focus, select-none when we lose:
View Full Code Here


        setMaximumSize(size);

        update();

        setInputVerifier(new AngleVerifier());
        Document doc = getDocument();
        doc.addDocumentListener(this);

        addMouseWheelListener(this);

        addFocusListener(
            new FocusAdapter() {
View Full Code Here

        private JTextField text;

        ExportUpdater(IntegerExportOption option, JTextField text) {
            this.option = option;
            this.text = text;
            Document doc = text.getDocument();
            doc.addDocumentListener(this);
        }
View Full Code Here

        fixSize();
        setNumber(0);
        this.listener = listener;
        setHorizontalAlignment(RIGHT);
        setInputVerifier(new PositiveNumberVerifier());
        Document doc = getDocument();
        doc.addDocumentListener(this);
        addFocusListener(FocusSelector);
        registerKeyboardActions();
    }
View Full Code Here

            DownAction,
            "Decrement",
            KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0),
            WHEN_FOCUSED
        );
        Document doc = getDocument();
        doc.addDocumentListener(TextUpdater);

        Dimension size = getPreferredSize();
        setMinimumSize(size);
        setPreferredSize(size);
        setMaximumSize(size);
View Full Code Here

                Container parent = editor.getParent();
                parent.repaint();
                return;
            }

            Document doc = editor.getDocument();
            try {
                editor.setPage(url);
            } catch (IOException e) {
                editor.setDocument(doc);
                getToolkit().beep();
View Full Code Here

   
    removeHighlights(textComp);
    if (pattern.length() > 0)
      try {
        Highlighter hilite = textComp.getHighlighter();
        Document doc = textComp.getDocument();
        String text = doc.getText(0, doc.getLength());
        text = text.toUpperCase();
        pattern = pattern.toUpperCase();
        int pos = textComp.getCaretPosition();
        if ((pos = text.indexOf(pattern, pos)) != -1)
          if (findAll == 0) {
View Full Code Here

      }
  }

  private static void replace(JTextComponent textComp, String pattern, int replaceAll) {
    removeHighlights(textComp);
    Document doc = textComp.getDocument();
    String text = "";
    try {
      text = doc.getText(0, doc.getLength());
      int pos = textComp.getCaretPosition();
      if (textComp.getSelectedText() != null) {
        String replacement = pattern;
        pattern = textComp.getSelectedText();
        if (replaceAll == 0) {
          textComp.replaceSelection(replacement);
        } else {
          textComp.replaceSelection(replacement);
          text = doc.getText(0, doc.getLength());
          for (; (pos = text.indexOf(pattern, pos)) >= 0; pos += replacement.length()) {
            textComp.setSelectionStart(pos);
            textComp.setSelectionEnd(pos + pattern.length());
            textComp.replaceSelection(replacement);
          }
View Full Code Here

        Highlighter highlighter = editorPane.getHighlighter();
        highlighter.removeAllHighlights();

        // get the text desplayed on the pane
        String text = "";
        Document doc = editorPane.getDocument();
        try {
            text = doc.getText(0, doc.getLength()).toLowerCase();
        } catch (BadLocationException e1) {
            Debug.error(e1);
            return;
        }
View Full Code Here

    private boolean searchPage(URL page, String searchText) {
        try {
            // create a document instance to search only in the view
            // and to exlude the formatting texts like HTML tags
            HTMLEditorKit editorKit = new HTMLEditorKit();
            Document doc = editorKit.createDefaultDocument();
            doc.putProperty("IgnoreCharsetDirective", new Boolean(true));
            editorKit.read(page.openStream(), doc, 0);

            String content = doc.getText(0, doc.getLength());

            return content.toLowerCase().indexOf(searchText.toLowerCase()) > -1;
        } catch (Exception e) {
            Debug.error(e);
        }
View Full Code Here

TOP

Related Classes of javax.swing.text.Document

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.