I created a Java applet supposed to be used in an applet as applets should.
For some reason, all browsers (chrome, firefox, IE) cut it.
I tried using the repaint() and invalidate() methods. I didn't help...
But, interestingly, when I scroll the browser up or down (even a tiny scroll), it immediately fixes. Also, when I use showOptionDialog(Component, String) method, if fixes after the user clicks the OK button on the dialog. It fixes only when the component inputted is the applet itself.
I don't understand why it crops, or how to fix it.
The HTML calling the applet it is very simple. Here is an example of a short piece of HTML code which causes the problem:
<html>
<head>
<title>nispahit</title>
</head>
<body>
<center>
<APPLET CODE="Applet/AppletMain.class" archive="nnis.jar, log4j-1.2.16.jar" WIDTH=800 HEIGHT=600>
<param name="userName" value="http://www.nispahit.com/images/shalom.jpg">
<param name="ColorsContrast" value="241026555"/>
<param name="param2" value="14">
<param name="param3" value="2">
<param name="param3" value="2">
</APPLET>
</center>
</body>
</html>
A solution or workaround will help very much. Any insight would also be helpful.
Thanks.
The cropping happens outside of the applet. There is some block element around the applet (usually a <div>) which is too small to contain the whole applet.
Try to add a div with a red background around the applet so you can see quickly which part is rendered by the browser and which comes from the applet.
Related
I created a custom loader for my Java applet :
Html Code:
<applet [...]
<PARAM name="image" value="pmap_loader.gif"/>
<PARAM name="boxborder" value="false"/>
<PARAM name="centerimage" value="true"/>
<\applet>
This works fine, but the gif is going crazy. The loading bar fills itself 1000x per second, while as you can see, the gif has been created properly : http://i.imgur.com/MQEof.gif
Does someone have an idea how to fix this? I guess the image is constantly refreshing itself or something like that, but I have no idea how I could fix this.
Thanks for the help!
I have a simple applet for psychological experiment, I use pxLab libraries ( http://www.pxlab.de/ ).
On this web page ( http://cogsci.fmph.uniba.sk/~stachova/exp/experiment.php ), there should be a start button for the applet and (tried on several computers) there is a button and it works.
However, some of my friends don't see the button when they load the page, and I have teamviewed one of their computers and there really is nothing displayed, where the button should be. Have you any idea, what may be the problem?
Here is how I call the applet:
<APPLET
CODEBASE="."
CODE="ExRunButton.class"
ARCHIVE="exrunbutton.jar, pxlabrt.jar"
ALT="Start design file experiment.pxd"
WIDTH=800
HEIGHT=60
MAYSCRIPT=true>
<PARAM NAME="CommandLine" VALUE="-S2">
<PARAM NAME="DesignFile" VALUE="experimentB.pxd">
<PARAM NAME="DesignFile" VALUE="experimentB.pxd">
<PARAM NAME="StartButtonLabel" VALUE="Začni experiment">
</APPLET>
When calling an applet id from JS giving Object doesn't support this property or method error.
Please check the code...
<!--[if !IE]> Firefox and others will use outer object -->
<object
classid = "java:com.mypack.myclass.ABCClass.class"
type = "application/x-java-applet"
height = "200"
width = "480"
id = "myappletId">
<!-- Konqueror browser needs the following param -->
<param name="cache_archive" value="a.jar, b.jar, c.jar" />
<param name="codebase" value="applets/" />
<param name="OnMouseLeftClickJS" value="showModal()">
<!--<![endif]-->
<!-- MSIE (Microsoft Internet Explorer) will use inner object -->
<object
classid = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
codebase = "http://java.sun.com/update/1.5.0/jinstall-1_5_0-windows-i586.cab"
height = "200"
width = "480"
id = "myappletId">
<param name="code" value="com.mypack.myclass.ABCClass" />
<param name="cache_archive" value="a.jar, b.jar, c.jar" />
<param name="OnMouseLeftClickJS" value="showModal()">
<param name="codebase" value="applets/" />
<strong>No Java Support</strong>
</object>
<!--[if !IE]> close outer object -->
</object>
<!--<![endif]-->
Now, in my showModal() js function I have,
var myId = document.getElementById("myappletId"); //At this point I am getting the object data.
I perform some operations in my modal window which is a jquery modal window and I have a button in it. When I click on that I am calling a function say xyz().
function xyz() {
var myId = document.getElementById("myappletId");
//At this point myId is getting empty.
}
This is happening in only IE Browser. I tested in IE8.
Works good in Firefox and chrome.
I am not navigating my page and on view source I can see my object tag.
Please help me out.
Thanks in advance...
In your comments you have
<!-- MSIE (Microsoft Internet Explorer) will use inner object -->
How about using document.getElementById('myappletId').getElementById('innerApplet') ?
It would be great idea to use unique id for inner applet, maybe then your solution would work.
Thanks for your effort guys, the mistake is in my code. When I open a modal window making the object tag visibility hidden in the back. Even I am make it visible after closing the modal window, This IE is not identifying it. Weird but true...
I learned how to call a java method from within a javascript code on the page when the applet is loaded with the applet tag that is something like this:
<applet name="myapplet" code="MyJavaApplet.class" width="480" height="432">
</applet>
<script>
(function() {
document.myapplet.myMethod();
})();
</script>
That works!
However applet tag is deprecated and the following does loads the applet but doesn't call the method:
<object name="myapplet" type="application/x-java-applet" width="480" height="432">
<param name="code" value="MyJavaApplet.class" />
</object>
<script>
(function() {
document.myapplet.myMethod();
})();
</script>
The code I have is not exactly that but is very similar.
I tried it on Opera and Chrome.
Is this a wrong implementation of the object class or I'm just not doing it right.
I don't have experience with javascript so I'm really in doubt here.
EDIT: Thanks for the quick replies.
It was a typo somewhere, I checked that document.myapplet was returning correctly through the console on dragonfly.
It worked when I wrote the page again.
I put an example here which prints on System.out so you'll need to open the Java console to see it working through both applet and object.
I have a span tag as parent to an object tag that loads a Java class. The span tag has style display:none. When a reference to the object tag is retrieved in Javascript and a method of this object tag is called, it fails.
But, if the span tag does not have display:none set OR visibility:hidden, then it works.
Why is this?
<span style='display:none'>
<object type="application/x-java-applet" width="100" height="100" name="my_class" id="my_class">
<param name="codebase" value="http://www.whatever.com/class">
<param name="code" value="myclass.class">
<param name="mayscript" value="yes">
<param name="scriptable" value="true">
</object>
</span>
This is basic styles (CSS), a hidden object is still included in the page, while an element with display:none is not even included.
Solution:
Make the applet around 10x10 pixels in size
Put it in some innocuous part of the web page (e.g. at the end)
Use visibility:hidden to hide it from view. Note that is visibility, not display!
Larry.
The reason is that when using 'display:none' browser renders the page as though the element was not there at all. Although you can get the referrence to the 'object' element in DOM, but object itself hasn't been created yet. On the other hand 'visibility:hidden' only hides the element, but it still takes up space and layout.
The best solution to not break page layout is to make your element absolutely positioned and take it in some place outside the user sight (e.g. left:-1000px)