Problem with using JNI with AWT events
arundeep Singh <arundeep78-/[email protected]>
| Newsgroups | gmane.user-groups.linux.delhi.devel |
|---|---|
| Message-ID | <[email protected]> |
well the 1st mail was send accidently that contains lot of comments
also
plese read this i had remove that comments from it
i am working in Fedora core . i a trying to run the following code,
which uses some JNI functions of class ParallelTest
Problem is that all the code works, but when the native code is called
in the key event functions, then i got the following exception
Local Time = Sun Apr 11 12:28:28 2004
Elapsed Time = 6
#
# The exception above was detected in native code outside the VM
#
# Java VM: Java HotSpot(TM) Client VM (1.4.2-b28 mixed mode)
#
# An error report file has been saved as hs_err_pid22771.log.
# Please refer to the file for further information.
#
Aborted
The code in which the following error occurs is
public class ParallelTest1 extends JFrame implements KeyListener{
private static final int[] stepData={1,2,4,8};
private int position=0;
private ParallelTest test=null;
public ParallelTest1(){
addKeyListener(this);
int temp;
//System.loadLibrary("CJParallelInterface");
test=new ParallelTest();
temp=test.setPermissions(ParallelPortUtil.LPTDataPort,3,1);
test.setModeParallel(ParallelPortUtil.WRITE_MODE,ParallelPortUtil.LPTControlPort);
System.out.println("value returned by ioperm function = " +
Integer.toString(temp));
if(temp!=0){
System.out.println("Error : No permision granted for ports");
System.exit(0);
}
try{
test.sendParallel(0,ParallelPortUtil.LPTDataPort);
Thread.sleep(300);
test.sendParallel(1,ParallelPortUtil.LPTDataPort);
Thread.sleep(300);
test.sendParallel(2,ParallelPortUtil.LPTDataPort);
}
catch(InterruptedException e){
System.out.println("Error");
}
//super.show();
}
public void keyPressed(KeyEvent event){
int keyCode=event.getKeyCode();
if(keyCode==KeyEvent.VK_LEFT){
test.sendParallel(stepData[position--],ParallelPortUtil.LPTDataPort);
position=(position+4)%4;
System.out.println(" Key Pressed is left and outValue = "
+stepData[position] );
}
if(keyCode==KeyEvent.VK_RIGHT){
test.sendParallel(stepData[position++],ParallelPortUtil.LPTDataPort);
position=position%4;
System.out.println("Key Pressed is right and outValue = "+
stepData[position]);
}
if(keyCode==KeyEvent.VK_END){
System.exit(0);
}
}
public void keyReleased(KeyEvent event){
}
public void keyTyped(KeyEvent event){
}
}
when the constructor gets executed then test.sendParallel is working
fine, but when the same code runs under key event then it exits. why??
please help if anyone could, i hope there will be number of.
i send all my thanks in advance .
=====
Arundeep Singh,
M.Tech (IS), IIIT Allahabad,
U.P, India.
ph: 09415262466, 09417066713
http://www.i-cognition.com
Don't take life seriously, as you can't come out of it alive.
__________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th
http://taxes.yahoo.com/filing.html