jeditorpane

How do I set both StrikeThrough and Underline styling options for text inside a JTextPane?

家住魔仙堡 提交于 2019-12-01 00:20:58
I have a JTextPane component and I am trying to style the text that will be typed by the user to be both underline and strikethrough at the same time. The relevant snippet of code that that should set the strikethrough attribute of the next typed character to true is this: JEditorPane editor = getEditor(e); if (editor != null) { StyledEditorKit kit = getStyledEditorKit(editor); MutableAttributeSet attr = kit.getInputAttributes(); SimpleAttributeSet sas = new SimpleAttributeSet(); StyleConstants.setStrikeThrough(sas, true); setCharacterAttributes(editor, sas, false); } This does style the text

Making a JEditorPane with html put correctly formatted text in clipboard

老子叫甜甜 提交于 2019-11-30 11:32:24
I have this code to demonstrate the problem: public static void main(String[] args) { JFrame frame = new JFrame(); frame.getContentPane().add(new JEditorPane("text/html", "Hello cruel world<br>\n<font color=red>Goodbye cruel world</font><br>\n<br>\nHello again<br>\n")); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } If you select all the text that appears in the frame once the app starts, you can copy it and paste it into MS Word, Apple's Pages, or Mail and the text is formatted correctly. But if you paste it

JEditorPane linewrap in Java7

怎甘沉沦 提交于 2019-11-30 10:16:53
First of all I hope it's not a problem I started a new topic. Tbh I don't have a clue how to ask a question based on an already answered one, so I made this. I'm pretty new with Java and my problem is the following. I'm writing a little chat program and I'm using a JEditorPane with an HTMLEditorKit to display text in different colors, to display smileys, and display hyperlinks. My problem is, and after some research I found out the problem might be due to Java7, I can't get the linewrap working properly. I want the text to word wrap and to wrap in the middle of Strings exceeding the width of

Java - HTML5 alternative to JEditorPane

落花浮王杯 提交于 2019-11-30 08:44:10
问题 I am trying to create a simple web browser for a project, but I am using JEditorPane to render and display HTML. I have heard that JEditorPane should not be used as a browser component because it does not support anything above HTML3.2 (and even then doesn't display it properly), but I can't seem to find an alternative for HTML5. Can anyone help me? Thanks in advance. 回答1: You can use JavaFX-2 Webview. From the JavaFX-2 Adding HTML Content tutorial docs: The embedded browser component is

How to make a red zig zag under word in JEditorPane

邮差的信 提交于 2019-11-29 23:47:14
问题 I need to make a simple spell checker in Java for an application that I am creating and I have searched around and have not found any straight and to the point answers. How do I make a word in JEditorPane get underlined with a red zig-zag? Like this: Please if any one has any simple and fairly easy to implement ideas please would you share them with me. Maybe even some links to some code. 回答1: You may find this custom editor kit example useful. It shows how to extend StyledEditorKit to add

Display and interact with an HTML form in a Swing application

删除回忆录丶 提交于 2019-11-29 18:19:11
问题 an application generates some HTML pages that should be displayed in the application itself. These HTML pages contain some forms that would be used by the user to enter some values. So far I've used a JTextPane which renders the HTML perfectly, but I do not know how to interact with the form to retrieve the values entered by the user. _ Is it possible to do so with a JTextPane / JEditorPane ? If no, do you now any other way to interact with an HTML form ? _ EDIT : following tulskiy

JEditorPane linewrap in Java7

自作多情 提交于 2019-11-29 15:17:50
问题 First of all I hope it's not a problem I started a new topic. Tbh I don't have a clue how to ask a question based on an already answered one, so I made this. I'm pretty new with Java and my problem is the following. I'm writing a little chat program and I'm using a JEditorPane with an HTMLEditorKit to display text in different colors, to display smileys, and display hyperlinks. My problem is, and after some research I found out the problem might be due to Java7, I can't get the linewrap

How should HTML for Java components reference resources?

*爱你&永不变心* 提交于 2019-11-29 10:51:25
Resources for HTML (style sheets, images etc.) might not be loaded correctly when: A Swing app. is distributed, or when it is put into a Jar file. The HTML is generated at run-time. How can such resources be accessed reliably in the HTML? HTML from a Jar file that links resources (e.g. CSS or images) by relative references will work just fine. E.G. This example loads HTML (that has a relative reference to an image) from a Jar. import javax.swing.*; import java.net.URL; class ShowHtml { public static void main(String[] args) { final String address = "jar:http://pscode.org/jh/hs/object.jar!

Java - HTML5 alternative to JEditorPane

﹥>﹥吖頭↗ 提交于 2019-11-29 07:14:29
I am trying to create a simple web browser for a project, but I am using JEditorPane to render and display HTML. I have heard that JEditorPane should not be used as a browser component because it does not support anything above HTML3.2 (and even then doesn't display it properly), but I can't seem to find an alternative for HTML5. Can anyone help me? Thanks in advance. Bruno Vieira You can use JavaFX-2 Webview . From the JavaFX-2 Adding HTML Content tutorial docs: The embedded browser component is based on WebKit, an open source web browser engine. It supports Cascading Style Sheets (CSS),

jEditorPane as a web browser

泄露秘密 提交于 2019-11-29 06:40:38
I am creating a web browser in Java. In this browser I am using JEditorPane for Browser Window. I am using "setPage(String url)" method to display the page. The browser can display the page but there are some problems which are as mentioned:: The browser is not displaying the java script. It is not displaying the Applet. Brows data does not show in proper way(like as a browser(Show in image )). My code is- JEditorPane editorPane = new JEditorPane(); String url="http://google.co.in"; editorPane.setEditable(false); try { editorPane.setPage(url); } catch (IOException e) { System.err.println(