Package javax.swing.text

Examples of javax.swing.text.DefaultStyledDocument


                              String type,
                              String encoding) throws IOException {

        try {
            RTFEditorKit rek = new RTFEditorKit();
            DefaultStyledDocument doc = new DefaultStyledDocument();
            rek.read(stream, doc, 0);
            String text = doc.getText(0, doc.getLength());
            return new StringReader(text);
        } catch (BadLocationException e) {
            logger.warn("Failed to extract RTF text content", e);
            return new StringReader("");
        } finally {
View Full Code Here


public class JColorPane extends JTextPane {
  private StyledDocument sd;

  public JColorPane(){
    super();
    sd = new DefaultStyledDocument();
    setDocument(sd);
  }
View Full Code Here

       
        textEditor.setDragEnabled(editable);
       
        initActions();
       
        DefaultStyledDocument doc = new DefaultStyledDocument();
        doc.setDocumentFilter(new GroovyFilter(doc));
        textEditor.setDocument(doc);

        // create and add the undo/redo manager
        this.undoManager = new TextUndoManager();
        doc.addUndoableEditListener(undoManager);
       
        // add the undo actions
        undoManager.addPropertyChangeListener(undoAction);
        undoManager.addPropertyChangeListener(redoAction);

        doc.addDocumentListener(undoAction);
        doc.addDocumentListener(redoAction);
       
        InputMap im = textEditor.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
        KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK, false);
        im.put(ks, StructuredSyntaxResources.UNDO);
        ActionMap am = textEditor.getActionMap();
View Full Code Here

public class RTFTextExtractorTest extends TestCase {

    public void testExtractor() throws IOException {
        // JCR-1881: Only run the test if the underlying libraries work
        try {
            new DefaultStyledDocument();
        } catch (Throwable t) {
            return;
        }

        TextExtractor extractor = new RTFTextExtractor();
View Full Code Here

                              String type,
                              String encoding) throws IOException {

        try {
            RTFEditorKit rek = new RTFEditorKit();
            DefaultStyledDocument doc = new DefaultStyledDocument();
            rek.read(stream, doc, 0);
            String text = doc.getText(0, doc.getLength());
            return new StringReader(text);
        } catch (Throwable t) {
            logger.warn("Failed to extract RTF text content", t);
            return new StringReader("");
        } finally {
View Full Code Here

        shellPopup.add(new JMenuItem(CUT)).addActionListener(this);
        shellPopup.add(new JMenuItem(COPY)).addActionListener(this);
        shellPopup.add(new JMenuItem(PASTE)).addActionListener(this);
       
        // shell window
        doc = new DefaultStyledDocument();
        shell = new JTextPane(doc);
        shell.setContentType("text/plain; charset=UTF-8"); //$NON-NLS-1$
        shell.setFont(new Font("Monospaced", Font.PLAIN, 12)); //$NON-NLS-1$
        shell.setMargin(new Insets(7, 5, 7, 5));
        shell.addKeyListener(this);
View Full Code Here

                              String type,
                              String encoding) throws IOException {

        try {
            RTFEditorKit rek = new RTFEditorKit();
            DefaultStyledDocument doc = new DefaultStyledDocument();
            rek.read(stream, doc, 0);
            String text = doc.getText(0, doc.getLength());
            return new StringReader(text);
        } catch (Throwable t) {
            logger.warn("Failed to extract RTF text content", t);
            return new StringReader("");
        } finally {
View Full Code Here

          try {
              reader = new InputStreamReader(is);
              file = File.createTempFile("extract", ".tmp");
              tempFiles.markForDeletion(file);
              writer = new FileWriter(file);
              DefaultStyledDocument doc = new DefaultStyledDocument();
              new RTFEditorKit().read(reader, doc, 0);
              writer.write(doc.getText(0, doc.getLength()));
          } catch (Exception ioe) {
              throw new ExtractionException("failed to parse rtf document", ioe,logger);
          }
          finally {
              if (reader != null) {
View Full Code Here

        if (dstTextPane != null)
            dstTextPane.setText("");
    }
   
    private void createDocuments() {
        combinedDoc = new DefaultStyledDocument();
        srcDoc = new DefaultStyledDocument();
        dstDoc = new DefaultStyledDocument();
        Iterator<Edit> it = edits.iterator();
        int srcLast = 0;
        int dstLast = 0;
        try {
            while (it.hasNext()) {
View Full Code Here

        mFile.setMnemonic('f');

        ImageIcon iconNew = new ImageIcon("file_new.gif");
        Action actionNew = new AbstractAction("Nuevo", iconNew) {
            public void actionPerformed(ActionEvent e) {
                DefaultStyledDocument document = new DefaultStyledDocument(new StyleContext());
                textPane.setDocument(document);
            }
        };
        JMenuItem item = null;
        // JMenuItem item = mFile.add(actionNew);
        // item.setMnemonic('n');

        ImageIcon iconOpen = new ImageIcon("file_open.gif");
        Action actionOpen = new AbstractAction("Abrir...", iconOpen) {
            public void actionPerformed(ActionEvent e) {
                SVNVisorFicheroEdicion.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                Thread runner = new Thread() {
                    public void run() {
                        if (fileChooser.showOpenDialog(SVNVisorFicheroEdicion.this) != JFileChooser.APPROVE_OPTION)
                            return;
                        SVNVisorFicheroEdicion.this.repaint();
                        File fChoosen = fileChooser.getSelectedFile();

                        // Recall that text component read/write operations are
                        // thread safe. Its ok to do this in a separate thread.
                        try {
                            InputStream in = new FileInputStream(fChoosen);
                            DefaultStyledDocument document = new DefaultStyledDocument(new StyleContext());
                            textPane.getEditorKit().read(in, document, 0);
                            textPane.setDocument(document);
                            in.close();
                        } catch (Exception ex) {
                            ex.printStackTrace();
View Full Code Here

TOP

Related Classes of javax.swing.text.DefaultStyledDocument

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.