I've implemented an interactive map applet, which is embedded in a web application. The application uses some Ajax, but has a predominantly page based structure.
The problem is, navigating away from and back to the page containing the applet causes an applet reload, which takes several seconds.
Possible ways to alleviate this problem I thought of are:-
Make the applet run continuously in a separate browser window (I lose integration with the main web app though)
Convert the web app to use Ajax exclusively to avoid page reloads
Implement the map view as a standalone desktop app
If there is some way of preventing applet reloads in the browser I would be very interested to hear about it, but I don't think this is possible due to the applet lifecycle.
I think that you enumerated all options, their advantages and disadvantages.
I'd like to suggest you a combination of options you suggested.
You can separate you applet into 2 components. First, heavy-weight application that will be started using a java web start. It will contain all application logic and will run in minimized (or even transparent) window. It will prepare image and send it via network to light-weight applet that just shows it.
I this case you do not loose your application integrity: map is shown in browser. The applet is very light weight, so it starts fast. The stand-alone app implements the most of programming logic.
Here is how to make window transparent: http://java.sun.com/developer/technicalArticles/GUI/translucent_shaped_windows/
Related
I've been trying to research for existing web browsers that do not have an address bar or additional controls on the UI. Ideally a web browser that has just the window frame. The reason is that I am writing a web application, which ideally I do not want the user to have the ability to navigate to other websites or have the ability to navigate backwards/forwards etc. Obviously I can write additional code that can prevent people from navigating other side/ backwards, etc, but ideally would like a clean Window for the user to work from.
So far i've explored the option of building a web browser UI using JavaFX. However the web application is built using Angular and the JavaFX web browser window flickers from time to time during a screen transition.
If there is anyone that can provide a recommendation of such a browser that would be greatly appreciated. Thanks.
Just curious if you have already looked into Kiosk modes for browsers as that is built in and meant to display a single website. If chromium has that then could could use that.
Chromium kiosk mode no address bar or menu
Edit:
https://github.com/chromium/chromium
When developing a Java web-based application, is it necessary to use AWT?
I've been researching this question and the answers are confusing. Take for example, Runescape. The user visits the website and can play the game right there. They can also download a desktop application to play the game with.
If I am developing a game application, and my main window is created in a JFrame but all of my graphics are processed in a JPanel inside the main window, will I be able to implement this inside of a web page without much difficulty in the future? I want my game to be accessible simply by visiting the website and running the application.
Additionally, I've seen people reference "Java Web Start". Will this load the java application inside of the website, or does it install/run Java and execute the program (so if my main function opens a JFrame, it would appear on your taskbar). Perhaps I'm having some confusion between a Java application and a Java applet.
..will I be able to implement this inside of a web page without much difficulty in the future?
No. The security environment around applets was made much stronger in recent times, but even then, browsers tend to put further hurdles between applets and 'onscreen, loaded applets'. Chrome is set to remove the plug-in which would normally embed applets and a few other things.
I want my game to be accessible simply by visiting the website and running the application.
Additionally, I've seen people reference "Java Web Start". ..
Yes, offering a link to a JWS launched JFrame will be a lot easier, and a better experience for the end user.
I was wondering how I could embed a browser like view in a Java client application, at the same time that I can interact with it by means of JavaScript.
The problem that triggered this question is the following:
The interface of my application consists of a (Google) map and some svg stuff.
This is easy to do in a browser.
However, I also need access to some special Java libraries that can process some information from the map (e.g., certain coordinates in the map) and that answers values that should influence the browser view (e.g., a path should be drawn over the map).
My first idea was to implement the Java side behaviour as a REST web service, so from JavaScript I will invoke this webservice sending relevant information about the map and using the answer to update the map. Nevertheless, for my current needs (this is only a prototype) using webservices is a bit too much of infrastructure.
Is there a way I could just:
embed a browser like view in my Java application.
Interact from the Java side with this view by means of JavaScript functions implemented in the web page displayed in the browser view (such as these functions will influence the rendering of the page in the browser like view) ?.
I found other questions related to how to embed a browser in a swing application (e.g., Embedding web browser window in Java) and JDIC seems to be able to do this. Although some people report it is difficult to make it work in OSX (the OS I use) and do not mention if it is possible to interact with the browser by means of JavaScript.
It seems to me that in Android it is possible to make JavaScript calls from the Java (Android) side, so probably this is also possible in plain Java.
Thanks for any pointer !
With Java FX 2 you can. You get a webkit webview there. Can interact with it back and forth with java<->javascript.
For an example embedding google maps see: http://java-buddy.blogspot.se/2012/03/embed-google-maps-in-javafx-webview.html
You can embed java fx in swing with JFXPanel if you don't want to go with 100% JavaFX yet.
If you can use swt, take a look at SWT Browser widget
For javascript you can use
http://www.mozilla.org/rhino/
I recently played around with the SWT browser widget (which is great). I am wondering if I could write a full desktop application with it (with java services behind - e.g. persistence) and what drawbacks I would have to consider. The advantage would be that people without java knowledge could work on the gui. Of course it depends on the requirements and I know that this is not a very specific question. But mabye someone already tried to build a bigger app this way and is willing to share insights.
Thanks
Marcel
I'm not sure I share your opinion of the SWT browser widget. AFAIK it's merely a shell into the default browser on your machine, merely with a few API access points. I've used it for minor things when I needed to show a web page from within the application. But writing a whole application? That doesn't make sense.
If you want to build a web-based application that runs in the browser against a Java based server framework, there are many AJAXian frameworks to do it. You'd still be doing JavaScript for your client code. And you'd still be dealing with all the complexities of different browsers. I'm not sure why you would want to host it inside an SWT application instead of just directly in the browser window.
OK so, let's say I have a Java applet that takes a while to load (~5 secs). It's getting the mysql-connector.jar and it's loading. Well.. instead of the gray box with the coffee logo... can I make it have a simple progress bar with the percent?
Thanks.
If you need the mysql-connector it seems like your application is fairly complex, and that you should, at least consider, using java webstart. From the faq:
How does Java Web Start relate to Java Plug-in Technology (applets)?
The two approaches are very similar. The key difference is in the user experience. If the Java application/applet needs to interact with a web page and be tightly bound to a web browser, then applets may be the solution. On the other hand, if browser independence is important, then Java Web Start is the deployment platform of choice.
If you really want to do the progress bar, this page describes a solution, but it's not trivial by any mean.