I have a swing application that sends commands to server and receives result in XML format. I need to transform this into HTML via XSLT and then display result HTML on the panel. The problem is that the only Swing component which is able to display HTML - JEditorPane - takes either URL or javax.swing.text.StyledDocument as a source.
Option with URL doesn't work for me because I have to save my html as a file on the file system first and I'd like to avoid this.
So I have a gap between in-memory result of XSL transformation and javax.swing.text.StyledDocument, which can be rendered by JEditorPane or JTextPane.
How to transform one to another? Or are there any other Swing solutions to display HTML from some in-memory source(DOM or String or whatever)?
Thank you in advance for help.
Is there a reason that JEditorPane.setText() does not work for you?
I use JEditorPane all the time and I've never pulled the displayed data from a file or URL. So it is possible. Just need to figure out why it's not working for you.
To be specific:
editor.setContentType( "text/html" );
editor.setText( "<html><body>Hello, world</body></html>" );
What about JeditorPane.setText() ?
Related
I'm trying to open a URL in my application through the displayHelpResource(href) function.
But I'm being shown the following :
This content cannot be dispalyed in a frame
To help protect the security of information you enter into this website, the publisher of this content does not allow it to be displayed in a frame.
I've understood that the site is blocking the Frame access. What can be done to open the desired URL using the displayHelpResource(href) function.
You can add noframes=true to the href you stop frames being used
http:xxxxx?noframes=true
The noframes=true text is removed from the href by the help system before it is actually used.
I'm making an app which will display quite a lot of information in text. I would love to be able to change this text without having to do any updates to the app itself and there-fore it would be great to just get the text from a simple HTMl-file from a server and display it in a textview. Is this possible?
TL;DR: Is there a way to display text from a remote HTML-file in a textview?
-Alexander
Your app can send a request to get your HTML page and then set the value of a TextView to be the content of the page as shown in this example: https://developer.android.com/training/volley/simple.html
I create pdf using Velocity template, but i am not able to put images in pdf.
I am adding url into context object and accessing that object into eot.vm file, url is going proper but still images are not displaying in pdf.
Thanks & Regards,
Tushar
Make sure that URL you are passing is sending IMAGE as response not an full html page.
i was passing URL that was sending me a whole html page, so i was unable to see images.
But now its fixed.
Please visit below link:
https://answers.atlassian.com/questions/2907/how-to-access-image-generated-via-velocity-template-confluence
Good evening,
I've been trying to display html code in a JEditorPane with embedded images. The code for the image that I receive is the following:
<img title="1909-yamaha-nemesis2.jpg" alt="1909-yamaha-nemesis2.jpg" src="cid:ii_12d7652d11e8d9a6">
As you can imagine, I cannot display the image, any idea? I suspect it should be the CID codification.
Thank you in advance,
http://java-sl.com/tip_local_images.html
You can use the same approach and place your image in the local cache.
How can I open an HTML page and show it in a text area? (If I choose the HTML file with the JFileChooser, how can I open that page and show it in the text area?)
URL url = new URL(String s);
JEditorPane pane = JEditorPane(url);
But how can I find the link of the HTML file for inserting as s, here!?
A TextArea is for displaying/editing text, not for showing formatted HTML.
JEditorPane supports HTML markup, but only a rather limited subset.
For full HTML support, you're going to need third-party components. Look at the answers to this question for links.
Format the HTML with a <pre> tag
I guess you can use any properly formatted URL a browser would use e.g.
http://stackoverflow.com/questions/1239454/how-can-i-open-an-html-page-and-show-it-in-a-text-area
But then again Java is very keen on security and you might not be allowed to use certain URLs in your environment.
And like Michael Borgwardt said - the JEditorPane's support of HTML is very limited and some tags (i think <div> is one of them) as well as JavaScript are not supported.
For implementation of a simple browser have a look at this
JEditorPane Tutorial