Reputation: 749
How can i start a java swing application by clicking a button on a html page. Is it possible?
Upvotes: 2
Views: 22498
Reputation: 14458
What you are looking for is called Java Web Start.
Note that unless you have the application signed, it will run in restricted mode (similar to applets) and will not be able to access much in the way of local resources.
Update (9 years later)
Java Web Start is no longer included in Java 11 and onward. Offhand, I can't see an immediate, drop-in, replacement.
Upvotes: 3
Reputation: 569
Maybe you were refering to showing the applet after the user clicks the button. In that case, the solution may be to add your <object>
to a <div>
that has a css-property of visibility:hidden;
. Then create a HTML-button element that accesses the <DIV>
element and changes its visibility property, e.g.
<html><head>
<style>
div.visible {
visibility:visible;
}
div.hidden {
visibility:hidden;
}
</style>
</head><body>
<div id="applet" class="hidden">
<!-- Your object-code goes here -->
<object></object>
</div>
<!-- This button will show the applet -->
<input type="button" value="Show the applet"
onclick="javascript:document.getElementById('applet').className = 'visible';" />
</body></html>`
You will need to adapt it to your purposes, but it should show the basic idea.
Upvotes: 1
Reputation: 1218
You can use Swing libraries in an applet. Your applet must be a subclass of javax.swing.JApplet
.
Remember that you'll be submitted to the applet "sandbox" constraints.
Upvotes: 0
Reputation: 23443
You need applets, and your client needs to have jre installed for this to work.
Upvotes: 0
Reputation: 12080
You could run an Applet. It's basically an embedded java app. See tutorial here.
Upvotes: 0