javax.swing.JEditorPane.getContentType()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(138)

本文整理了Java中javax.swing.JEditorPane.getContentType()方法的一些代码示例,展示了JEditorPane.getContentType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JEditorPane.getContentType()方法的具体详情如下:
包路径:javax.swing.JEditorPane
类名称:JEditorPane
方法名:getContentType

JEditorPane.getContentType介绍

暂无

代码示例

代码示例来源:origin: stanfordnlp/CoreNLP

private void saveUntaggedContents(File file) {
 try {
  String contents;
  if (editorPane.getContentType().equals("text/html")) {
   contents = editorPane.getText();
  } else {
   Document doc = editorPane.getDocument();
   contents = doc.getText(0, doc.getLength());
  }
  saveFile(file, contents);
  saveUntagged.setEnabled(true);
  loadedFile = file;
 } catch (Exception e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: stanfordnlp/CoreNLP

public void saveUntaggedContents(File file) {
 try {
  String contents;
  if (editorPane.getContentType().equals("text/html")) {
   contents = editorPane.getText();
  } else {
   Document doc = editorPane.getDocument();
   contents = doc.getText(0, doc.getLength());
  }
  saveFile(file, contents);
  saveUntagged.setEnabled(true);
  loadedFile = file;
 } catch (Exception e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: stanfordnlp/CoreNLP

public void redraw() {
 String text = editorPane.getText();
 taggedContents = null;
 untaggedContents = null;
 if (!editorPane.getContentType().equals("text/html")) {
  editorPane.setContentType("text/rtf");
  Document doc = editorPane.getDocument();
  try {
   doc.insertString(0, text, defaultAttrSet);
  } catch (Exception e) {
   throw new RuntimeException(e);
  }
  editorPane.revalidate();
  editorPane.repaint();
  editorPane.setEditable(true);
  htmlContents = null;
 } else {
  editorPane.setEditable(false);
  htmlContents = editorPane.getText();
 }
 saveUntagged.setEnabled(false);
 saveTaggedAs.setEnabled(false);
}

代码示例来源:origin: stanfordnlp/CoreNLP

private void removeTags() {
 if (editorPane.getContentType().equals("text/html")) {
  editorPane.setText(htmlContents);
  editorPane.revalidate();
  editorPane.repaint();
 } else {
  DefaultStyledDocument doc = (DefaultStyledDocument)editorPane.getDocument();
  SimpleAttributeSet attr = new SimpleAttributeSet();
  StyleConstants.setForeground(attr, Color.BLACK);
  StyleConstants.setBackground(attr, Color.WHITE);
  doc.setCharacterAttributes(0, doc.getLength(), attr, false);
 }
 saveTaggedAs.setEnabled(false);
}

代码示例来源:origin: stanfordnlp/CoreNLP

private void extract() {
 log.info("content type: "+editorPane.getContentType());
 if (!editorPane.getContentType().equals("text/html")) {

代码示例来源:origin: stanfordnlp/CoreNLP

private void removeTags() {
 if (editorPane.getContentType().equals("text/html")) {
  if (htmlContents != null) {
   editorPane.setText(htmlContents);
  }
  editorPane.revalidate();
  editorPane.repaint();
 } else {
  DefaultStyledDocument doc = (DefaultStyledDocument)editorPane.getDocument();
  SimpleAttributeSet attr = new SimpleAttributeSet();
  StyleConstants.setForeground(attr, Color.BLACK);
  StyleConstants.setBackground(attr, Color.WHITE);
  doc.setCharacterAttributes(0, doc.getLength(), attr, false);
 }
 saveTaggedAs.setEnabled(false);
}

代码示例来源:origin: stanfordnlp/CoreNLP

private void extract() {
 log.info("content type: "+editorPane.getContentType());
 if (!editorPane.getContentType().equals("text/html")) {

代码示例来源:origin: stanfordnlp/CoreNLP

String text = editorPane.getText();
taggedContents = null;
if (!editorPane.getContentType().equals("text/html")) {
 editorPane.setContentType("text/rtf");
 Document doc = editorPane.getDocument();

代码示例来源:origin: igniterealtime/Spark

/**
 * Method to set the Document to print as the one contained in a JEditorPane.
 * This method is useful when Java does not provide direct access to a
 * particular Document type, such as a Rich Text Format document. With this
 * method such a document can be sent to the DocumentRenderer class enclosed
 * in a JEditorPane.
 *
 * @param jedPane the JEditorPane document container.
 */
public void setDocument(JEditorPane jedPane) {
  JEditorPane = new JEditorPane();
  setDocument(jedPane.getContentType(), jedPane.getDocument());
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-extension-openide

TextTransferable(JTextComponent c, int start, int end) {
  this.c = c;
    
  Document doc = c.getDocument();
  try {
    p0 = doc.createPosition(start);
    p1 = doc.createPosition(end);
    plainData = c.getSelectedText();
    if (c instanceof JEditorPane) {
      JEditorPane ep = (JEditorPane)c;
        
      mimeType = ep.getContentType();
      if (mimeType.startsWith("text/plain")) {
        return;
      }
      StringWriter sw = new StringWriter(p1.getOffset() - p0.getOffset());
      ep.getEditorKit().write(sw, doc, p0.getOffset(), p1.getOffset() - p0.getOffset());
        
      if (mimeType.startsWith("text/html")) {
        htmlData = sw.toString();
      } else {
        richText = sw.toString();
      }
    }
  } catch (BadLocationException ble) {
  } catch (IOException ioe) {
  }
}

代码示例来源:origin: com.fifesoft.rtext/fife.common

if (!contentType.equals(editorPane.getContentType())) {
  editorPane.setContentType(contentType);

代码示例来源:origin: org.swinglabs.swingx/swingx-all

dummy.setContentType(errorMessage.getContentType());
dummy.setEditorKit(errorMessage.getEditorKit());
dummy.setText(errorMessage.getText());

代码示例来源:origin: org.swinglabs.swingx/swingx-core

dummy.setContentType(errorMessage.getContentType());
dummy.setEditorKit(errorMessage.getEditorKit());
dummy.setText(errorMessage.getText());

代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core

dummy.setContentType(errorMessage.getContentType());
dummy.setEditorKit(errorMessage.getEditorKit());
dummy.setText(errorMessage.getText());

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

dummy.setContentType(errorMessage.getContentType());
dummy.setEditorKit(errorMessage.getEditorKit());
dummy.setText(errorMessage.getText());

代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop

dummy.setContentType(errorMessage.getContentType());
dummy.setEditorKit(errorMessage.getEditorKit());
dummy.setText(errorMessage.getText());

代码示例来源:origin: org.swinglabs.swingx/swingx-all

dummy.setContentType(errorMessage.getContentType());
dummy.setText(errorMessage.getText());
dummy.setSize(parent.getWidth() - leftEdge - insets.right, 20);

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

dummy.setContentType(errorMessage.getContentType());
dummy.setText(errorMessage.getText());
dummy.setSize(parent.getWidth() - leftEdge - insets.right, 20);

代码示例来源:origin: nroduit/Weasis

public EditorPanePrinter(JEditorPane pane, PageFormat pageFormat, Insets margins) {
  JEditorPane tmpPane = new JEditorPane();
  tmpPane.setUI(new BasicEditorPaneUI());
  tmpPane.setContentType(pane.getContentType());
  HTMLEditorKit kit = new HTMLEditorKit();
  StyleSheet ss = kit.getStyleSheet();
  ss.addRule(
    "body {font-family:sans-serif;font-size:12pt;background-color:white;color:black;margin:3;font-weight:normal;}"); //$NON-NLS-1$
  tmpPane.setEditorKit(kit);
  tmpPane.setBorder(null);
  tmpPane.setText(pane.getText());
  this.sourcePane = tmpPane;
  this.pageFormat = pageFormat;
  Paper paper = pageFormat.getPaper();
  this.margins = margins;
  this.pageWidth = (int) paper.getWidth();
  this.pageHeight = (int) paper.getHeight();
  paper.setImageableArea(0, 0, paper.getWidth(), paper.getHeight());
  pageFormat.setPaper(paper);
  doPagesLayout();
}

代码示例来源:origin: javax.help/javahelp

debug("html current ContentType is: "+html.getContentType());
} catch (Exception e3) {

相关文章

JEditorPane类方法