Package javax.swing.text

Examples of javax.swing.text.StyledEditorKit


  {
    editorPane.setText(article.getContent());
  }

  public void updateFont(int direction) {
    StyledEditorKit kit = (StyledEditorKit) editorPane.getEditorKit();
    MutableAttributeSet set = kit.getInputAttributes();
    StyledDocument doc = (StyledDocument) editorPane.getDocument();
    Font currentFont = doc.getFont(set);
    int currentFontSize = currentFont.getSize();
    switch (direction) {
      case FontHelper.FONT_DIR_UP:
View Full Code Here


                      JPanel descriptionPanel = new JPanel(new BorderLayout());
                      JEditorPane descriptionEditorPane = new JEditorPane(description.startsWith("<html>")? "text/html": "text/plain", description) {
                        @Override
                        public EditorKit getEditorKitForContentType(String type){
                          if("text/plain".equalsIgnoreCase(type)) {
                            StyledEditorKit styledEditorKit = new StyledEditorKit();
                            MutableAttributeSet inputAttributes = styledEditorKit.getInputAttributes();
                            StyleConstants.setFontFamily(inputAttributes, DESCRIPTION_FONT.getFamily());
                            StyleConstants.setFontSize(inputAttributes, DESCRIPTION_FONT.getSize());
                            return styledEditorKit;
                          }
                          return super.getEditorKitForContentType(type);
View Full Code Here

    addNewTab();
  }

  public void addNewTab() {
    JEditorPane textComponent = new JEditorPane();
    textComponent.setEditorKit(new StyledEditorKit());
    JScrollPane scrollPane = new JScrollPane(textComponent);

    JTabbedPane documentTab = documentPanel.getTabbedPane();

    documentTab.add(scrollPane);
View Full Code Here

    int end = editor.getSelectionEnd();
    if (start != end) {
      StyledDocument doc = (StyledDocument) editor.getDocument();
      doc.setCharacterAttributes(start, end - start, attr, true);
    }
    StyledEditorKit k = (StyledEditorKit) editor.getEditorKit();
    MutableAttributeSet inputAttributes = k.getInputAttributes();
    inputAttributes.removeAttributes(inputAttributes);
    inputAttributes.addAttributes(attr);
  }
View Full Code Here

TOP

Related Classes of javax.swing.text.StyledEditorKit

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.