• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

control cursor keys using java code

Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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;

return bytes;

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


this is another file....


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) {

public void run(){
try {

Connection connection =
// connection obtained
// 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

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

Operation putOperation = cs.put(hs);

OutputStream outputStream =
// file push complete



} catch (Exception e) {

"Don't believe every tiny ad you see on the internet. But this one is rock solid." - George Washington
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic