本文整理了Java中javax.swing.JEditorPane.setText()
方法的一些代码示例,展示了JEditorPane.setText()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JEditorPane.setText()
方法的具体详情如下:
包路径:javax.swing.JEditorPane
类名称:JEditorPane
方法名:setText
暂无
代码示例来源:origin: stanfordnlp/CoreNLP
private void displayTsurgeonHelp() {
if(tsurgeonHelpFrame != null) {
tsurgeonHelpFrame.setVisible(true);
} else {
tsurgeonHelpFrame = new JFrame("TSurgeon Help...");
JEditorPane helpText = new JEditorPane();
helpText.setContentType("text/html");
// StringBuffer s = new StringBuffer();
// s.append(htmlTsurgeonHelp);
helpText.setText(htmlTsurgeonHelp);
helpText.setEditable(false);
JScrollPane scroller = new JScrollPane(helpText);
helpText.setCaretPosition(0);
scroller.setPreferredSize(new Dimension(500,500));
tsurgeonHelpFrame.add(scroller);
tsurgeonHelpFrame.pack();
tsurgeonHelpFrame.setBackground(Color.WHITE);
tsurgeonHelpFrame.setVisible(true);
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
chatLog.setEditable(false);
chatLog.setContentType("text/html");
chatLog.setText("<html><body>");
getContentPane().add(new JScrollPane(chatLog), "Center");
p.add(new JButton(new SendAction(false)));
getContentPane().add(p, "South");
代码示例来源:origin: stackoverflow.com
op.setEditable(false);
op.setText(content);
JPanel fontNameCol = new JPanel(new GridLayout(0, 1, 2, 2));
JPanel fontExampleCol = new JPanel(new GridLayout(0, 1, 2, 2));
fontTable.add(fontNameCol, BorderLayout.WEST);
fontTable.add(fontExampleCol, BorderLayout.CENTER);
for (int ii = 0; ii < fonts.length; ii++) {
fontNameCol.add(new JLabel(fonts[ii]));
fontExampleCol.add(getExampleOfFont(fonts[ii]));
p.add(tabPane, BorderLayout.CENTER);
p.setPreferredSize(new Dimension(400, 400));
JFrame f = new JFrame("Properties");
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.getContentPane().add(p, BorderLayout.CENTER);
f.pack();
f.setSize(600, 500);
f.setLocationRelativeTo(null);
f.setVisible(true);
代码示例来源:origin: stackoverflow.com
JEditorPane jep = new JEditorPane();
jep.setEditable(false);
try {
jep.setPage("http://www.yoursite.com");
}catch (IOException e) {
jep.setContentType("text/html");
jep.setText("<html>Could not load</html>");
}
JScrollPane scrollPane = new JScrollPane(jep);
JFrame f = new JFrame("Test HTML");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(scrollPane);
f.setPreferredSize(new Dimension(800,600));
f.setVisible(true);
代码示例来源:origin: igniterealtime/Spark
public static void main(String args[]) {
JFrame frame = new JFrame();
frame.getContentPane().setLayout(new BorderLayout());
JEditorPane pane = new JEditorPane();
frame.getContentPane().add(new JScrollPane(pane));
StringBuilder buf = new StringBuilder();
Enumeration<String> enumeration = (Enumeration<String>) prb.propertyNames();
while (enumeration.hasMoreElements()) {
String token = enumeration.nextElement();
String value = prb.getProperty(token).toLowerCase();
if (value.endsWith(".gif") || value.endsWith(".png") || value.endsWith(".jpg") || value.endsWith("jpeg")) {
SparkRes.getImageIcon(token);
}
String str = "public static final String " + token + " = \"" + token + "\";\n";
buf.append(str);
}
checkImageDir();
pane.setText(buf.toString());
frame.pack();
frame.setVisible(true);
}
代码示例来源:origin: stackoverflow.com
e.setVisible(true);
} catch (IOException e) {
web.setContentType("text/html");
web.setText("<html>Could not load</html>");
getContentPane().add(scrollPane);
this.setBounds( 0, 0, 200, 200);
代码示例来源:origin: stackoverflow.com
import javax.swing.JTextPane;
import java.awt.print.PrinterException;
public class TestPrint {
public static void main(String[] args) throws PrinterException {
JTextPane textPane = new JTextPane();
textPane.setText("test text string - Hello World! Are you there?");
textPane.print();
}
}
代码示例来源:origin: stackoverflow.com
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(400, 400);
setLocationRelativeTo(null);
JTextPane txt = new JTextPane(doc);
txt.setText("public class Hi {}");
add(new JScrollPane(txt));
setVisible(true);
代码示例来源:origin: stackoverflow.com
JFrame frame=new JFrame();
JEditorPane textarea = new JEditorPane("text/html", "");
//listArea.setText("<b>Bold</b>");
textarea.setText("<b>Bold</b> and normal text");
frame.add(textarea);
frame.setSize(300,300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
代码示例来源:origin: cytoscape.coreplugins/cpath
private void init () {
helpFrame = new JFrame("Quick Reference Manual");
Container contentPane = helpFrame.getContentPane();
contentPane.setLayout(new BorderLayout());
JEditorPane htmlPane = new JEditorPane();
EmptyBorder border = new EmptyBorder(5, 5, 5, 5);
htmlPane.setBorder(border);
htmlPane.setContentType("text/html");
htmlPane.setEditable(false);
htmlPane.setPreferredSize(new Dimension(WIDTH, HEIGHT));
String html = this.getAboutHtml();
htmlPane.setText(html);
htmlPane.setCaretPosition(0);
JScrollPane scrollPane = new JScrollPane(htmlPane);
contentPane.add(scrollPane, BorderLayout.CENTER);
// Pack it, but don't show it yet.
helpFrame.pack();
}
代码示例来源:origin: stanfordnlp/CoreNLP
private void displayHelp() {
if (helpFrame != null) {
helpFrame.setVisible(true);
} else {
helpFrame = new JFrame("Tregex Help...");
//JPanel helpPanel = new JPanel();
JEditorPane helpText = new JEditorPane();
helpText.setContentType("text/html");
// StringBuffer s = new StringBuffer();
// s.append(htmlHelp);
helpText.setText(htmlHelp);
helpText.setEditable(false);
//helpPanel.add(helpText);
JScrollPane scroller = new JScrollPane(helpText);
helpText.setCaretPosition(0);
scroller.setPreferredSize(new Dimension(500,500));
helpFrame.add(scroller);
helpFrame.pack();
helpFrame.setBackground(Color.WHITE);
helpFrame.setVisible(true);
//helpFrame.repaint();
}
}
代码示例来源:origin: ron190/jsql-injection
dialogPane.add(iconJSQL, BorderLayout.WEST);
dialogPane.add(lastLine, BorderLayout.SOUTH);
text[0].setText(result.toString().replace("%JSQLVERSION%", InjectionModel.getVersionJsql()));
} catch (IOException e) {
LOGGER.error(e.getMessage(), e);
dialogPane.add(this.scrollPane, BorderLayout.CENTER);
代码示例来源:origin: stackoverflow.com
Container bg = t.getContentPane();
t.createJEditorPane(bg, bg.getSize());
t.setVisible(true);
pane.setMaximumSize(size);
pane.setOpaque(true);
pane.setText("<b><font face=\"Arial\" size=\"50\" align=\"center\" > Unfortunately when I display this string it is too long and doesn't wrap to new line!</font></b>");
bg.add(pane, BorderLayout.CENTER);
代码示例来源:origin: mguessan/davmail
protected JPanel getBodyPanel(String description) {
JPanel bodyPanel = new JPanel();
bodyPanel.setLayout(new BoxLayout(bodyPanel, BoxLayout.Y_AXIS));
bodyPanel.setBorder(BorderFactory.createTitledBorder(BundleMessage.format("UI_NOTIFICATION_BODY")));
bodyField = new JTextPane();
bodyField.setText(description);
//HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
//bodyField.setEditorKit(htmlEditorKit);
//bodyField.setContentType("text/html");
bodyPanel.add(new JScrollPane(bodyField));
return bodyPanel;
}
代码示例来源:origin: stackoverflow.com
jep.setText("Welcome to <a href='http://stackoverflow.com/'>StackOverflow</a>.");
JFrame f = new JFrame("HyperlinkListener");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(jep);
f.pack();
f.setVisible(true);
代码示例来源:origin: stackoverflow.com
JFrame frame=new JFrame();
JEditorPane pane=new JEditorPane();
pane.setContentType("text/html");
String data="<table border=\"1\"><tr><td>cell1</td><td>cell2</td></tr></table>";
pane.setText(data);
frame.add(pane);
frame.setSize(200,200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
代码示例来源:origin: stackoverflow.com
import java.io.*;
import java.net.*;
import java.util.regex.*;
import javax.swing.*;
public class webloader {
static JComponent page;
public static void loadcode(){
JEditorPane jep = new JEditorPane();
jep.setEditable(false);
try {
jep.setPage("http://(server):(port)/" + web.url);
}
catch (IOException e) {
jep.setContentType("text/html");
jep.setText("<html>Could not load webpage</html>");
}
JScrollPane scrollPane = new JScrollPane(jep);
JFrame f = new JFrame(web.url);
f.getContentPane().add(scrollPane);
f.setSize(512, 342);
f.show();
}
}
代码示例来源:origin: stackoverflow.com
JEditorPane editor = new JEditorPane();
editor.setBorder(BorderFactory.createLineBorder(Color.RED, 1));
editor.setText("..large text block..");
JScrollPane scrollPane = new JScrollPane(editor);
JPanel panel = new JPanel();
BoxLayout layout = new BoxLayout(panel, BoxLayout.Y_AXIS);
panel.setLayout(layout);
panel.add(Box.createVerticalGlue());
panel.add(scrollPane);
panel.add(Box.createVerticalGlue());
JFrame frame = new JFrame();
frame.setSize(600, 400);
frame.add(panel);
frame.setVisible(true);
代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2
/**
* sets up the editor pane.
*/
private void setupEditorPane() {
contentPane.setLayout(new BorderLayout());
// create antialiased editor pane.
pane = new JEditorPane() {
private static final long serialVersionUID = -789611244532767255L;
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
super.paint(g);
}
};
// no editing.
pane.setEditable(false);
// enable html support.
pane.setContentType("text/html");
// enable hyperlink handling.
pane.addHyperlinkListener(listener);
// default text
pane.setText(Config.language.getProperty("ContentsDisplay.EmptyText"));
contentPane.add(new JScrollPane(pane), BorderLayout.CENTER);
}
代码示例来源:origin: stackoverflow.com
import javax.swing.JTextPane;
import javax.swing.text.StyleConstants;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.SimpleAttributeSet;
public class StyleBugFix {
public static void main(String[] args) {
JTextPane textPane = new JTextPane();
textPane.setText("This is a test string");
StyleConstants.setBold(BOLD, true);
StyleConstants.setItalic(ITALIC, true);
int start = 5;
int end = 10;
textPane.getStyledDocument().setCharacterAttributes(start, end - start, BOLD, false);
textPane.getStyledDocument().setCharacterAttributes(start, end - start, ITALIC, false);
for(int i = start; i < end; i++)
System.out.println(textPane.getStyledDocument().getCharacterElement(i).getAttributes()
.containsAttributes(BOLD)); //all now print true
}
private static final MutableAttributeSet BOLD = new SimpleAttributeSet();
private static final MutableAttributeSet ITALIC = new SimpleAttributeSet();
}
内容来源于网络,如有侵权,请联系作者删除!