Swing components inside HTML - java

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.

Related

making a browser without using JTextPane or any other class that reads HTML

Good evening, I'm working on a project with a team, we have to make a browser without using JEditorPane or any other class that reads HTML.
How can we do that? Do we need to make a new class that does what JEditorPane does? Can I find somewhere JEditorPane's code? Thanks!
Well, this is an answer:
If you need to display web content without using any pre-existing engine (such JEditorPanel or a ChromeBind), you need to read the HTML as a XML file and construct your native View based on it (without CSS and JS this is a fairly easy task) by constructing the screen based on a one-to-one equivalent of a HTML tag to a Java JComponent.
Modern Web Browsers are pretty complicated, so there are a lot of different pieces that come together to display a web page. In order to build a browser, you need to first understand what a browser is. For that, I recommend reading this tutorial.
Once you have an understanding of how a browser actually works you need to determine which pieces you can reuse and which pieces you have to write from scratch. Do you have to write the entire rendering engine? Good luck! Can you use an existing engine like Gecko or Webkit? Or maybe you can get a little closer to done and use the java port of Webkit?
Once you have a better understanding of the question come back and ask more direct questions when you get stuck at a specific piece. As it is, your first step is to gain an understanding of the problem you are trying to solve.

Accessing HTML elements from java

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!

Generating Java GUI code from basic HTML/Javascript

I would like to know the best way and what it would require(languages/libraries) to generate Java GUI code from an HTML page with embedded Javascript code. It would emulate the HTML objects(like divs/tables) and their interactions. I don't need to emulate any complicated Javascript libraries, but just get basic functionality like handling mouse clicks/movements and key presses which Java can easily support.
I was thinking of representing all of the HTML objects using absolute positioning in Java without having to generate code for layout managers.
EDIT:
Regarding seand's comment: I meant that I don't need to convert code written in JQuery or other Javascript libraries into Java GUI code. I only want to deal with simple Javascript.
I was searching as well and it appears that nothing seems really meant to do that.
However one option is to embed a browser into your app using something like:
http://djproject.sourceforge.net/ns/
http://www.eclipse.org/articles/Article-SWT-browser-widget/browser.html
And then used it to load your HTML pages.

Converting Swing app to web

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.

Add a web browser in my Java application

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/

Categories

Resources