wood burning stoves 2.0*
The moose likes Java in General and the fly likes control cursor keys using java code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "control cursor keys using java code" Watch "control cursor keys using java code" New topic
Author

control cursor keys using java code

simran gaur
Greenhorn

Joined: Mar 10, 2009
Posts: 7
hi....i am simran...i am working on a project"BLUETOOTH REMOTE CONTROL" n i am having a problem...
actually wat i want to do is ,i wannna control cursor using ma mobile's joy stick...like if i press left of my mobile's joystick,then cursor should move to the left and so on.....
so for that what can i do is i can pass command from my mobile to OS to activate some program which can handle cursor keys....
so neone have any idea how to do it???


[Nitesh: Removed bold font.]
simran gaur
Greenhorn

Joined: Mar 10, 2009
Posts: 7
guys ...what happened ....no reply......ok i am having another problem regarding my project...i am tryomg to send a file from my PC to my mobile phone.wen i run the following code,a message is displayed on my phone that "ACCEPT CONNECTION FROM [PCNAME]".but wen i accept the connection ,it gets disconnected...the two files are.........


send.java file

import java.io.*;
import java.io.File;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.IOException;

public class send extends Thread
{
String connection;

public byte[] getBytesFromFile(String file) throws IOException {

InputStream is = new FileInputStream(file);
System.out.println("\nDEBUG: FileInputStream is " + file);

// Get the size of the file
long length = file.length();
System.out.println("DEBUG: Length of " + file + " is " + length + "\n");

if (length > Integer.MAX_VALUE) {
System.out.println("File is too large to process");
return null;
}

// Create the byte array to hold the data
byte[] bytes = new byte[(int)length];

// Read in the bytes
int offset = 0;
int numRead = 0;
while ( (offset < bytes.length)
&&
( (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) ) {

offset += numRead;

}
is.close();
return bytes;
}

public static void main(String args[])
{
try{
send obj=new send();
byte[] filebytes=obj.getBytesFromFile("C:/Users/Sarbjit/Pictures/21.jpg");
Thread t=new Thread(new SendFileTask(filebytes,"abc"));
t.start();
}
catch(Exception e){}

}}



this is another file....



SendFileTask.java

import java.io.OutputStream;
import javax.microedition.io.Connection;
import javax.microedition.io.Connector;
import javax.obex.ClientSession;
import javax.obex.HeaderSet;
import javax.obex.Operation;


public class SendFileTask implements Runnable {

private String url;
private byte[] file;
private String filename;

public SendFileTask(byte[] file, String filename) {

this.file=file;
this.filename=filename;
}
public void run(){
try {

Connection connection =
Connector.open("btspp://0018427450CD:1;authenticate=false;encrypt=false;master=false");
// connection obtained
System.out.println(connection);
// now, let’s create a session
// and a headerset objects
ClientSession cs =
(ClientSession) connection;
HeaderSet hs = cs.createHeaderSet();

// now let’s send the connect header
cs.connect(hs);

hs.setHeader(HeaderSet.NAME, filename);
// content-type could be
// checked from a filename
hs.setHeader(HeaderSet.TYPE, "image/jpeg");
hs.setHeader(
HeaderSet.LENGTH,
new Long(file.length));

Operation putOperation = cs.put(hs);

OutputStream outputStream =
putOperation.openOutputStream();
outputStream.write(file);
// file push complete

outputStream.close();
putOperation.close();

cs.disconnect(null);

connection.close();
} catch (Exception e) {
e.printStackTrace();
}
}


}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: control cursor keys using java code
 
Similar Threads
automatic scrolling of JTextField
IntelliJ IDEA arrow navigation does not work with numeric keypad arrow keys
samsung mobile
controlling the buttons functions in a page using keyboard itself
Problem while trapping the navigation keys