I have a JAVA application that, every five minutes, transfers data from a Data Base A to a Data Base B. Then, the application makes some calculations with the data of the Data Base B, and shows the results in a java swing panel. The application is continuously running. All ok.
I would like to see this java swing panel from other computers (more than one). So the idea is to see the panel from different computer whenever you want. I have thought of making a webpage showing the results, but I have no idea of making webpages and I haven’t much time to deal with it.
Is it possible to make a fast java application (or anything else) that connects with my swing panel from another computer?
Thank you very much!
You could use an applet, your Swing components will be added to a JApplet instead of a JFrame, and any web client can download the full application. You will still need to make a web page, but it could only have your Java applet in it.
Related
I'm new here and not so much familiar with applets.
I searched the site and many other forums for answer but i found nothing.
I have made an application in Java which starts with an applet login form, and continues with JFrame subforms which are doing several things like running JOptionPanes for example when a customer make a change in his profile.
My problem is that when the JOptionPane appears, the applet start form comes on top even if i have opened 2 or 3 JFrames.
I forgot to say that my app is big so i cannot post any code (and i think is not needed).
Thanks in advance!
Avoid mixing frames and applets, your working with competing paradigms. If you MUST use an applet, use something like a CardLayout or JTabbedPane to allow the user to switch between forms.
If you can, try using Java Web Start, which will allow you to start your application off the web, but have the same restrictions as that of any embedded GUI.
As to your problem, it sends like you are mixing the native peer for the JOptionPane. Make sure that the parent reference is correct (ie references the frame or child of the frame)
I work in HPC. I have both an applet and a Java client application that display information about jobs (jobID, jobname, userID, etc.) running on the cluster via information received from our TORQUE job scheduler.
Recently, I added buttons to sort the data by category by ascending or descending values. With this addition, where the user has the ability to force an update of the display by sorting the data (previously I had a timer that received new data from the server every 10 seconds and subsequently updated the display), I noticed a disparity in performance - the applet lagged significantly. Putting in timing code, I found that the application took an average of 0.05 seconds to setContentPane() whereas the applet took an average of 1.50 seconds to perform the same operation with the same code. This issue is the same whether the applet is being run in appletviewer or a browser.
I want to emphasize that virtually all of the code is the same. The only significant difference is that the JApplet makes setContentPane() (and other) calls on itself, whereas my application makes these calls on the JFrame (e.g. frame.setContentPane() ).
Curiously, the first call to setContentPane() for the applet returns in ~0.13 seconds. However, all subsequent calls require the previously noted time.
Any suggestions? I'd much rather have a functioning applet so I don't have to push the application on my user community.
Edit: JApplet's event handling is not the issue: performance regarding mouse movement and position reading as well as popup drawing on the glass pane is identical between the JApplet and the Java application.
Edit2: I just edited the JApplet code so a JFrame pops up with the application running inside and the performance matches that of the application! What is it with Applets? I've been reading about them for weeks and no one has shed light on this problem - It's almost exclusively "applets don't run in my firefox browser on my linux box" or "how do I turn my application into an applet." No one can tell me why the same GUI code that is literally identical will run ridiculously slow inside a JApplet. That is, why does setContentPane() have a 30x slowdown in a JApplet created from a JFrame???
The reason I'm running an applet is because i want it embedded in a web page, the pop-up JFrame is too intrusive. Thoughts?
Edit3: In continuing my diagnostics of this problem, I found that a call to setContentPane() by the JApplet spikes my CPU usage up to anywhere from 60-100%. This is not the case for the application's setContentPane() which will only jump from 0.1% to ~4%. What is causing all of the operational and performance-taxing overhead for the JApplet?
Refactor your application to use this hybrid approach. It offers two advantages:
You can more directly profile the overhead of disparate top-level containers.
You have more flexible deployment options using java-web-start, illustrated here.
Curiously, the first call to setContentPane() for the applet returns in ~0.13 seconds. However, .. Any suggestions?
In that first call, add a panel with a CardLayout. Never call setContentPane() again, but instead use the panel with card layout to 'add' anything more.
Unfortunately, Applets will run slower by comparison. A lot depends upon the browser's JVM and response to Applet requests. It's one of the reasons that they're used so infrequently.
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/
I have a program that uses a JFrame. I would like to make it so people could play my game from a website. Is there an easy way to turn JFrames into JApplets?
I have a program that uses a jFrame. I would like to make it so people could play my game from a website. ..
Launch the JFrame directly off a web site using Java Web Start. JWS offers many neat features, like auto-update & desktop integration (menu items, desktop shortcut).
..Is there an easy way to turn jFrames into jApplets?
When it comes to applets, nothing is easy.
It is always a matter of dealing with how different (versions of different) browsers, on different (versions of different) OS, using different (versions of different) Java plug-ins interact with each other. And that can often be summed up as 'poorly'.
I think the best way is to code your application to be contained within a JPanel. Then in the main method create the JFrame and adds that JPanel to it. Likewise, you can create a JApplet that gets created and just add the JPanel. This way your Swing application will be generally agnostic with regards to the top-level container.
You can simply create a JFrame from the applet. This JFrame then is a new OS window, and not still embedded in your browser.
Our program shows an example of this (of both popping up an external JFrame (or JDialog) and having components inside the applet, actually). (No source available, though.)
My project having a Jframe that showing some gui, the gui will represent a user or agent to move into the map. My Jframe will keep refreshing to make the user GUI moving on the map, and it have location to move with.
Now I will need to implement the GUI to show in others computer. If i successfully send the information and create a new user to show in the MAP GUI of the host by just a button, any idea how I show the entire map of the host?
I need to show the Jframe at host when user access. But i got no idea what kind of thing i need to use to keep synchronize and show it? If i not planing to use java applet, what others can perform this function?
Java RMI should be sufficient. However, when it comes to network programming, you have several choices within the Java EE libraries