Keylistener in MIDP?

I am writing a MIDlet for cell phones/Blackberries. I want to be able to intercept the escape button (specifically on the Blackberry) and prompt the user to save/don't save/cancel. Unfortunately, there is no Keylistener in MIDP as far as I know. There are Blackberry specific APIs that fulfill this need, but I don't want to make the MIDlet specific to a Blackberry, so I can't use them.
Has anyone found a way to implement a Keylistener in MIDP? I was reading something about kAWT that sounded possible, but I really don't know much about it. Can anyone help me? Is there an easy way to write my own Keylistener?
Any help would be greatly appreciated.

The only way to "implement a KeyListener" in MIDP 1.0, is to have a Canvas subclass as the active displayable, and implement the method keyPressed() (in the Canvas subclass). Otherwise you're stuck with the high level UI with all it's querks...
But anyway, to capture the escape button you'll need to use some platform specific code, since there is no keycode defined for special keys in MIDP 1.0.
shmoove

Similar Messages

  • MIDP 1.0: Image to byte[] or serializing...

    I would like to extract pixels from a MIDP 1.0 "Image" object through any means possible. I am currently under the impression that "Image.toString()" would just do something lame, like giving me a string like "Image@1234" that identifies the class and the instance -- which could in principle be used for mere instance comparison. Anyhow, if I could serialize an Image object to a file, and then read back the file in to a byte array, then I would be delighted. I want to stress that I don't care how convoluted the approach may be, as long as it is in plain-vanilla J2ME Java code for MIDP 1.0 and is capable of working on an actual device (as opposed to an emulator). Can I cast the Image to Object, and then somehow convert to byte[]? I don't care if I have to get down and dirty, hacking the platform-specific bytes of the full Object manifestation of the Image. Anyhow, I want to make it clear that any hard core hack, doing all kinds of things that would break on different VMs, etc, is totally fine. Messy is fine. I just want access to the binary data of the entire Image object, or, even better (but only icing on the proverbial cake), access to pixel data. If I can get the byte[] representation of Image, then I can hack the rest myself.

    My goal was do a capture of the way things actually rendered on a device, kind of like a "screen capture", only a little more indirect (since I don't think there is a way to get access to the pixels of the LCD). What I have to do is render to an off-screen Image object and then retrieve pixel data from it using the platform-dependent getPixels() supplied by Motorola. You're going to think I'm crazy, but I send this image data to a web server via POSTs, which get collected and stored as a single file on my web server. Voila! A screen capture of how things actually render to an Image object on an actual device.
    Everything works, except...
    I can't get the Motorola "getPixels()" method to work in their emulator, so I'm worried
    that it won't work on my Motorola T720 (something I haven't actually tried, though).
    I get a "Uncaught Exception: java/lang/Error" message from the T720 emulator
    when I run one of the Motorola demos (built using their scripts) when I add the
    following code to the Canvas paint() method:
    if (0 == iDidThis) {  iDidThis = 1;
    try
    {  javax.microedition.lcdui.Image   temp = Image.createImage( 120, 160 );
    int [] rgbData = new int [120*160];
    com.motorola.game.ImageUtil.getPixels ( temp, 0, 0, 1, 1, rgbData );
    System.out.println("Captured Data");
    catch( java.lang.ArrayIndexOutOfBoundsException e )
    {  e.printStackTrace();   } }
    This code runs only once, when the paint() method of the Canvas object is called for
    the first time. Okay, I get the error message, but the "Bounce" demo (to which I added
    the code block above) goes on to run just fine. (NOTE: The message "Captured Data"
    is NOT printed in this scenario.)
    I don't understand why the public static "com.motorola.game.ImageUtil.getPixels()"
    method causes the "java/lang/Error" exception. (By the way, if I comment out the
    call to this method, the code totally works without error, and I see the printed
    statement "Captured Data" in the command window associated with the emulator.)
    If my getPixels() call resulted in bad array access, then I would get the
    java.lang.ArrayIndexOutOfBoundsException exception. But apparently this is
    not what is going on.
    I am really rusty with J2ME, so I don't even know the meaning of "java/lang/Error".
    I assume it is different from a "class not found" exception, but I suspect that my
    problem has to do with a fault in the emulator trying to execute the code for the
    "com.motorola.game.ImageUtil.getPixels()" method.
    My Motorola emulator (v7.5) is from around December, 2002, so it may be really old, and
    maybe this was a known issue at that time that has since been resolved. I'm just never
    tried to use platform-specific J2ME APIs before, so I don't know if what I am observing
    is my fault, or is an emulator issue.
    I'd be grateful for any ideas about what might be going wrong and for ideas about
    possible solutions.

  • Problem using KeyListener in a JFrame

    Let's see if anyone can help me:
    I'm programming a Maze game, so I use a JFrame called Window, who extends JFrame and implements ActionListener, KeyListener. Thw thing is that the clase Maze is a JPanel, so I add it to my Frame and add the KeyListener to both, the Maze and the Window, but still nothing seems to happen.
    I've tried to remove the KeyListener from both separately, but still doesn't work...
    Any suggestions???

    This is the code for my Window.java file. May be someone can see the error...
    package maze;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class Window extends JFrame implements ActionListener, KeyListener {
      private Maze maze;
      private JButton crear = new JButton("New");
      public Window(int size, String s) {
        super("3D Maze");
        boolean b = true;
        if (s.equalsIgnoreCase("-n"))
          b = false;
        else if (s.equalsIgnoreCase("-v"))
          b = true;
        Container c = getContentPane();
        c.setLayout(new BorderLayout());
        maze = new Maze(size,size,b);
        crear.addActionListener(this);
        addKeyListener(this);
        maze.addKeyListener(this);
        c.add(crear,BorderLayout.NORTH);
        c.add(maze,BorderLayout.CENTER);
        setSize(600,650);
        show();
      public void keyPressed(KeyEvent e) {
        if (e.getKeyCode() == e.VK_UP || e.getKeyCode() == e.VK_W)
          maze.walk();
        else if (e.getKeyCode() == e.VK_DOWN || e.getKeyCode() == e.VK_S)
          maze.back();
        else if (e.getKeyCode() == e.VK_LEFT || e.getKeyCode() == e.VK_A)
          maze.turnLeft();
        else if (e.getKeyCode() == e.VK_RIGHT || e.getKeyCode() == e.VK_D)
          maze.turnRight();
        else if (e.getKeyCode() == e.VK_V)
          maze.alternaMostrarCreacion();
        else if (e.getKeyCode() == e.VK_M)
          maze.switchMap();
      public void keyTyped(KeyEvent e) {}
      public void keyReleased(KeyEvent e) {
      public void actionPerformed(ActionEvent e) {
        maze.constructMaze();
      public static void main(String[] args) {
        int i = 30;
        String s = "-v";
        if (args.length != 0) {
          try {
            i = Integer.parseInt(args[0]);
            if (!(i >= 15 && i <= 50))
              i = 30;
            s = args[1];
          catch(Exception e) {}
        Window w = new Window(i,s);
        w.addWindowListener(
          new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              ImageIcon im = new ImageIcon("./Logo.gif");
              String s = "";
              s += "3D MAZE\n\n";
              s += "Creator: Allan Marin\n";
              s += "http://metallan.topcities.com\n\n";
              s += ""+((char)(169))+" 2002";
              JOptionPane.showMessageDialog(null,s,"About...",JOptionPane.PLAIN_MESSAGE,im);
              System.exit(0);
    }

  • Trouble with focus, swing & keyListener

    can anybody out there help me with this problem, I got stuck with:
    I create a JDialog in a JFrame & would like to add Keylistener to the JDialog as soon as it opens..........but the it doesn't seem to be working....

    Oops! As bbhangale pointed out, my previous post is incorrect. It should read as follows:
    dialog.getRootPane().getInputMap...
    dialog.getRootPane().getActionMap...Actually, I've created MyDialog, an abstract sub-class of JDialog. In it, I over-ride the createRootPane() method and delcare the abstract onDialogClose() method. Here's what that looks like:
    public abstract class MyDialog extends JDialog
       // Implement MyDialog wrappers for all the JDialog constructors
       public MyDialog()
          super();
        * Overriding this method to register an action so the 'Esc' key will dismiss
        * the dialog.
        * @return a <code>JRootPane</code> with the appropiate action registered
       protected JRootPane createRootPane()
          JRootPane rootPane = new JRootPane();
          rootPane.getInputMap( JComponent.WHEN_IN_FOCUSED_WINDOW ).
             put( KeyStroke.getKeyStroke( KeyEvent.VK_ESCAPE, 0 ), "escPressed" );
          rootPane.getActionMap().
             put( "escPressed", new AbstractAction( "escPressed" )
             public void actionPerformed( ActionEvent actionEvent )
                onDialogClose();
          return rootPane;
        * This method gets called when the user attemps to close the JDialog via the
        * 'Esc' key.  It is up to the sub-class to implement this method and handle
        * the situation appropriately.
       protected abstract void onDialogClose();
    }Then, anytime I need a dialog, I sub-class MyDialog and implement onDialogClose() to do whatever I want it to do when the user presses 'Esc'.
    I swear I've been using it for quite some time now and it works beautifully!
    Jamie

  • Questions on MIDP Security

    Hi all,
    I've a few questions on MIDP security to seek help:
    1) Suppose I have a midlet to store confidential details on the mobile phone, if it doesn't make any connections to the internet, would anyone be able to retrieve the information I'd on the RMS?
    2) Again, assuming no internet connection is made by the midlet. Suppose I've a login screen that prompts for a password & uses MD5. Can anyone crack it?
    3) Is it possible to retrieve the midlet from the mobile phone itself onto a desktop?
    Thanks for the help!

    Yes, it is possible to retrieve the data stored in
    RMS.
    Just try it on a Nokia S60 phone:
    1. download and install FExplorer (free file
    explorer)
    2. go to: c:\system\midp\<vendor>\untrusted\<midlet
    name>\<?????> folder
    3. select rms.db
    3. choose options/send/SMS|MMS|e-mail|bluetooth|irda
    Of course cracking is a harder work...does this means that I can follow your step 1 & goto whichever midlet that I'm interested in & send the JAR/JAD file via SMS/MMS/Email/BlueTooth/IRDA?

  • KeyListener..for beginners..please help me

    hi, im new to java..i think that this thing is simple to you guys..im trying to make a program where there is a ball bouncing around the screen..theres 3 walls one on the left one on the right and the other on top..there should be a moving catcher at the bottom..which should be controlled by the keyboard..
    i already made the catcher..my only problem is..i dont know how to make it move..
    by the way..i'm using threading..
    it would be nice if you can post even a simple example of threading with keylistener even just left and right so i would know how to apply it..
    i hope that someone there would help beginners like me, it would really be a big help..
    thank you very much!
    -dennis

    Hi Madhuama, I'll try to give you a hand with this. First off, what OS is running on your notebook, what game are you attempting to play, and how is it not working? Is it not installing?
    Thanks,
    Fenian Frank
    I work on behalf of HP

  • How to change the midp version in ktoolbar of wireless toolkit 2.1

    Hi
    How to change the version of midp in ktoolbar of wireless tool kit 2.1
    though i tried to change the platform by selecting midp1.0 from settings
    dialog box iam geeting alert:BadVersion Error
    and the application is terminated abruptly
    do i need to change any configuration files
    please suggest me
    as it is very urgent

    The version of Java inside the database? If so - Not recommended at all ... the environment is NOT the same as your grandfathers JRE and there are a few noteworthy conditions.
    How much of the Oracle Java Developer's Guide have you reviewed? http://www.oracle.com/pls/db102/to_toc?pathname=java.102%2Fb14187%2Ftoc.htm&remark=portal+%28Books%29

  • How to add a KeyListener to a JInternalFrame

    1). I have Main Window which is an Application window and has a menu. When I click on a menu option,
    a user interface which is a JInternalFrame type, with JTextFields in it, is loaded.
    2). In the first JTextField(e.g. Employee Number), I have a KeyListener added to the JInternalFrame.
    3). When I enter an Employee number in the JTextField and press the Key F10, I have to fetch the details about the Employee
    (his first name, middle name, last name etc.) from the database and display these details in the corresponding
    JTextFields in the user interface.
    PROBLEM:
    I am able to add a KeyListener to the JInternalFrame but it does not work the way I need it to.
    The moment F10 key is pressed, the JInternalFrame looses focus, and the focus goes to the Main Window and does not execute
    the code for the keyPressed event that is there in the listener.
    How do I overcome this issue??
    The code that I am using is below
    public class TD {
    public void invoke(){
    cFrame = new JInternalFrame("TD Form",
    false, //resizable
    true, //closable
    true, //maximizable
    true);//iconifiable
    // More code here..................
    //Destroy the TD Window.
    cFrame.addInternalFrameListener(new InternalFrameAdapter() {
         public void internalFrameClosing(InternalFrameEvent evt){
                   cancelSteps();
    }); // end of InternalFrameListener.
    cFrame.addKeyListener(new KeyTD(this)); // Adding the KeyListener here to the JInternalFrame
    cFrame.setVisible(true);
    cFrame.setSize(800,450);
    cFrame.setLocation(10,10);
    } // end of the constructor.
    // Inner class that implements the KeyListener
    class KeyTD implements KeyListener {
    private int msg =JOptionPane.INFORMATION_MESSAGE;
    private String title = "KeyPress Event Message";
    Container cornbut;
    TD objTD;
    private int UTNum;
    public KeyTD(TD objTD){
              this.objTD = objTD;
    public void keyPressed(KeyEvent ke){
    int key1 = ke.getKeyCode();
    switch(key1){
    case KeyEvent.VK_F9:
    tD_F9();
    break;
    case KeyEvent.VK_F10:
    UTNum = getNum(); // Reads the content of the JTextField and gets the Integer value
    if (UTNum > 0){
                        tD_F10();
    }else{
    JOptionPane.showMessageDialog(cornbut," Please enter the Number. ",title,msg);
    break;
    }//end of keyPressed method
    public void keyReleased(KeyEvent ke){
    public void keyTyped(KeyEvent ke){
    public void tD_F9(){
    //sets focus to the Text Field where the key listener has been added
    }//end of tD_F9 method
    public void tD_F10(){
    String str = String.valueOf(UTNum);
    Objdbdef.fetchTaskDefiner(str,"", "","" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" );
    if(//there are records in the database then){                       
    // If there are records matching the number from the JTextField the display statements are here.........
    }else{
    JOptionPane.showMessageDialog(cornbut,"There are no records found for the specified criteria.",title,msg);
    }//end of td_F10 method
    }// end of KeyTD class

    As a rule of thumb, I never use KeyListeners, unless you want to listen to many different key strokes.
    Instead, use ActionMap/InputMap. You can attach an action to, say your desktop, that
    is activated when F1 is pressed WHEN_ANCESTOR_OF_FOCUSED_COMPONENT or
    WHEN_IN_FOCUSED_WINDOW

  • A sort of KeyListener without a GUI Component?

    a sort of KeyListener without a GUI Component? ( or any trick that will do)?
    please be patient with my question
    I can't express myself very well but it's very important.
    Please help me I need an example how to implement
    a way to detect some combination of keystrokes in java without
    any GUI ( without AWT or Swing frames ...)
    just the console (DOS or Linux shell window) or with a minimzed
    java frame (awt or swing...) you know, MINIMIZED= not in focus.
    in other words if the user press ctrl + alt +shift ...or some
    other combination... ANYTIME ,and the java program is running in the
    background, is there a way to detect that,
    ... my problem if I use a frame (AWT or SWING) the windows must
    be in focus and NOT MINIMIZED..
    if I use
    someObject.addKeylistener(someComponent);
    then the "someComponent" must be in focus, am I right?
    What I'm coding is a program that if you highlight ANY text in
    ANY OS window, a java window (frame) should pop up and match the
    selected text in a dictionary file and brings me the meaning
    ( or a person's phone number , or
    a book author ...etc.)
    MY CHALLENGE IS WITHOUT PRESSING (Ctrl+C) to copy and paste
    ...etc. and WITHOUT MONITORING THE OS's CLIPBOARD ...I just want to
    have the feature that the user simply highlight a text in ANY
    window anywhere then press Ctrl+shift or some other combination,
    then MY JAVA PROGRAM IS TRIGGERED and it should EMULATE SOME
    KEYSTROKES OF Ctrl+C and then paste the clipboard
    somewhere in my program...with all that AUTOMATION BEING in the background.
    remember that my whole program ALL THE TIME MUST BE MINIMIZED AND
    NOT IN FOCUS
    or just running in the background (using javaw)..
    is there any trick ? pleeeeeeze!!!
    i'm not trying to write a sort of the spying so-called "key-logger"
    purely in java but it's a very similar challenge.
    please reply if you have questions
    I you could please answer me , then guys this would be very
    valuable technique that I need urgently. Thanks!

    DO NOT CROSS POST especially since this has nothing to do with game development at all. I can understand if it was in Java programming and New to Java but even then pick a forum and post it to that one and that one only.

  • KeyListener anomoly: delay in firing KeyEvent

    Hello,
    I've implemented a KeyListener that's exhibiting some anomolies. I'm using it in a video game. I'm using it to control the main character's movement. It determines his movement based on strokes of the arrow keys. I've programmed it so that only one key has an effect at a time. That is, so long as (say) the up arrow was pressed first and held down, the character moves up, and no other key has an effect. Other keys only have an effect if the up arrow is released.
    The anomoly comes about when two keys are held down (only one of them determining the movement of the character - which ever was first), and then the first is released. When the first is released (but the second is still held down), the character freezes for about a second, and only after that second does he move in the direction of the second key which is still held down.
    It's this second-long delay which is the anomoly. I'm guessing it results from the fact that the KeyEvent is not being fired constantly or immediately after the release of the first key. Even though the second key is held down, it takes a second to fire the KeyEvent after the first key is released (though it seems to fire immediately upon depressing the key).
    I'm wondering if there's a way to get rid of the delay or at least shorten it so it's not noticeable.
    Here's my KeyListener code:
    import java.awt.event.*;
    public class InputProcessor implements KeyListener {
        // key codes
        public static final int      LEFT  = 37;
        public static final int      UP    = 38;
        public static final int      RIGHT = 39;
        public static final int      DOWN  = 40;
        private boolean      left_arrow_down  = false;
        private boolean      right_arrow_down = false;
        private boolean      up_arrow_down    = false;
        private boolean      down_arrow_down  = false;
        // flag to mark when a key (any key) is pressed
        private boolean     key_pressed      = false;
        public InputProcessor() {}
        public void keyPressed (KeyEvent KE) {
         if (key_pressed) return; // all other keys disabled if one key is down
         switch (KE.getKeyCode()) {
             case LEFT:
              left_arrow_down true;
              key_pressed = true;
              break;
             case RIGHT:
              right_arrow_down = true;
              key_pressed = true;
              break;
             case UP:
              up_arrow_down = true;
              key_pressed = true;
              break;
             case DOWN:
              down_arrow_down = true;
              key_pressed = true;
              break;
        public void keyReleased (KeyEvent KE) {
         switch (KE.getKeyCode()) {
             case LEFT:
              left_arrow_down = false;
              break;
             case RIGHT:
              right_arrow_down = false;
              break;
             case UP:
              up_arrow_down = false;
              break;
             case DOWN:
              down_arrow_down = false;
              break;
         // only set key_pressed to false if all keys have been released
         if (!left_arrow_down &&
           !right_arrow_down &&
           !up_arrow_down &&
           !down_arrow_down)
             key_pressed = false;
        public void keyTyped (KeyEvent KE) {}
        public boolean isLeftArrowDown()  {return left_arrow_down;}
        public boolean isUpArrowDown()    {return up_arrow_down;}
        public boolean isRightArrowDown() {return right_arrow_down;}
        public boolean isDownArrowDown()  {return down_arrow_down;}
        public static void main (String[] args) {
         InputProcessor IP = new InputProcessor();
    }I'm wondering if there might be a command I can execute at the end of the keyReleased() method, something like this:
        public void keyReleased (KeyEvent KE) {
         switch (KE.getKeyCode()) {
             case LEFT:
              left_arrow_down = false;
              break;
             case RIGHT:
              right_arrow_down = false;
              break;
             case UP:
              up_arrow_down = false;
              break;
             case DOWN:
              down_arrow_down = false;
              break;
         // only set key_pressed to false if all keys have been released
         if (!left_arrow_down &&
           !right_arrow_down &&
           !up_arrow_down &&
           !down_arrow_down)
             key_pressed = false;
         checkForKeyPressed();
        }Let me know if you'd like a SSCCE.
    Thanks

    It's this second-long delay which is the anomoly. I'm guessing it results from the fact that the KeyEvent is not being fired constantly or immediately after the release of the first key.That's the usual key-repeat behavior on most OSs.
    I'm wondering if there's a way to get rid of the delay Probably by setting booleans in the keyPressed(...) / keyReleased(...) and polling those booleans at equal intervals using a Timer.
    db

  • Some problems with fullscreen, keylistener and bufferstrategy :-)

    Hi.
    I have a few questions.
    I worked a long time trying to make my game run smoothly but I just couldn't get it perfect. I thought it had something to do with the load of graphics I use, but it wasn't the case. Here is what I did:
    public class Game extends Frame implements Runnable, KeyListener {
        int [] controls = new int[256];
        final static int FrameRate = 60;
        final int MiliFrameLength = 1000/FrameRate;
        private long startTime;
        private int frameCount;
        public Game()
            GraphicsDev gd = new GraphicsDev(); // Class that handles the graphics device
            int ref = gd.getDisplayM().getRefreshRate();
            if(fullscreen==1) {
                setUndecorated(true);
                gd.getGraphicsDev().setFullScreenWindow(this);
                gd.getGraphicsDev().setDisplayMode(new DisplayMode(screenWidthX,screenWidthY,24,ref));
            } else if (fullscreen==0) {
                setSize(screenWidthX,screenWidthY);
            addKeyListener(this);
            show();
            createBufferStrategy(2);
            buffer = getBufferStrategy();
            startTime = System.currentTimeMillis();
            frameCount = 0;
            Thread t = new Thread(this);
            t.start();
            update();
        public void update() {
            while(rungame)  {
                Graphics2D gr2D = (Graphics2D)buffer.getDrawGraphics();
                if(controls[40] == 1) moveup(1);
                if(controls[38] == 1) movedown(1);
                if(controls[37] == 1) moveleft(1);
                if(controls[39] == 1) moveright(1);
                paintGraphics(gr2D);
                gr2D.dispose();
                buffer.show();
                frameCount++;
                while((System.currentTimeMillis()-startTime)/MiliFrameLength <frameCount)
                { Thread.yield(); }
        public void keyPressed(KeyEvent ke) {
             controls[ke.getKeyCode()&0xFF] = 1;
        public void keyReleased(KeyEvent ke) {
             controls[ke.getKeyCode()&0xFF] = 0;
          public void keyTyped(KeyEvent ke){}
    }The original code is of cause much bigger, so this is just to show what happens. It's pretty straight forward.
    My problem is that the game only runs completely smooth when it is in fullscreen and v-synched. This means that I have to have a framerate at 60 (same as the refreshrate). It looks great, but my keyboard input can't keep up with this speed. About every 10 sec the game hangs for a while. If I set the framerate or refreshrate lower it doesn�t run smoothly.
    My questions are:
    1: Is it possible to make the keyboard work with a framerate/refreshrate of 60+
    2: Is it possible to use v-synched in window mode?
    3: If yes � How do I do this? ;-)
    Maybe I'm taking a totally wrong approach to this, but everyone seems to have different solution to making a game to run smooth, and right now I'm very confused (was first yesterday I found out about the v-synch).

    I've seen this code before. You're following a standard rendering template right? I've never used the
    while((System.currentTimeMillis()-startTime)/MiliFrameLength <frameCount)
                { Thread.yield(); } method for syncing framerate but here's another suggestion which
    is what I use and my rendering is as smooth as silk even at a monitor refresh rate (and framerate)
    of 85 fps (however, like you, I only go to 60 fps) long framerate = 60;  //i.e. 60 fps
       public final void run(){
          long start_Time = 0;
          long elapsed_Time = 0;
          final Thread t = Thread.currentThread();
          while(t == thread){
             //start_Time = . . .
             render();
             relocate_Sprites();
             sort_Sprites_for_Z_Buffer();
             //elapsed_Time = . . .
             try{
                if(elapsed_Time < 1000/framerate)
                   Thread.sleep(1000/framerate-elapsed_Time);
                else
                   Thread.sleep(3); // without this line, you may starve the gc
             catch(InterruptedException e){
       }This system works perfectly even with 40 Sprites, one of which is like 1050 x 640 in dimensions
    (background which scrolls a bit). My system is not particularly fast:
    -AMD Athlon 1.2 GHz
    -384 MB RAM
    -nVidia GeForce 2 400 MX at 32 MB (this piece is practically extinct now)

  • How to open files in MIDP (from the jar file)?

    Hello,
    I can't seem to figure out how to open a file that is in my MIDP applications jar-File.
    From what I've found via Google, I assume that the way to do it should be by using
    Connector.openInputStream("file:{path_to_my_file}")
    but I only get the error
    java.lang.ClassNotFoundException: com.sun.midp.io.j2me.file.Protocol
    (Running the Emulator from Suns WTK 2.0 with DefaultColorPhone)
    I've also tried file:// with the same result.
    Any ideas?
    Many thanks in advance!
    Bjoern

    I think I've found something that looks promising now:
    Class.getResourceAsStream()

  • What's a good MIDP 2.0 implementation? Not Nokia 6600!

    Hi All,
    My company is developing an mobile application that connects to a server over HTTP... Nothing new. But we need the features of MIDP 2.0 and MMAPI because we take photos of items and upload these to the server, as well as some CustomItem for displaying these in a grid-like format.
    The only one matching this profile (according to http://jal.sun.com/webapps/device/device?api=61) is the Nokia 6600. So we brought one. Unfortunately, it has a lot of bugs which make us unable to use these features. CustomItems don't display on the screen until they are forced to refresh (by moving over them, etc.) Changing Forms (using setDisplay) causes the app to 'randomly' crash. The ChoiceItem as type POPUP doesn't respond to the change event so they are practicly useless. To work around these we had to make a CustomForm class which recorded the state of the current form & cleared it as a new form for use by another 'screen'. Change the popups into opening another form for selection.
    We also had to make the camera capture as a Form item (to prevent changing Displayables and causing random crashes). But the picture about to be taken would only update if you moved the cursor right or left (suprisingly up & down didn't do anything).
    In the end it basically became unusable because of all these changes & work-a-rounds just to avoid the bugs in the implementation. Nokia weren't of much help either!
    I really like the MIDP 2.0 profile, Sun's SDK is excellent, and was very quick & easy to get used too. So since a lot of the code already exists in J2ME and our server side is also J2EE, I would like to continue developement in this environment.
    So I guess the purpose of writing this message is two-fold... 1) If you are thinking of serious MIDP 2.0 developement, don't use the 6600 and 2) Can anyone please tell me if there is a decent implementation of MIDP 2.0 & MMAPI out on the market? We really need to know as we don't want to go to other alternatives (like Microsoft) but we will if there are no other choices....
    Thanks in advance for any help at all.

    Hi, What I am providing is not really a solution to your problems.
    In fact I am asking questions, currently I want to do the same thing as you i.e. uploading and downloading medias files to and from a Server, therefore my questions are:
    -Can You access the default media files folders (Image, sounds and videos) ?
    -Is it in these folders that you store the downloaded media files ? or are you obliged to store them elsewhere (RMS in particular ).
    I am currently using Symbian C++ as developing langage but if I could move to Java It would be great because It's too hard to master symbian C++ (every thing is a nightmare...).
    Thanks in advance for your anwser
    Have a nine day

  • KeyListener no longer working in JPanel

    Hi,
    I have implemented a graphics interface with JPanel with mouse action and movement captured. Everything works fine until I added KeyListener implementation.
    No matter what I do, I could not enable the key event.
    The top window is a JFrame which contains several components and one of them is a JPanel. I wanted to capture key event inside that JPanel.
    JFrameC a = new JFrameC();
    JPanelC b = new JPanelC(a);
    And inside JPanelC, I have statement as
    a.addKeyListener(this);
    addKeyListener(this);
    But still no key event.
    If I simply change JPanelC class from JPanel to Panel (only extends statement), key event appears as it supposes to be.
    What's wrong with JPanel? I thought it should behave similar to Panel with more better features.
    What should I do to enable key event in JPanel?
    Please help.

    I tried the following simple program which is similar to my complicated implementation and it worked. I am confused.
    <pre>
    //KeyFrame.java
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.BorderLayout;
    import java.awt.*;
    public class KeyFrame extends JFrame {
    public KeyFrame(String s) {
    super(s);
    KeyEventDemo ked = new KeyEventDemo(this);
    getContentPane().add(ked);
    pack();
    show();
    setSize(500, 500);
    validate();
    public static void main(String [] args) {
    KeyFrame kf = new KeyFrame("");
    // KeyEventDemo.java
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.BorderLayout;
    import java.awt.*;
    public class KeyEventDemo extends JPanel
    //implements KeyListener, ActionListener {
    implements KeyListener {
    public KeyEventDemo(Component c) {
    super();
    c.addKeyListener(this);
    //addKeyListener(this);
    /** Handle the key typed event from the text field. */
    public void keyTyped(KeyEvent e) {
    System.err.println("KEY TYPED: ");
    /** Handle the key pressed event from the text field. */
    public void keyPressed(KeyEvent e) {
    System.err.println("KEY PRESSED: ");
    /** Handle the key released event from the text field. */
    public void keyReleased(KeyEvent e) {
    System.err.println("KEY RELEASED: ");
    </pre>

  • Urgent help in Midp porting

    hi,
    Im Rahulya, i'm final year student of b.e. computer.
    I am working on my project ,which requires me to port midp on linux, and i guess anybody might have already ported midp,so i expect some help from u.
    I have already ported KVM on redhat linux, now im porting midp on redhat linux. Almost it's done , but i have problem in midp event handling.
    I have written stubs for the native functions which have not been defined in the midp/src/platform/native directory.(Eg. Java_com_sun_cldc_io_j2me_events_PrivateInputStream_readInt()
    ,this function is called in midpEvents.c)
    In midpEvents.c the function
    void Java_com_sun_midp_lcdui_Events_readInt(void)
    calls the function
    Java_com_sun_cldc_io_j2me_events_PrivateInputStream_readInt()
    but the function is undefined. And i am not able to find anything related to how to port these native functions or how to implement these function.
    So, if u have any idea about this ,please let me know
    Help me out.
    Thanks in advance.

    hi
    i'm having the same problem.

Maybe you are looking for