#navi(contents-page-name): No such page: ST

FrontPage>Swing Tips>ST/StyleConstants

ST/StyleConstants

Terai Atsuhiro 2021-12-24 (金) 12:38:13

JTextPane

#ref(): File not found: "StyleConstants.png" at page "Swing/StyleConstants"

private void append(String str, boolean flg){
  SimpleAttributeSet sas = null;
  if(!flg){
    //sas = new SimpleAttributeSet(jtp.getCharacterAttributes());
    sas = new SimpleAttributeSet();
    StyleConstants.setForeground(sas, Color.RED);
    //StyleConstants.setBold(sas, true);
    //StyleConstants.setFontFamily(sas, "Monospaced");
    //StyleConstants.setFontSize(sas, 32);
    //StyleConstants.setForeground(sas, Color.GREEN);
  }
  try{
    Document doc = jtp.getDocument();
    doc.insertString(doc.getLength(), str+SEPARATOR, sas);
  }catch(BadLocationException e){}
}

StyleConstants