javax.swing.JTextPane.getInputAttributes()方法的使用及代码示例

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

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

JTextPane.getInputAttributes介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

jta.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
fnt = ge.getAvailableFontFamilyNames();
mas = jta.getInputAttributes();
new Thread(this).start();

代码示例来源:origin: stackoverflow.com

public static void increaseJTextPaneFont(JTextPane jtp) {
  MutableAttributeSet attrs = jtp.getInputAttributes();
  //first get the current size of the font
  int size = StyleConstants.getFontSize(attrs);

  //now increase by 2 (or whatever factor you like)
  StyleConstants.setFontSize(attrs, size * 2);

  StyledDocument doc = jtp.getStyledDocument();
  doc.setCharacterAttributes(0, doc.getLength() + 1, attrs, false);
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui

/**
 * Method for inserting Unicode characters via the UnicodeDialog class
 */
public void insertUnicodeChar(String sChar) throws IOException, BadLocationException, RuntimeException {
 int caretPos = jtpMain.getCaretPosition();
 if (sChar != null) {
  htmlDoc.insertString(caretPos, sChar, jtpMain.getInputAttributes());
  jtpMain.setCaretPosition(caretPos + 1);
 }
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui

/**
 * Method for inserting a non-breaking space ( )
 */
private void insertNonbreakingSpace() throws IOException, BadLocationException, RuntimeException {
 int caretPos = jtpMain.getCaretPosition();
 htmlDoc.insertString(caretPos, "\240", jtpMain.getInputAttributes());
 jtpMain.setCaretPosition(caretPos + 1);
}

代码示例来源:origin: stackoverflow.com

pane.addCaretListener(new CaretListener() {
  public void caretUpdate(CaretEvent event) {
    final JTextPane textPane = (JTextPane) event.getSource();
    EventQueue.invokeLater(new Runnable() {
      public void run() {
        MutableAttributeSet inputAttr =
          textPane.getInputAttributes();
        inputAttr.removeAttribute(StyleConstants.Foreground);
      }
    });
  }
});

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

private void maintainForegroundColor()
 {
  // Ensure text typed into the console uses the foreground color.  If we don't set it here, the
  // editor sometimes reuses a color from wherever the user may have moved the cursor in the console
  // and pressed Enter.
  _outputPanel.getInputAttributes();
  SimpleAttributeSet sas = new SimpleAttributeSet();
  StyleConstants.setForeground( sas, _outputPanel.getForeground() );
  _outputPanel.setCharacterAttributes( sas, false );
 }
}

代码示例来源:origin: beryx/text-io

public void appendToInput(String message, boolean preserveCaretPosition) {
  try {
    document.insertString(document.getLength(), message, textPane.getInputAttributes().copyAttributes());
  } catch (BadLocationException e) {
    e.printStackTrace();
  } catch (Exception e) {
    logger.error("Cannot insert input text", e);
  }
  if(!preserveCaretPosition) {
    textPane.setCaretPosition(document.getLength());
  }
}

代码示例来源:origin: org.activecomponents.jadex/jadex-commons-gui

MutableAttributeSet attrs = jtp.getInputAttributes();

代码示例来源:origin: stackoverflow.com

attribIns = new SimpleAttributeSet (textArea.getInputAttributes());

代码示例来源:origin: stackoverflow.com

public void run() {
  textPane2.getCaret().setDot(textPane2.getText().length());
  MutableAttributeSet inputAttributes = textPane2.getInputAttributes();
  inputAttributes.addAttributes(set);

代码示例来源:origin: beryx/text-io

private OffsetAttrs fixCaretPosition(int offset, AttributeSet attrs) {
  if (!isEditAllowedAt(offset) && (readMode || fakeReadMode)) {
    textPane.setCaretPosition(document.getLength());
    return new OffsetAttrs(document.getLength(), textPane.getInputAttributes().copyAttributes());
  }
  return new OffsetAttrs(offset, attrs);
}

代码示例来源:origin: beryx/text-io

public void replaceInput(String message, boolean preserveCaretPosition) {
  int oldCaretPosition = textPane.getCaretPosition();
  try {
    document.remove(startReadLen, document.getLength() - startReadLen);
    document.insertString(document.getLength(), message, textPane.getInputAttributes().copyAttributes());
  } catch (BadLocationException e) {
    e.printStackTrace();
  } catch (Exception e) {
    logger.error("Cannot insert input text", e);
  }
  int newCaretPosition = (preserveCaretPosition && oldCaretPosition <= document.getLength()) ? oldCaretPosition : document.getLength();
  textPane.setCaretPosition(newCaretPosition);
}

代码示例来源:origin: stackoverflow.com

jsp.setPreferredSize(new Dimension(height, width));
fnt = ge.getAvailableFontFamilyNames();
mas = jta.getInputAttributes();
for (int i = 0; i < fnt.length; i++) {
  StyleConstants.setBold(mas, false);

代码示例来源:origin: stackoverflow.com

jta.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
fnt = ge.getAvailableFontFamilyNames();
mas = jta.getInputAttributes();
new Thread(this).start();

代码示例来源:origin: stackoverflow.com

jta.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
fnt = ge.getAvailableFontFamilyNames();
mas = jta.getInputAttributes();
new Thread(this).start();

代码示例来源:origin: stackoverflow.com

jta.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
fnt = ge.getAvailableFontFamilyNames();
mas = jta.getInputAttributes();
new Thread(this).start();

相关文章

JTextPane类方法