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

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

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

JTextPane.setText介绍

暂无

代码示例

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

JTextPane f = new JTextPane();
f.setContentType("text/html"); // let the text pane know this is what you want
f.setText("<html>Hello World</html>"); // showing off
f.setEditable(false); // as before
f.setBackground(null); // this is the same as a JLabel
f.setBorder(null); // remove the border

代码示例来源:origin: wiztools/rest-client

JTextPane jtp = new JTextPane();
jtp.setEditable(false);
jtp.setContentType("text/html");
jtp.setText(MessageI18N.getMessage("menu.help.about"));
jp_center.add(new JScrollPane(jtp));
jp.add(jp_center, BorderLayout.CENTER);

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

JTextPane textPane = new JTextPane();
textPane.setText( "original text" );
StyledDocument doc = textPane.getStyledDocument();

//  Define a keyword attribute

SimpleAttributeSet keyWord = new SimpleAttributeSet();
StyleConstants.setForeground(keyWord, Color.RED);
StyleConstants.setBackground(keyWord, Color.YELLOW);
StyleConstants.setBold(keyWord, true);

//  Add some text

try
{
  doc.insertString(0, "Start of text\n", null );
  doc.insertString(doc.getLength(), "\nEnd of text", keyWord );
}
catch(Exception e) { System.out.println(e); }

代码示例来源:origin: wiztools/rest-client

jp_help.setLayout(new BorderLayout());
JTextPane jtp_help_center = new JTextPane();
jtp_help_center.setEditable(false);
Dimension d = jtp_help_center.getPreferredSize();
jtp_help_center.setText(helpText);
jtp_help_center.setPreferredSize(d);
jtp_help_center.setCaretPosition(0);

代码示例来源:origin: chewiebug/GCViewer

