<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/platform.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d1074803565153692547\x26blogName\x3dInnoLearning\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttps://innolearning.blogspot.com/search\x26blogLocale\x3den_US\x26v\x3d2\x26homepageUrl\x3dhttp://innolearning.blogspot.com/\x26vt\x3d2174717628392424844', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe", messageHandlersFilter: gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER, messageHandlers: { 'blogger-ping': function() {} } }); } }); </script>

InnoLearning

Calling javascript code from applet
Tuesday, November 27, 2007

Sometimes you may want your applet to interact with javascript.

Apply this code to your applet class.

private void alert(){
try{
getAppletContext().showDocument(
new URL("javascript:doAlert()"));
}catch (MalformedURLException ex) { }
}



When running this code you'll execute the javascript doAlert() placed in the htm file where the <applet> tag is located.


<script language="javascript" type="text/javascript">
function doAlert() {
//some code to be executed...
alert('doAlert() exevcuted!');
}
</script>


-OR-

Using the netscape.javascript package in your java code and the mayscript option in your applet tag. For this you need a Netscape JAR file name java40.jar to compile the javascript code.


import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import netscape.javascript.*;

public class jsobject extends Applet implements ActionListener
{
Button button;

public void init()
{
button = new Button("hello");
button.addActionListener(this);
add(button);
}
public void actionPerformed(ActionEvent event)
{
JSObject obj = JSObject.getWindow(this);
obj.call("hello", null);
}
}



Regards,
Manesh Koovappillil

Labels: , , , ,

posted by MIGHTYMAK @ 2:05 AM, ,




Opening Notepad (or any other external application) with JAVA
Wednesday, November 21, 2007

public class test {
public static void main(String args[])
{
System.out.println("\nSuccess");
Runtime r= Runtime.getRuntime();
Process p=null;
try {
p=r.exec("notepad.exe");
}
catch(Exception e)
{
System.out.println(e);
}
}
}

Labels:

posted by MIGHTYMAK @ 7:52 AM, ,




Nth highest Retrieval
Sunday, November 4, 2007

Consider a schema EMPLOYEE(name, salary). Now I want to find the employee name having nth highest salary.

For example "Find the name of the employee having 3rd highest salary?"

select salary
from (select rownum rn,b.salary from ( select unique salary from employee a order by salary desc) b)
where rn=N

-- OR --

[using aggregate function (min)]



select min(e.salary)
from(select salary from employee order by salary desc) e
where rownum <= N

Labels: , ,

posted by MIGHTYMAK @ 5:25 AM, ,