JavaApplet when you press a button/ click on image - java

Is it possible to run JavaApplet when you press a button , or when you click on the image on the webpage?
Maybe you guys can share any example, related html/jscript/jquery?
What is wrong with my code at this point?
<html>
<script>
function openApplet(){
var attributes = {codebase:'.',
code:'d.Applet',
archive:'Applet.jar',
WIDTH=500, HEIGHT=300} ;
}
</script>
<body>
<applet id="myapplet"
CODEBASE="."
ARCHIVE="Applet.jar"
CODE="d.Applet"
WIDTH=500 HEIGHT=300
style="visibility:hidden;"
>
</applet>
<input value="Applet_on_Click" onclick="openApplet()" type="button">
</body>
</html>
I'm just looking for very simple solution. Click on the image , applet shows up, click on the different image , another applet will show up. Or maybe these things can happen when we press a button too?
Update
Thank you slowpoison for the information!
But I'm missing something.
There is my original code now:
http://www.text-upload.com/read.php?id=360320&c=7544773
This is working just with pure html. But there is no action when you click on the button.
If I disable this row "style="visibility:hidden" , applet will show up without a click.
I wan't to show applet just after the button click. :(

You should add the applet tag to the document in the onclick handler.
var applet = document.createElement("applet");
// fill in various attributes for applet
// ...
// "install" the applet
document.getElementById("appletContainer").appendChild(applet);

Related

I have one requirement in which I need to print a web page(actually a jsp page created using struts 1.3 ) using brower's print option

I have one requirement in which I need to print a web page(actually a jsp page created using struts 1.3 ) using browser's print option in such a way that buttons which are there on that webpage should look little darker in print or in pdf(when we use save as pdf).
I had tried below code inside head tag:
<style>
#media print {
.light {color: #000 !important; }
}
</style>
I put the buttons inside a div and tried to apply .light class on that dive so that only during print or saving it as pdf buttons should be visible darker.
buttons code is as below (struts bean tag is used here):
<div class="light">
<bean:message key="button.internet.request.update" />
</div>
<% } %>
</html:submit>
<% } %>
so I added line no. 1 and 3 just for putting the button code inside a div and applied that .light class. But it didn't work.
Help me appling the css code in bean tag so that button gets printed darker on print page or visible darker in pdf.
Images for proper button and disturbed button I have attached. Proper here means before applying my code and disturbed one is for after applying my code which didn't work.

Removing close button and back button

Can someone tell me how can I disable the browser's close button and back button. i.e user can not see the browser's close button or back button or can not click on the close button or back button of the browser. If user clicks nothing should happen or it should be completly hidden from user.
Solution can be in java or javascript or win32 apis..
We use this technique in-house for opening a browser window on top of all other apps so the user can use in-house hosted forms/webapps etc. Please remember to offer a close button.
NB: This only works for IE:
<html xmlns="http://www.w3.org/1999/xhtml">
<script for="window" event="onload">
window.open('main.jsp',
'Your Name',
'width=800,height=600,resizable=0,status=0,toolbar=0');
<!-- Stops user from being able to press BackSpace -->
window.opener = window.top;
window.open('', '_self', '');
window.close();
</script>
</html>

JEditorPane doesn't want to show a button done in html (it shows in a browser)

I created a buttton in html and linked it to another html file, when i open the file with the button in a browser (tried IE and FFox) the button shows and works properly, however when i JEditorPane.setPage(the html file with the button) the only thing that shows is the name of the button with no actual clickable area or anything! Any ideas on how i can get the button to appear inside the pane?
Here's a pic of the button in the java frame(button is circled in red)
http://tinypic.com/r/fopswo/6
Here's a pic of the button in a browser(it's a button)
http://tinypic.com/r/2zjj71z/6
The code for the button
<font size = 12 face = "verdana" ><u> Creating An Account </u></font>
<span style="padding-left:360px"> </span>
<button onclick="window.location.href ='file:///F:/java 12/Isp/help file try/doc 2/test.html'">Back</button>
Thanks in Advance
Swing's HTML support is patchy - I think you have fallen in one of its holes. More info here:
Which HTML tags are supported in Swing components?

Button tag with Image while submit issue

I am using a
<button name="btn" value="Save"><img src="/image/save.png"/>Save</button>;
in my JSP page. when user lands on page, User is seeing that button and image on left to text of Save. but when the Form is submitted, in request.getParameterValues(), it is showing the value of button name:
(name=value as btn = img src="/image/save.png"/ Save)
and I am restrcting special character like < sign due to security concern. So I am expecting the request.getParameterValues for btn should return me "Save" and not complete <img tag.
Has anybody came across this issue? I dont want to add image using css.
Thanks in advance.
Nilesh
I'm not sure what you're asking but I'm guessing you're trying to display an image as a button?
Maybe try this:
<input type="image" src="/image/save.png" alt="Save" name="save" value="save"/>
then in your JSP or Servlet:
String save = request.getParameter("save");
If you are using IE, that's the expected result at least when I tested it on IE8, it sent the text between button tag (with the HTML tag stripped off) as value to the server. FF and Chrome both return the correct value set as the value attribute. Go test here.

How can I build a GWT Loading Dialog?

I have a page with a mix of HTML and GWT components. I'd like to not make the content viewable to the user until the content has completely loading (perhaps showing a simple loading dialog during the process).
What is the easiest way of achieving this?
Actually, the proposed way is to create a in your HTML and, after you load everything in your entry point, hide it:
<html>
...
<body>
...
<div id="loading">
<span id="loadingMsg">Loading ...</span>
</div>
...
</body>
</html>
public void onModuleLoad()
{
...
// Hide the "Loading" notification
RootPanel.get("loading").setVisible(false);
...
}
I use a PopupPanel with autohide set to false and modal set to true. Style it however you want, show it when you start loading your content, and hide it when you're finished.

Categories