Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Java (or J2ME) question

  • 19-11-2008 8:16pm
    #1
    Closed Accounts Posts: 2,349 ✭✭✭


    For a J2ME project I have this problem:

    I have a class that is basically a File Browser for the phone. The class is instantiated in the main java file i.e.
    public void startApp() {
            FileBrowser browser = new FileBrowser(Display.getDisplay(this), true);
    ........
    }
    

    The user selects a file and I want the main class to wait until this happens. How can I do it?

    I know I can do it with a callback function but my code just starts to get overcomplicated, can I make the main class wait until an event has occured in the FileBrowser class?


Comments

  • Moderators, Science, Health & Environment Moderators Posts: 10,088 Mod ✭✭✭✭marco_polo


    grasshopa wrote: »
    For a J2ME project I have this problem:

    I have a class that is basically a File Browser for the phone. The class is instantiated in the main java file i.e.
    public void startApp() {
            FileBrowser browser = new FileBrowser(Display.getDisplay(this), true);
    ........
    }
    

    The user selects a file and I want the main class to wait until this happens. How can I do it?

    I know I can do it with a callback function but my code just starts to get overcomplicated, can I make the main class wait until an event has occured in the FileBrowser class?

    Not sure how well it is supported in J2ME but I would use a seperate thread for the file browser if possible, you can then wait for an answer in the main thread. The browser thread should notify the main thread when a file is selected by the user.


  • Closed Accounts Posts: 2,349 ✭✭✭nobodythere


    Thanks, I'll try that. Only done threads in C so I'm eager to find another way! If anyone has a simpler way do chime in :)

    Edit: Turns out it's very easy and I can use "wait()" and "notify()" - see http://www.crazysquirrel.com/computing/java/concurrency/wait-and-notify.jspx for anyone having trouble


  • Registered Users, Registered Users 2 Posts: 21,611 ✭✭✭✭Sam Vimes


    i know in J2SE you can call a method called int returnVal = fc.showOpenDialog(.....)

    and it opens the chooser box and the program waits until you choose a file. I'd assume it's something similar in J2ME


Advertisement