I have a java application which is for viewing content from web. So I want to add a fully functional browser in my application. I've already tried JEditorPane and it's not processing dynamic contents. Is there any other way?
Any help on how to do it?
This links are good examples for this:
create browser in swing
how-to-create-a-simple-browser-in-swing
Hope this helps.
If you are willing to pay for third party software you might want to consider JxBrowser:
http://www.teamdev.com/jxbrowser/
Related
I am looking to implement Etherpad's functionality into a Java Swing application. There is a Java library for accessing Etherpad's HTTP API, but it only seems to support getting/setting the entire pad text. I want to have live multi-user editing of plain text in Java, where all users see each other's changes realtime while editing. Can anybody point me in the right direction?
Just use: http://docs.oracle.com/javafx/2/swing/SimpleSwingBrowser.java.htm and point it at the Etherpad Pad URL you want to edit...
If I'm honest though, your question is not very clear in what you want to accomplish.
I found a Java library for easily accessing Etherpad's API. I combined this with the JavaFX web browser component and a custom Swing UI.
For anyone finding this on Google or something, you can see my code on GitHub as a standalone app here: https://github.com/Netsyms/SyMATPadViewer
Feel free to use it (BSD license), just change the PADS_URL in the PadUtils class and put your Etherpad API key in the file padkey at the root of the src directory.
I need to access HTML elements from my Java program based on the id or className of the element (like getElementByID or getElementsByClassName). I also need to be able to click a few buttons on the page.
Main Points:
I am creating a desktop application. It is not a web app.
I need a browserless solution
My code needs to auto fill a form and submit it without opening a page.
Are there any libraries out there that could suit my needs, or could I achieve this in plain Java code? If my question isn't clear please let me know and I will try to explain it in a better way. Thank you.
Selenium is a library used for scraping html elements using java. It is often used for testing. There is another library called Vaadin. It is used for doing front-end work on the back-end using java. It is similar to Java Swing but used on the web. Hope this helps!
I have Java code of the algorithm that has numeric values as its input and output. The GUI is implemented as Swing in Eclipse. Now I would like to tranfer to the web environment and create the web-tool using JavaScript or sth like this. Is there any way to use the Java code of my algorithm without rewriting it?
if your logic and goi all together at the same class you need to remove all the GUI part and stay with all the logic. after you have logic class you can use what ever goi you want(swing, html, jsf....)
Another alternative is to skip the HTML part by hand and just create your HTML app in Java. No need for separate servlets serving Java validation to your HTML inputs. The open source framework Vaadin that we've been working on since 2001 and it has an almost 100% similar API to Swing could be an alternative for this for you. And it would hopefully save you a lot of time.
As a swing developer the most relevant starting point for you would be: https://vaadin.com/swing
You can look up in to servlets and if you do it in netbeans then will be much easier for you.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Is there a way to embed a browser in Java?
I am working on an application where I have to embed a web browser with application. Any ideas on how to achieve it? Also will I be able to interact JavaScript from within the code?
see this post .... Embed a web browser within a java application
check out Eclipse, it has an embedded browser which is configurable by the user (they support multiple browsers).
you can probably embed their browser even if you use an AWT based application using the AWT_SWT bridge if you are using Java swing application.
this article may help you get started.
Check out Lobo
[Lobo] is an open source web browser that is
written completely in Java. Lobo is
being actively developed with the aim
to fully support HTML 4, Javascript
and CSS2. Lobo also supports direct
JavaFX rendering.
For very simple pages, you can use the JEditorPane, which is in the Swing API: see doc
I'm afraid that embedding a real browser is your only option, if you need JavaScript capabily and AJAX etc. look at JavaXPCOM API in order to see how easily you can embed FireFox. There is also JDIC, that will allow you to embed IE in Windows environments. You will need some DLL files but the procedure is straight forward with both APIs and well documented.
Let's admit that JEditorPane is fine, but mainly for HTML you have control over. I use it only to render HTML help files into my application. Once you start visiting sites with it things start getting nasty.
Does anybody know of a pure java (ar at least cross platform) open source component/library which displays HTML which can contain swing components inside it?
All I could find were either abandoned or incomplete.
I am asking because I'm thinking about trying out approach to do use this combination for creating desktop application.
EDIT:Seems like this question is missunderstood, so let me clarify it. I basically want to create desktop application in the similar way as web. Idealy I would like browser to serve as an UI layer. That browser should allow me to embed my own compoents, eg to be able to use JTextField instead of <input type="text">.
Since I don't know of such easily usable browser, I was asking for a html component which will let me do it. I hop the question is clearer right now.
JEditorPane already supports what you want to do. It can render HTML (pretty crappily, I'll admit) and you can embed Swing components in that HTML using the <object> tag. Here is a blog post that demonstrates this technique: http://weblogs.java.net/blog/aim/archive/2007/07/index.html
Otherwise, I don't think you have a lot of options.
I think the question is the other way around or, better, goes further than using JTextPane. As I understand the question: Marko needs a Java component that can display HTML and additionally is able to contain further Swing components. Say, there should be a new tag
<swing jclass="MySwingComponent" />
which would render that MySwingComponent class. Not sure, maybe it would also be okay to have a HTML-able Swing component that can embed further applets?
And no, I don't know of such a thing. Sorry.
JavaFX maybe?
check out xhtmlrenderer: https://xhtmlrenderer.dev.java.net/
You will have to work wit it to get it to do all you want.
I thought Google Web Toolkit allowed you to write a UI in terms of Java/Swing. It would then convert it to JavaScript. Maybe that's what you're looking for.