private void initComponents(String fileName) {
  super.initComponents();
  
  JTextPane textPane = new JTextPane();
  textPane.setEditable(false);
  textPane.setContentType("text/html");
  textPane.addHyperlinkListener(new HyperlinkAdapter(this));
  
  try {
    textPane.setText(readFile(fileName));
    textPane.setCaretPosition(0);
  }
  catch (IOException e) {
    e.printStackTrace();
  }
  
  JScrollPane scrollPane = new JScrollPane(
      textPane,
      JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
      JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  
  getContentPane().add("Center", scrollPane);
  pack();
}

代码示例来源:origin: kiegroup/optaplanner

private JComponent createNoPlannerFoundTextField() {
  String infoMessage = "No planner benchmarks have been found in the benchmarkDirectory ("
      + benchmarkAggregator.getBenchmarkDirectory() + ").";
  JTextPane textPane = new JTextPane();
  textPane.setEditable(false);
  textPane.setText(infoMessage);
  // center info message
  StyledDocument styledDocument = textPane.getStyledDocument();
  SimpleAttributeSet center = new SimpleAttributeSet();
  StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
  StyleConstants.setBold(center, true);
  styledDocument.setParagraphAttributes(0, styledDocument.getLength(),
      center, false);
  return textPane;
}

代码示例来源:origin: marytts/marytts

jTextPane_PromptDisplay = new javax.swing.JTextPane();
jTextPane_nextSentence = new javax.swing.JTextPane();
jLabel_SessionStatus = new javax.swing.JLabel();
jPanel_AdminControls = new javax.swing.JPanel();
jTextPane_PromptDisplay.setFont(new java.awt.Font("Tahoma", 0, 30));
jTextPane_PromptDisplay
    .setText("This is a long and boring test sentence, the only purpose of which is to see how to break between lines without making any difference across the windows.");
jTextPane_PromptDisplay.setAutoscrolls(false);
jTextPane_PromptDisplay.addComponentListener(new java.awt.event.ComponentAdapter() {
jTextPane_nextSentence.setForeground(new java.awt.Color(50, 50, 50));
jTextPane_nextSentence
    .setText("This is a long and boring test sentence, the only purpose of which is to see how to break between lines without making any difference across the windows.");

代码示例来源:origin: marytts/marytts

jTextPane_PromptDisplay = new javax.swing.JTextPane();
jLabel_SessionStatus = new javax.swing.JLabel();
jProgressBar_SpeakerProgress = new javax.swing.JProgressBar();
jLabel_PromptTotal = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextPane_nextSentence = new javax.swing.JTextPane();
jTextPane_PromptDisplay.setFont(new java.awt.Font("Tahoma", 0, 36));
jTextPane_PromptDisplay
    .setText("This is a long and boring test sentence, the only purpose of which is to see how to break between lines without making any difference across the windows.");
jTextPane_PromptDisplay.setAutoscrolls(false);
jTextPane_nextSentence.setForeground(new java.awt.Color(50, 50, 50));
jTextPane_nextSentence
    .setText("This is a long and boring test sentence, the only purpose of which is to see how to break between lines without making any difference across the windows.");
jScrollPane1.setViewportView(jTextPane_nextSentence);

代码示例来源:origin: apache/pdfbox

private JTextPane createTextView(COSString cosString)
{
  JTextPane textPane = new JTextPane();
  textPane.setText(getTextString(cosString));
  textPane.setEditable(false);
  return textPane;
}

代码示例来源:origin: RaiMan/SikuliX2

@Override
public void setText(String text) {
 this.text = text;
 if (comp != null) {
  maximum_width = comp.maxWidth - 2 * comp.PADDING_X;
  htmltxt = "<html><div style='" + comp.getStyleString() + "'>"
      + text + "</div></html>";
 } else {
  htmltxt = "<html><font size=5>"+text+"</font></html>";
 }
 super.setText(htmltxt);
 JTextPane tp = new JTextPane();
 tp.setText(htmltxt);
 if (getPreferredSize().getWidth() > maximum_width) {
  // hack to limit the width of the text to width
  if (comp != null) {
   htmltxt = "<html><div style='width:" + maximum_width + ";" + comp.getStyleString() + "'>"
        + text + "</div></html>";
  } else {
   htmltxt = "<html><div width='"+maximum_width+"'><font size=5>"+text+"</font></div></html>";
  }
  super.setText(htmltxt);
 }
 setSize(getPreferredSize());
}

代码示例来源:origin: magefree/mage

lblMessage = new javax.swing.JTextPane();
spnAmount = new javax.swing.JSpinner();
panelCommands = new javax.swing.JPanel();
lblMessage.setText("long text long text long text long text long text long text long text long text");
lblMessage.setCursor(null);
lblMessage.setFocusable(false);

代码示例来源:origin: pentaho/mondrian

jSplitPane1 = new javax.swing.JSplitPane();
jScrollPane1 = new javax.swing.JScrollPane();
queryTextPane = new javax.swing.JTextPane();
jScrollPane2 = new javax.swing.JScrollPane();
resultTextPane = new javax.swing.JTextPane();
connectButton = new javax.swing.JButton();
jPopupMenu = new JPopupMenu();
jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
queryTextPane.setFont(new java.awt.Font("Courier New", 0, 12));
queryTextPane.setText("");
queryTextPane.addMouseListener(
  new MouseAdapter() {

代码示例来源:origin: RaiMan/SikuliX2

JTextPane jtp = new JTextPane();
jtp.setContentType("text/html");
jtp.setFont(new Font(Font.DIALOG, Font.PLAIN, 14));
    BorderFactory.createLineBorder(Color.magenta, 2),
    BorderFactory.createEmptyBorder(0, 10, 10, 10)));
jtp.setText(aText);
jtp.setEditable(false);
jtp.setCaretPosition(0);

代码示例来源:origin: ron190/jsql-injection

final JTextPane browser = new JTextPane();
browser.setContentType("text/html");
browser.setEditable(false);
  browser.setText(htmlSource);
} catch (EmptyStackException e) {
  LOGGER.error(e, e);

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

JTextPane pane = new JTextPane ();
 pane.setText ( "Column A:\tColumn B:\n" +
     "Alpha\tAlpha\n" +
     "Beta\tBeta\n" +
     "Gama\tGamma" );

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

JTextPane jtp1 = new JTextPane();
jtp1.setText("bhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhbhbbbbbbbbbbbbbbbbhbbbbbbbbbbbbbbbbbb b");
jtp1.setEditable(false);

JPanel noWrapPanel = new JPanel( new BorderLayout() );
noWrapPanel.add( jtp1 );

JScrollPane scrollpane2 = new JScrollPane(noWrapPanel);

JFrame frame=new JFrame();
frame.add(scrollpane2);
frame.setSize(200,100);
frame.setVisible(true);

代码示例来源:origin: com.google.code.findbugs/findbugs

private JTextPane createMessagePane(String msg) {
  JTextPane msgpane = new JTextPane();
  msgpane.setEditable(false);
  msgpane.setFocusable(false);
  msgpane.setText(msg);
  return msgpane;
}

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

String text = new String("Hello");
String htmlText = new String("<html><font color='red'>" + text + "</font></html>");
JTextPane jTextPane =new JTextPane ();
jTextPane.setContentType("text/html");
jTextPane.setText(htmlText );

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

private void initialize() {
  frame = new JFrame();
  frame.setBounds(100, 100, 450, 300);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

  JTextPane textPane = new JTextPane();
  System.out.println(String.valueOf("\u2622"));
  textPane.setContentType("text/html");
  textPane.setText("c'est " + String.valueOf("\u2622"));
  frame.getContentPane().add(textPane, BorderLayout.CENTER);
  frame.pack();            // Add these
  frame.setVisible(true);  // two lines
}

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

JTextPane myTextPane = new JTextPane();
myTextPane.setContentType("text/html"); 
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("<html>");
stringBuilder.append("<b>bold text </b>");
stringBuilder.append("normal text");
stringBuilder.append("</html>");

myTextPane.setText(stringBuilder.toString());

相关文章

JTextPane类方法