Package javax.swing.text

Examples of javax.swing.text.Document


        panel.add(fixedHeight(new JLabel("Birthdate")));
        panel.add(Box.createHorizontalStrut(10));

        final JTextField birthdateField = new JTextField(iBirthdateStr + ' ');
        Document doc = birthdateField.getDocument();
        doc.addDocumentListener(new DocumentListener() {
            public void insertUpdate(DocumentEvent e) {
                update(e);
            }
            public void removeUpdate(DocumentEvent e) {
                update(e);
View Full Code Here


  public Object convert(final ReportElement source, final Object value)
  {
    try
    {
      final Document doc = RichTextConverterUtilities.parseDocument(editorKit, value);
      if (doc == null)
      {
        return value;
      }

      final Element element = process(doc.getDefaultRootElement());
      final Band band = RichTextConverterUtilities.convertToBand(StyleKey.getDefinedStyleKeys(), source, element);
      band.getStyle().setStyleProperty(BandStyleKeys.LAYOUT, "inline");
      return band;
    }
    catch (Exception e)
View Full Code Here

 
  protected void append(final String toAppend, final AttributeSet style) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        try {
          Document doc = area.getDocument();
          doc.insertString(doc.getLength(), toAppend, style);
          area.setCaretPosition(doc.getLength());
//          area.select(area.getCaretPosition(), area.getCaretPosition());

          // Cut the document to fit into the MAX_DOC_SIZE.
          // See JRUBY-4237.
          int extra = doc.getLength() - MAX_DOC_SIZE;
          if (extra > 0) {
            int removeBytes = extra + MAX_DOC_SIZE / 10;
            doc.remove(0, removeBytes);
            startPos -= removeBytes;
          }
        } catch (BadLocationException e) {
        }
      }
View Full Code Here

  }

  private void del_chars(int i) {

    try {
      Document doc = area.getDocument();
      int offs = area.getCaretPosition() + i;
      doc.remove(offs, -i);
    } catch (BadLocationException e) {
    }

  }
View Full Code Here

    SwingUtilities.invokeLater(new Runnable() {
      public void run() {

        try {
          Document doc = area.getDocument();
          int pos = area.getCaretPosition();
          doc.insertString(pos, string, inputStyle);
          area.setCaretPosition(pos + string.length());
          area.select(area.getCaretPosition(), area.getCaretPosition());

          // Cut the document to fit into the MAX_DOC_SIZE.
          // See JRUBY-4237.
          int extra = doc.getLength() - MAX_DOC_SIZE;
          if (extra > 0) {
            int removeBytes = extra + MAX_DOC_SIZE / 10;
            doc.remove(0, removeBytes);
            startPos -= removeBytes;
          }
        } catch (BadLocationException e) {
        }
View Full Code Here

          try {
            final String s = e.getURL().toExternalForm();
            pane.setPage(s);
          } catch (final Throwable t) {
            try {
              final Document doc = pane.getDocument();
              final String content = doc.getText(0, doc
                  .getLength());
              String searchString = " \n"
                + e.getDescription().substring(1);
              int pos = content.indexOf(searchString);
              if (pos == -1) {
View Full Code Here

          StyleSheet styleSheet = kit.getStyleSheet();
          styleSheet.addRule("body {font-family:\"Helvetica Neue\", Arial, Helvetica, sans-serif;}");
          styleSheet.addRule("h1 {margin:2px;padding:2px;}");
          styleSheet.addRule("p {margin:2px;padding:2px;}");

          Document doc = kit.createDefaultDocument();
          pane.setDocument(doc);
          pane.setText(html);

          if(hasFocus)
          {
View Full Code Here

        initComponents();


        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(uk.co.nimp.scardterminalmanager.ScardTerminalManagerApp.class).getContext().getResourceMap(ScardTerminalManagerAboutBox.class);

        Document doc=infoTextArea.getDocument();
        StringBuilder sb=new StringBuilder();
        sb.append("Product: ");
        sb.append(resourceMap.getString("appTitleLabel1.text"));
        sb.append("\nversion:      ");
        sb.append(resourceMap.getString("appVersionLabel1.text"));
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("uk/co/nimp/scardterminalmanager/resources/BuildNumber"); // NOI18N
        sb.append("\nbuild number: ");
        sb.append(bundle.getString("build.number"));
        sb.append("\n\nJava properties:\n");
        Properties p=System.getProperties();
       
        for(Object key:p.keySet()){
            sb.append(key);
            sb.append(": ");
            sb.append(p.get(key));
            sb.append("\n");
        }
        try {
            doc.insertString(0, sb.toString(), null);
            infoTextArea.setCaretPosition(0);
        } catch (BadLocationException ex) {
            Logger.getLogger(ScardTerminalManagerAboutBox.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
View Full Code Here

    /**
     * Applys the tag to the current selection
     */
    protected void applyTag(HTML.Tag tag) {
        Document doc = getDocument();
        if (!(doc instanceof HTMLDocument)) {
            return;
        }
        HTMLDocument hdoc = (HTMLDocument)doc;
        int start = getSelectionStart();
View Full Code Here

    private class PropertyHandler implements PropertyChangeListener {
        public void propertyChange(PropertyChangeEvent evt) {
            String name = evt.getPropertyName();
            if (name.equals("document")) {
                Document doc = (Document)evt.getOldValue();
                if (doc != null) {
                    doc.removeUndoableEditListener(getUndoableEditListener());
                }

                doc = (Document)evt.getNewValue();
                if (doc != null) {
                    doc.addUndoableEditListener(getUndoableEditListener());
                }
            }
        }
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.