Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 months ago.
Improve this question
What libraries/methods do you know of that can do some basic HTML representation in Swing? Can you comment on your experience?
A good pure Java solution is JWebEngine. It render HTML 4 very good.
Many of the Swing controls (like JLabel) can render basic HTML content. JEditorPane can be used to display HTML pages. However, these controls are limited to HTML 3.2 support.
For a richer experience, I would use the JDesktop Integration Components.
JDIC provides Java applications with
access to functionalities and
facilities provided by the native
desktop. It consists of a collection
of Java packages and tools. JDIC
supports a variety of features such as
embedding the native browser,
launching the desktop applications,
creating tray icons on the desktop,
registering file type associations,
creating JNLP installer packages, etc.
I haven't tried this in a while, but a quick google search shows some possibilities:
Java Sketchbook: The HTML Renderer Shootout, Part 1
Cobra: Java HTML Renderer & Parser
Are you trying to do this in an applet, or an application? If it's an application (or signed applet) you could potentially instantiate IE or Firefox within your application. Webrenderer acts as a Swing wrapper for this.
Swing has a built-in compontent called BasicHTML. I've never used it, but I think it should be sufficient for the basic stuff.
This has historically been a major weak point for Java, IMO. There are numerous ways to display limited markup, but very few that offer full featured HTML capabilities. The previously mentioned JDIC component is one option, however it is considered a "heavyweight" component and therefore does not always integrate well with Swing applications.
I am hopeful, however, that the new Webkit based JWebPane project will provide more advanced capabilities without all of the issues that we've had to deal with in the past. And, of course, there are several commercial options as well (IceBrowser is pretty good as an example).
I've just used SwingBox to display a quite simple HTML page, with good results.
The project includes a simple demo application which compares its BrowserPane component to JEditorPane, showing a far better result on complex pages (but still not comparable with a modern web browser).
The only issue I had is about unwanted scrollbars from the wrapping JScrollPane. The demo application seems to have the same problem. I can't tell where the issue originates. I'm using version 1.0.
Here a code fragment to show how simple is to use the component:
BrowserPane browserPane = new BrowserPane();
JScrollPane scrollPane = new JScrollPane(browserPane);
someContainer.add(scrollPane);
browserPane.setText("<html><b>Some HTML here</b></html>");
// or...
browserPane.setPage(new URL("http://en.wikipedia.org"));
Came across Lobo java web browser the other day.
Lobo is being actively developed with the aim to fully support HTML 4, Javascript and CSS2.
No experience with it though, but thought it may fit the bill for you.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Is there a way to embed a browser in Java? more specifically, is there a library that can emulate a browser?
Since JavaFX 2.0 you can use now webview
I believe JWebPane is going to be the official way to embed a browser into a java app. Its based on the open sourced engine - WebKit, which is used in Apples Safari and Googles Chrome browsers.See this blog for details.
You may try this: https://jdic.dev.java.net/
(source: java.net)
Or this: http://lobobrowser.org/java-browser.jsp
(source: lobobrowser.org)
You could use SWT for your GUI. Its Browser control allows you to embed IE, Mozilla or Safari (depending on the platform you're running in) with little pain.
By far the most robust embeddable browser I am familiar with is the one in SWT.
In fact, it is so flexible that the JavaDoc hover you can see in Eclipse is actually a browser, and the JavaDoc view actually supports things like animation!
The only risk with using SWT is that there are different versions of the SWT library for different platforms. I'm not sure if there is a singl jar you could include to cover everyone.
Take a look at
https://xhtmlrenderer.dev.java.net/
JxBrowser has not been mentionned yet. It embed either Mozilla Firefox (Gecko), Apple Safari (WebKit) or Internet Explorer. Programmer's Guide
You could also try the JWebBrowser from DJ Native Swing: http://djproject.sourceforge.net/ns
I have successfully opened a browser from Java using SWT. You can find code examples of how to use SWT to open a Browser window. It's very easy to do.
You can embed a browser in a Swing/AWT GUI using the JDIC API. I don't see any mention of OS X, so it may not be of use to you.
You can try Webrenderer or Ice Browser
If you need a pure Java solution then you can try JWebEngine. It render HTML 4 very good. You can use it in an applet, Java webstart and on any platform. The using is very simple.
You could try a JEditorPane, it doesn't interpret advanced HTML, nor Javascript, nor advanced CSS, but you can write that part yourself, called the EditorKit. That is the class/object that is consulted by the JEditorPane or how it has to display its content.
I know its possible, because I tried and failed (:P), but it could be outdated or deprecated by now, I don't know.
Maybe Chromium Embedded Framework is an option for you. Specific to Java there is
javacef for SWT: https://github.com/wjywbs/javacef
java-cef for AWT: https://bitbucket.org/chromiumembedded/java-cef
If you look at The Minecraft launcher (the old one), look through LoginForm or LauncherFrame, you may be able to find out that method. There is a tutorial by kippykip on youtube on how to decompile and edit it: here
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Is there a way to embed a browser in Java? more specifically, is there a library that can emulate a browser?
Since JavaFX 2.0 you can use now webview
I believe JWebPane is going to be the official way to embed a browser into a java app. Its based on the open sourced engine - WebKit, which is used in Apples Safari and Googles Chrome browsers.See this blog for details.
You may try this: https://jdic.dev.java.net/
(source: java.net)
Or this: http://lobobrowser.org/java-browser.jsp
(source: lobobrowser.org)
You could use SWT for your GUI. Its Browser control allows you to embed IE, Mozilla or Safari (depending on the platform you're running in) with little pain.
By far the most robust embeddable browser I am familiar with is the one in SWT.
In fact, it is so flexible that the JavaDoc hover you can see in Eclipse is actually a browser, and the JavaDoc view actually supports things like animation!
The only risk with using SWT is that there are different versions of the SWT library for different platforms. I'm not sure if there is a singl jar you could include to cover everyone.
Take a look at
https://xhtmlrenderer.dev.java.net/
JxBrowser has not been mentionned yet. It embed either Mozilla Firefox (Gecko), Apple Safari (WebKit) or Internet Explorer. Programmer's Guide
You could also try the JWebBrowser from DJ Native Swing: http://djproject.sourceforge.net/ns
I have successfully opened a browser from Java using SWT. You can find code examples of how to use SWT to open a Browser window. It's very easy to do.
You can embed a browser in a Swing/AWT GUI using the JDIC API. I don't see any mention of OS X, so it may not be of use to you.
You can try Webrenderer or Ice Browser
If you need a pure Java solution then you can try JWebEngine. It render HTML 4 very good. You can use it in an applet, Java webstart and on any platform. The using is very simple.
You could try a JEditorPane, it doesn't interpret advanced HTML, nor Javascript, nor advanced CSS, but you can write that part yourself, called the EditorKit. That is the class/object that is consulted by the JEditorPane or how it has to display its content.
I know its possible, because I tried and failed (:P), but it could be outdated or deprecated by now, I don't know.
Maybe Chromium Embedded Framework is an option for you. Specific to Java there is
javacef for SWT: https://github.com/wjywbs/javacef
java-cef for AWT: https://bitbucket.org/chromiumembedded/java-cef
If you look at The Minecraft launcher (the old one), look through LoginForm or LauncherFrame, you may be able to find out that method. There is a tutorial by kippykip on youtube on how to decompile and edit it: here
Okay, i am officially scared to ask this question. I am a PHP developer that is attempting to learn the language of JAVA. My experience limits me to PHP, JavaScript and basic CSS to develop and style my web apps.
I would like to know, and this is embarrassing, What technology is used to "Style" JAVA Applications just like CSS is used to "Style" HTML & PHP applications?
I feel so stupid asking this! Please don't think i am an idiot, i am really good with PHP.
I tried to google the answer but gained more questions than answers.
Web Application using Java:
Frontend is same i.e. HTML/Javascript/CSS
Backend Java (from where data you will get, connect with DB etc etc) similar to role of PHP
Desktop Application:
you can use Java Swing for UI and other API for respective work.
Mobile Application:
use J2ME API for developing application
UI here is developed using JAVA API(only api that are allowed to use under KVM (kilobyte virtual machine)).
For better look and feel there are frameworks for it.
What about JavaFX? As far as I know there are similarities to CSS. However, most of the Java applications are designed to match the system's look-and-feel. That's why tweaking is not as important as to web pages. If you want to start with that, have a look at Swing components. Be aware that JavaFX will be included in Java 8. So JavaFX may be seen as the next gen GUI.
Basically U use JSP/JSF/HTML for front end . There too you can use your CSS skills .. That is CSS can be used for styling ...
Assuming you are doing a desktop application, not internet application - as otherwise PHP and especially HTML/CSS would suffice.
Java Swing is a cross-platform emulation of GUI components. It has so called Look and Feels, one of which is the System L&F, which under Windows tries to look as the Windows GUI. Another is really cross-platform looking: the Nimbus L&F. And there are other Look-and-Feels, even from third parties.
Start with System or Nimbus Look and Feel.
Besides that one might set default colors/fonts for specific type of things. One may query them with SystemColor.activeCaptionText or so. Nice for White on Black.
Inside Swing one uses layouts to do the layouting. Generally not pixel perfect, but with really cross-platform, with consideration for different buttons, menues and such.
Use a GUI editor; I am always advocating the NetBeans IDE, also for its simplicity. Though eclipse is very nice too.
Use separate classes, do not pack all in a GUI class, as that becomes a maintenance mess.
The text components: JLabel, tooltip, and so on, have HTML capabilities: "<html><b>Bold</b><i>Italics</i>".
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Is there a way to embed a browser in Java? more specifically, is there a library that can emulate a browser?
Since JavaFX 2.0 you can use now webview
I believe JWebPane is going to be the official way to embed a browser into a java app. Its based on the open sourced engine - WebKit, which is used in Apples Safari and Googles Chrome browsers.See this blog for details.
You may try this: https://jdic.dev.java.net/
(source: java.net)
Or this: http://lobobrowser.org/java-browser.jsp
(source: lobobrowser.org)
You could use SWT for your GUI. Its Browser control allows you to embed IE, Mozilla or Safari (depending on the platform you're running in) with little pain.
By far the most robust embeddable browser I am familiar with is the one in SWT.
In fact, it is so flexible that the JavaDoc hover you can see in Eclipse is actually a browser, and the JavaDoc view actually supports things like animation!
The only risk with using SWT is that there are different versions of the SWT library for different platforms. I'm not sure if there is a singl jar you could include to cover everyone.
Take a look at
https://xhtmlrenderer.dev.java.net/
JxBrowser has not been mentionned yet. It embed either Mozilla Firefox (Gecko), Apple Safari (WebKit) or Internet Explorer. Programmer's Guide
You could also try the JWebBrowser from DJ Native Swing: http://djproject.sourceforge.net/ns
I have successfully opened a browser from Java using SWT. You can find code examples of how to use SWT to open a Browser window. It's very easy to do.
You can embed a browser in a Swing/AWT GUI using the JDIC API. I don't see any mention of OS X, so it may not be of use to you.
You can try Webrenderer or Ice Browser
If you need a pure Java solution then you can try JWebEngine. It render HTML 4 very good. You can use it in an applet, Java webstart and on any platform. The using is very simple.
You could try a JEditorPane, it doesn't interpret advanced HTML, nor Javascript, nor advanced CSS, but you can write that part yourself, called the EditorKit. That is the class/object that is consulted by the JEditorPane or how it has to display its content.
I know its possible, because I tried and failed (:P), but it could be outdated or deprecated by now, I don't know.
Maybe Chromium Embedded Framework is an option for you. Specific to Java there is
javacef for SWT: https://github.com/wjywbs/javacef
java-cef for AWT: https://bitbucket.org/chromiumembedded/java-cef
If you look at The Minecraft launcher (the old one), look through LoginForm or LauncherFrame, you may be able to find out that method. There is a tutorial by kippykip on youtube on how to decompile and edit it: here
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I am looking for an extensive example or, the most preferably, an open source project with a nice, modern, ajax-enabled user interface which is using JQuery or YUI on top of Java web application - it can be full Java EE application, JSF only, Spring MVC application, anything.
I would like to learn what are best practices to create such applications. In particular how to efficiently make use of the JavaScript library with a chosen Java web UI technology: JSP, JSF, Spring MVC, etc.
I am not particularly interested in simple demo examples, simple things I can figure out myself, I need something bigger so I would be able to investigate overall UI creation strategy, how clean the code is, how difficult were particular features to apply, etc.
You will find plenty of ways to build web apps, and I'm not sure there's a clear winner. In the end it is just a matter of personal taste or related to your knowledge background.
My advice anyway when you will look at them is to consider a clear separation between the frontend and the backend, and build a flexible UI (in the model of iGoogle or netvibes)
The frontend, presents the information in a human format. The browser code is JS, HTML and CSS. May be flash if you really want.
While the backend handle the authentication/security and the business logic and send or receive only JSON or XML messages.
I did that before with SAP serving XML and the browser rendering it with XSLT and Javascript.
And now in my current project Erlang serving JSON and the browser rendering it with a JS template engine and JS.
In both cases, this is giving really responsive web apps. As you optimise the network usage.
And finally about the flexible UI. I mean think in widgets instead of a monolithic app. It is not easy to get, but once it runs it is an amazing way of building web apps.
Here is a small video we just released to highlight this.
My personal favorite is jQuery on top of Spring-MVC. SpringSource.org has put together many great sample applications demonstrating the Spring-MVC framework, and the "mvc-ajax" project includes some great jQuery examples of how to generate ajax requests to the server that returns json to the browser.
The subversion repository for these projects is here.
Many jQuery components are actually being wrapped inside different components from jsf libs (like RichFaces).
As I understand (I only worked for few months with jsf and so I'm still a newbie) it's counted a bad practice to mix jQuery UI with clear jsf (with components) ui.
I can only guess that if you want to use jQuery UI with your jsf then you probably need to create custom jsf component and wrap chosen jQuery component.
The best example i can give you is GOOGLE.
They use all the stuff you talked about.
Unfortunatly GOOGLE will not give any part ot their code.