I have a difficult dilemma. I implemented a java application using Netbeans while implementing it I used JFrame and now I want to convert it to JApplet so that it can essentially function as a web service. I have lots of classes and I tried Changing JFrame to Japplet as directed in some solutions on this site but then new errors arise because of that... for example ... exit on close method not defined ... pack not defined and so on.
Could anybody give me a better solution.
Thanks a lot
Any help appreciated
..exit on close method not defined ...
An applet is a guest in a web page and might share a JVM with other applets. Exiting the VM is like 'burning down the guest house'. Instead call showDocument(thanksForUsingUrl).
..pack not defined and so on.
validate()
Related
How would I be able to share my jframe or jpanel on a website without having to extend from a applet?
I want to be share my java gui program with other people without having them have java or download a zip file for them to run it.
I read online that using an applet is insecure and outdated. Other responses insisted in learning javascript. However, I want to stick with java. I also read about using Java Web Start but it is quite confusing for me. May someone give me a general gist or even a starting point for me to research on this topic.
I am working on a primitive online game client that I wrote as a Java Swing application. My problem is that potential users refuse to download and run any unfamiliar executable. I want my game to be reach as many people as possible and users fear that the executable might contain a virus. That is why I would like to embed the game client into my web page instead. How would you turn this Java executable code (liked below) into an applet?
Thus far I have a main which makes the initial connection to the game server...
https://dl.dropboxusercontent.com/u/214507961/Main.java
A Java Swing GUI that I made with the Netbeans GUI builder...
https://dl.dropboxusercontent.com/u/214507961/GUI.form
Object input/output streams connected to my game/web server...
https://dl.dropboxusercontent.com/u/214507961/Clients_Input.java
https://dl.dropboxusercontent.com/u/214507961/Clients_Output.java
And some buffered images for graphics...
https://dl.dropboxusercontent.com/u/214507961/Image_Repo.java
Note that in future development, I would like to replace much of the primitive looking 2D Swing GUI with content rendered with the Lightweight Java Game Library or some other higher-level video game graphics specific library to make the game look better.
Given that information, what is the best way to make this Java application into an embed-able (applet)? Describe your method and reasoning in such a way that even a college freshman could follow.
Note: Following the advice below, I have tried using WebStart, but I still get an intimidating warning:
Update:
I am in the process of refactoring my code so that the top level container is a JPanel.
I have tried making "GUI" extend JPanel and changing the "gamewindow" from a JFrame into a JPanel.
Modified Main:
https://dl.dropboxusercontent.com/u/214507961/Panel_Top_Level_Container/Main.java
Modified GUI:
https://dl.dropboxusercontent.com/u/214507961/Panel_Top_Level_Container/GUI.java
Despite the changes, Netbeans will not allow this program to run with Java Web Start.
When I enable WebStart and Build/Clean, Netbeans creates two files:
I then clicked Build/Clean and it generated two files:
master-application.jnlp
https://dl.dropboxusercontent.com/u/214507961/Panel_Top_Level_Container/master-application.jnlp
preview-application.html
https://dl.dropboxusercontent.com/u/214507961/Panel_Top_Level_Container/preview-application.html
but no JAR file.
Still working on it. AI moved the remainder of this question to:
Why can't I get Netbeans with Java Web Start enabled to work on my executable?
At this point I'm so tired of putting up with the security hassles and see little to no way to get around certification warnings without paying. I have decided that it would probably be better to just re-write the entire client in HTML5 and javascript.
The basic concept is to build your app (GUI basicly) without using applet specific technologies (like commmunication with web page via JS etc.) and with JPanel as a top level container insteed of of JFrame (Window would be accceptable too, as JApplet extends Window). If you do so, that you will be able to deploy the same code as standalone application and via JNLP as applet.
The digital signature could not be verified by a trusted source.
This is caused by the app. being 'self signed' by a digital certificate we generate ourselves using the SDK tools. Security was increased recently so that 'self signed' apps. get that scary warning. This has been discussed extensively across SO in recent times.
Try looking at the posts under applet+security for details.
Redo the client using HTML5 and Javascript so that you don't run into any prompts or security warnings.
I export a method to javascript window with JSNI, and I want to call this function from a applet in a GWT application..
I think that sometimes I have problems with Window context, so, I do some research and found the JSObject class.
I afraid with the package name (netscape.javascript). Is this class still be used? Is there another better way to do this?
I already tried to get applet context and show a new URl (with javascript:myFunction();), but, in some browsers it redirects the user to a new blank window...
What can I do to make it works best as possible?
Thanks in advance.
The netscape.javascript package is included with every Oracle JRE that I am aware of. Not entirely sure about the others.
I am making a simple examination app! The questions for various examinations will be present on the server. The clients will access them using RMI, and the UI for client side is being implemented in Applets! (that's according to the spec of the project!).
I want to have multiple applets for various stuff! I want to be able switch from one applet to other depending on the return value of the methods called on the server. I also want to be able to pass information if necessary!
Please tell me how can I do it!
An applet is equivalent to your workspace. You generally have one JApplet per application.
Now, you can have various JPanels within your JApplet. These JPanels can switch depending on the return value of the methods called on the server.
This Oracle tutorial should help you get started: How to Make Applets.
I'm writing a genome browser designed primarily to view the history of chromosomal rearrangements. Right now the project is a series of proof-of-concept demos written using Processing. At this point if I don't make any radical changes the final application will be a web applet with a gui built of swing components that open PApplets to actually show the rearrangements happening.
My question is: Should I give up on processing and switch over to pure Swing/AWT? This is my first big java project. I'm building in eclipse, but I can use netbeans as well. If I could embed PApplet objects inside a JFrame, for example, that would make my day.
processing.core.PApplet extends java.applet.Applet, so it should be possible to embed
a PApplet in a java.awt.Frame, as discussed in the article Applet ⇒ application: Hybrid Switch Hitters. See also, Mixing heavy and light components.
Addendum: From the API, "Processing runs in a Frame and not a JFrame. However, there's nothing to prevent you from embedding a PApplet into a JFrame," except for the limitations mentioned above.
Keep in mind that I know almost nothing about either Processing or your project, so I can only give you general advice.
The question that you should ask yourself before every major design change: what problem am I trying to solve by making this change? If the current architecture works, then you should keep it. If it's not working, then you should start by defining the specific things that are wrong with it (which I notice you didn't do).