本文整理了Java中javax.swing.text.html.HTMLEditorKit
类的一些代码示例,展示了HTMLEditorKit
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HTMLEditorKit
类的具体详情如下:
包路径:javax.swing.text.html.HTMLEditorKit
类名称:HTMLEditorKit
暂无
代码示例来源:origin: stackoverflow.com
JTextPane text_panel = new JTextPane();
HTMLEditorKit kit = new HTMLEditorKit();
HTMLDocument doc = new HTMLDocument();
text_panel.setEditorKit(kit);
text_panel.setDocument(doc);
kit.insertHTML(doc, doc.getLength(), "<b>hello", 0, 0, HTML.Tag.B);
kit.insertHTML(doc, doc.getLength(), "<font color='red'><u>world</u></font>", 0, 0, null);
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@NotNull
public static JTextPane createDescriptionPane() {
JTextPane result = new JTextPane();
result.addHyperlinkListener(new BrowserHyperlinkListener());
result.setContentType("text/html");
Font descriptionFont = UIUtil.getLabelFont(UIUtil.FontSize.SMALL);
HTMLEditorKit editorKit = UIUtil.getHTMLEditorKit();
editorKit.getStyleSheet().addRule("body, p {" +
"color:#" + ColorUtil.toHex(UIUtil.getLabelFontColor(UIUtil.FontColor.BRIGHTER)) + ";" +
"font-family:" + descriptionFont.getFamily() + ";" +
"font-size:" + descriptionFont.getSize() + "pt;}");
result.setHighlighter(null);
result.setEditorKit(editorKit);
return result;
}
}
代码示例来源:origin: org.netbeans.api/org-openide-dialogs
public FixedHeightPane () {
super ();
setEditable(false);
HTMLEditorKit htmlkit = new HTMLEditorKit();
StyleSheet css = htmlkit.getStyleSheet();
if (css.getStyleSheets() == null) {
StyleSheet css2 = new StyleSheet();
Font f = new JList().getFont();
int size = f.getSize();
try {
css2.addRule(new StringBuffer("body { font-size: ").append(size) // NOI18N
.append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N
css2.addStyleSheet(css);
htmlkit.setStyleSheet(css2);
} catch( RuntimeException ex ) {
代码示例来源:origin: net.imagej/ij
private void init(String message) {
ij.util.Java2.setSystemLookAndFeel();
Container container = getContentPane();
container.setLayout(new BorderLayout());
if (message==null) message = "";
editorPane = new JEditorPane("text/html","");
editorPane.setEditable(false);
HTMLEditorKit kit = new HTMLEditorKit();
editorPane.setEditorKit(kit);
StyleSheet styleSheet = kit.getStyleSheet();
styleSheet.addRule("body{font-family:Verdana,sans-serif; font-size:11.5pt; margin:5px 10px 5px 10px;}"); //top right bottom left
styleSheet.addRule("h1{font-size:18pt;}");
styleSheet.addRule("h2{font-size:15pt;}");
styleSheet.addRule("dl dt{font-face:bold;}");
editorPane.setText(message); //display the html text with the above style
public void actionPerformed(ActionEvent e) {}
JScrollPane scrollPane = new JScrollPane(editorPane);
container.add(scrollPane);
JButton button = new JButton("OK");
button.addActionListener(this);
代码示例来源:origin: tinyMediaManager/tinyMediaManager
private void initComponents() {
setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, },
new RowSpec[] { FormSpecs.LINE_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormSpecs.LINE_GAP_ROWSPEC, }));
JPanel panelMovieScrapers = new JPanel();
panelMovieScrapers.setLayout(new FormLayout(
new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("80dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
panelMovieScrapers.add(lblMovieScraper, "2, 2, 11, 1");
JScrollPane scrollPaneScraper = new JScrollPane();
panelMovieScrapers.add(scrollPaneScraper, "2, 4, 5, 1, fill, fill");
scrollPaneScraper.setViewportView(tableScraper);
JPanel panelScraperDetails = new JPanel();
new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC, }));
tpScraperDescription = new JTextPane();
tpScraperDescription.setOpaque(false);
tpScraperDescription.setEditorKit(new HTMLEditorKit());
panelScraperDetails.add(tpScraperDescription, "2, 2, default, top");
代码示例来源:origin: org.swinglabs.swingx/swingx-all
iconLabel = new JLabel(pane.getIcon());
errorMessage = new JEditorPane();
errorMessage.setEditable(false);
errorMessage.setContentType("text/html");
errorMessage.setEditorKitForContentType("text/plain", new StyledEditorKit());
errorMessage.setEditorKitForContentType("text/html", new HTMLEditorKit());
errorMessage.setOpaque(false);
copyToClipboardButton.addActionListener(copyToClipboardListener);
detailsPanel.setLayout(createDetailPanelLayout());
detailsPanel.add(detailsScrollPane);
detailsPanel.add(copyToClipboardButton);
errorScrollPane = new JScrollPane(errorMessage);
errorScrollPane.setBorder(new EmptyBorder(0,0,5,0));
errorScrollPane.setOpaque(false);
代码示例来源:origin: stackoverflow.com
public JComponent makeEditorPane(String bullet) {
JEditorPane pane = new JEditorPane();
pane.setContentType("text/html");
pane.setEditable(false);
if(bullet!=null) {
HTMLEditorKit htmlEditorKit = (HTMLEditorKit)pane.getEditorKit();
StyleSheet styleSheet = htmlEditorKit.getStyleSheet();
styleSheet.addRule(String.format("ul{list-style-image:url(%s);margin:0px 20px;", u));
JPanel p = new JPanel(new GridLayout(2,1));
p.add(new JScrollPane(makeEditorPane(null)));
p.add(new JScrollPane(makeEditorPane("bullet.png")));
return p;
JFrame f = new JFrame();
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.getContentPane().add(new HTMLTest2().makeUI());
f.setSize(320, 320);
f.setLocationRelativeTo(null);
代码示例来源:origin: stackoverflow.com
public void run() {
JFrame frame = new HTMLLabelTest();
frame.pack();
frame.setVisible(true);
HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
StyleSheet styleSheet = new StyleSheet();
URL resource = getClass().getResource("/stylesheet.css");
styleSheet.importStyleSheet(resource);
htmlEditorKit.setStyleSheet(styleSheet);
label.setPreferredSize(new Dimension(30,20));
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.add(label);
panel.setOpaque(true);
代码示例来源:origin: pentaho/pentaho-reporting
/**
* Creates a new, uninitialized module editor.
*/
public DefaultModuleEditor() {
messages = Messages.getInstance();
contentpane = new JPanel();
contentpane.setLayout( new VerticalLayout() );
helpPane = new JEditorPane();
helpPane.setEditable( false );
helpPane.setEditorKit( new HTMLEditorKit() );
helpPane.setPreferredSize( new Dimension( 600, 100 ) );
final JPanel toolbar = new JPanel();
toolbar.setLayout( new BorderLayout() );
toolbar.add( new JScrollPane( helpPane ) );
toolbar.setMinimumSize( new Dimension( 100, 150 ) );
rootpane = new JSplitPane( JSplitPane.VERTICAL_SPLIT );
try {
// An ugly way of calling
// rootpane.setResizeWeight(1);
final Method m = rootpane.getClass().getMethod
( "setResizeWeight", new Class[] { Double.TYPE } ); //$NON-NLS-1$
m.invoke( rootpane, new Object[] { new Double( 1 ) } );
} catch ( Exception e ) {
// ignored ...
}
rootpane.setBottomComponent( toolbar );
rootpane.setTopComponent( new JScrollPane( contentpane ) );
}
代码示例来源:origin: es.gob.afirma/afirma-core-firmaweb
BrowserDialog(final String html, final Frame parent) {
super(parent, WebSignMessages.getString("BrowserDialog.13"), true); //$NON-NLS-1$
this.getAccessibleContext().setAccessibleParent(parent);
final JEditorPane ep = new JEditorPane();
ep.setEditable(false);
ep.setEnabled(false);
ep.addHyperlinkListener(this.linkListener);
getContentPane().add(new JScrollPane(ep), BorderLayout.CENTER);
setSize(600, 600);
final JPanel sur = new JPanel();
sur.add(new JButton(this.afirmar), BorderLayout.WEST);
sur.add(new JButton(this.anoFirmar), BorderLayout.EAST);
getContentPane().add(sur, BorderLayout.SOUTH);
ep.setEditorKit(this.kit);
try {
final Document doc = ep.getDocument();
this.kit.read(new StringReader(html), doc, 0);
disableContent(ep);
}
catch (final Exception e) {
LOGGER.severe(WebSignMessages.getString("BrowserDialog.14") + e); //$NON-NLS-1$
}
}
代码示例来源:origin: org.scijava/scijava-ui-swing
textPane = new JTextPane();
kit = new HTMLEditorKit();
doc = new HTMLDocument();
textPane.setEditorKit(kit);
textPane.setDocument(doc);
textPane.setEditable(false);
splitPane.add(new JScrollPane(tree));
splitPane.add(new JScrollPane(textPane));
clearHistory.addActionListener(this);
final JPanel buttonBar = new JPanel();
buttonBar.setLayout(new BoxLayout(buttonBar, BoxLayout.X_AXIS));
buttonBar.add(Box.createHorizontalGlue());
buttonBar.add(clearHistory);
代码示例来源:origin: stackoverflow.com
@Override
public void run() {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JEditorPane editorPane = new JEditorPane();
editorPane.setEditorKit(new HTMLEditorKit());
try {
editorPane.setPage(new URL("http://weblogs.java.net/blog/alex2d/archive/2008/12/jwebpane_projec.html"));
} catch (IOException ex) {
final JPanel panel = new JPanel(new BorderLayout());
panel.add(new JScrollPane(editorPane), BorderLayout.CENTER);
panel.add(new JButton(new AbstractAction("SAVE") {
@Override
public void actionPerformed(ActionEvent e) {
frame.setContentPane(panel);
frame.setSize(600, 400);
frame.setVisible(true);
代码示例来源:origin: stackoverflow.com
JEditorPane jEditorPaneIsFollower = new JEditorPane();
jEditorPaneIsFollower.setEditable(false);
jEditorPaneIsFollower.setContentType("text/html");
jEditorPaneIsFollower.setDocument(new HTMLDocument());
jEditorPaneIsFollower.setEditorKit(new HTMLEditorKit());
jEditorPaneIsFollower.setText(HTML_TEXT);
ToolTipManager.sharedInstance().registerComponent(jEditorPaneIsFollower);
return new JScrollPane(jEditorPaneIsFollower);
JFrame f = new JFrame();
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.getContentPane().add(new HyperlinkTooltipTest().makeUI());
f.setSize(320, 240);
f.setLocationRelativeTo(null);
代码示例来源:origin: org.cytoscape/work-swing-impl
dialog.setPreferredSize(new Dimension(500, 400));
pane = new JEditorPane();
pane.setEditable(false);
pane.setContentType("text/html");
final HTMLEditorKit htmlEditorKit = (HTMLEditorKit) pane.getEditorKit();
final StyleSheet styleSheet = htmlEditorKit.getStyleSheet();
styleSheet.addRule("ul {list-style-type: none;}");
final JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
buttonsPanel.add(cleanButton);
final JScrollPane scrollPane = new JScrollPane(pane);
代码示例来源:origin: stackoverflow.com
StyleSheet styleSheet = new StyleSheet();
styleSheet.addRule("body {font-family:\"Arial\"; font-size:12; } ");
HTMLEditorKit messageEditorPaneHTMLEditorKit = new HTMLEditorKit();
messageEditorPaneHTMLEditorKit.setStyleSheet(styleSheet);
HTMLDocument document = (HTMLDocument) messageEditorPaneHTMLEditorKit.createDefaultDocument();
JEditorPane editorPane = new JEditorPane("text/html", "");
editorPane.setEditorKit(messageEditorPaneHTMLEditorKit);
editorPane.setDocument(document);
});
JFrame frame = new JFrame("Styling example");
JPanel contentPane = new JPanel();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
contentPane.add(editorPane);
contentPane.add(changeStyleButton);
frame.setContentPane(contentPane);
frame.setSize(300,300);
frame.setLocationRelativeTo(null);
代码示例来源:origin: fr.ifremer/isis-fish
$objectMap.put("$JScrollPane0", $JScrollPane0 = new JScrollPane());
$JScrollPane0.setName("$JScrollPane0");
SwingUtil.setComponentHeight($JScrollPane0,200);
createDoc();
createComboResult();
$objectMap.put("$JPanel0", $JPanel0 = new JPanel());
$JPanel0.setName("$JPanel0");
$JPanel0.setLayout(new GridLayout(0, 3, 2, 2));
createOk();
createReset();
setModalityType(Dialog.ModalityType.APPLICATION_MODAL);doc.setEditable(false);doc.setEditorKit(new HTMLEditorKit());doc.addHyperlinkListener(createHyperLinkListener());// registers 2 data bindings
$registerDefaultBindings();
$completeSetup();
代码示例来源:origin: stackoverflow.com
JFrame jFrame = new JFrame();
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container container = jFrame.getContentPane();
container.setLayout(new BorderLayout());
container.add(new JTextField(), BorderLayout.NORTH);
JEditorPane editorPane = new JEditorPane();
editorPane.setEditorKit(new HTMLEditorKit());
editorPane.setText("<html><body>Hello World</body></html>");
container.add(editorPane, BorderLayout.CENTER);
代码示例来源:origin: stackoverflow.com
"</html>";
JEditorPane swingbox = new JEditorPane ();
swingbox.setEditorKit(new HTMLEditorKit());
swingbox.setContentType("text/html");
swingbox.setText(html);
JFrame frame=new JFrame("Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(swingbox);
Dictionary cache=(Dictionary)swingbox.getDocument().getProperty("imageCache");
代码示例来源:origin: stackoverflow.com
+ "<v><q><vn>5 </vn>De Rahab, Salma eut pour descendant Booz.<br/>De Ruth, Booz eut pour descendant Obed.</q></v></c></p>";
final JFrame mainFrame = new JFrame("test");
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JTextPane field = new JTextPane();
field.setContentType("text/html");
HTMLEditorKit kit = (HTMLEditorKit) field.getEditorKit();
HTMLDocument doc = (HTMLDocument) field.getDocument();
kit.read(r, field.getDocument(), 0);
} catch (IOException | BadLocationException ex) {
Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
kit.write(w, field.getDocument(), field.getSelectionStart(), field.getSelectionEnd()-field.getSelectionStart());
System.out.println(w.toString());
} catch (IOException | BadLocationException ex) {
mainFrame.getContentPane().setLayout(new BorderLayout());
mainFrame.getContentPane().add(field,BorderLayout.CENTER);
mainFrame.setSize(500,500);
mainFrame.setVisible(true);
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame();
JEditorPane edPane = new JEditorPane();
edPane.setContentType("text/html");
System.out.println(edPane.getText());
HTMLEditorKit hek = new HTMLEditorKit();
edPane.setEditorKit(hek);
doc.insertAfterEnd(body,"<img src="+ClassLoader.getSystemResource("thumbnail.png").toString()+">");
System.out.println(edPane.getText());
} catch(BadLocationException e) {
frame.add(edPane);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.pack();
frame.setVisible(true);
内容来源于网络,如有侵权,请联系作者删除!