0

See question above. I found a library called JSoup which makes it possible to kid of parse HTML into the console but how do I do that into a Jpanel or other Component?

The1NOnly
  • 9
  • 2

1 Answers1

0

Yes, have a look here for information about using text components and here for information on how JEditorPane supports HTML.

Alex Voss
  • 147
  • 9
  • Thanks for the links. Actually my html code which Iwant to include seems to be too complicated for JEditorPane (there is a script tag in it). – The1NOnly Jul 30 '20 at 11:57
  • Do you need JavaScript to run or is JEditorPane not rendering because of the script element? – Alex Voss Jul 30 '20 at 12:00
  • This might help: https://stackoverflow.com/questions/13717769/jeditorpane-with-javascript-and-css-support – Alex Voss Jul 30 '20 at 12:01
  • Sadly I am not allowed to use any version above JAVA SE 11 :/ – The1NOnly Jul 30 '20 at 12:03
  • I want to inclue a online weather forecast and there are several weather widget html codes but I can't use them in a JEditorPane – The1NOnly Jul 30 '20 at 12:03
  • Is there a text-based weather forecast which I could include maybe? Or can I use Jsoup to that and if yes, how? – The1NOnly Jul 30 '20 at 12:04
  • Java 11 should be fine, no? This might help: https://stackoverflow.com/questions/18547362/javafx-and-openjdk – Alex Voss Jul 30 '20 at 12:10
  • You can try using a Jsoup Cleaner to restrict HTML to what the JEditorPane support: https://jsoup.org/apidocs/org/jsoup/safety/Cleaner.html Depends on how the data source works. Does the source not provide an API for the same data so you could render the data yourself? – Alex Voss Jul 30 '20 at 12:24
  • Link-only answers are discouraged here. While your links are useful, please consider adding a summary of the information they contain, and a short example of how one might use that information (for example, an example that places HTML in a JLabel and another example that loads HTML in a JEditorPane). – VGR Jul 30 '20 at 14:29