BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 03-19-2007, 06:03 AM   #1 (permalink)
New Member
 
Join Date: Mar 2007
Model: 8700g
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Can't obtain multiple windows

Please Login to Remove!

Hi! I'm a noob and my company would like me to develop a BlackBerry java application. I've got some Java basics and I learn in a very quick way.
But I really can't develop a multiple-windows application
May somebody help me?

My application pushes the first screen into the stack
Code:
 public Test(){
        pushScreen(new MainWindow());
    }
This works fine, but I can't do the same thing for another window (ex: SecondWindow)

This is the code of MainWindow.java:
Code:

class MainWindow extends MainScreen{
      private UiApplication _app;
      
      public MainWindow(){
        super(DEFAULT_MENU | DEFAULT_CLOSE);
      
        setTitle(new LabelField("Main Window"));

        add(new RichTextField("String"));
    }

    public boolean onClose(){
        System.exit(0);
        return true;
    }

    public boolean keyChar(char key, int status, int time) {
        //intercept the ESC key - exit the app on its receipt
        boolean retval = false;
        switch (key) {
            case Characters.ESCAPE:
                onClose();
                retval = true;
            break;
            case Characters.LATIN_SMALL_LETTER_L:
                SecondWindow screen = new SecondWindow();
                _app.pushModalScreen(screen);
                retval = true;
            break;
        }
        return retval;
    }
    
    
    
}
I wrote this just for learning: when the user presses the "l" key, a new window should be created (SecondWindow.java is quite a copy of the code of MainWindow.java). This does not work .. the program compiles, but I obtain a NullPointerException when I press the "l" key..

May somebody help me?
Offline  
Old 03-19-2007, 07:28 AM   #2 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

you declarate _app but you don't have an instanciated object of that name, do you?

Code:
UiApplication.getUiApplication().pushScreen(new SecondWindow());
should do what you want
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 03-19-2007, 07:54 AM   #3 (permalink)
New Member
 
Join Date: Mar 2007
Model: 8700g
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by simon.hain
you declarate _app but you don't have an instanciated object of that name, do you?

Code:
UiApplication.getUiApplication().pushScreen(new SecondWindow());
should do what you want
Yep it does, and I found it about 10 seconds after my post loooool...
Thanks anyway! Just another question: should I put a close(); after the pushScreen?
Offline  
Old 03-19-2007, 08:46 AM   #4 (permalink)
New Member
 
Join Date: Feb 2007
Location: Bonn, Germany
Model: 8100
Carrier: T-Mobile
Posts: 7
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Wirelessly posted (BlackBerry8100/4.2.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/114)

You can't modify the UI directly from your main event thread. Instead, you have to use the invokeAndWait or invokeLater methods in UiApplication.

Regards,

Marcelo
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Lot of 5 Nextel Blackberry 7520 and 1 7510 - For Parts - Accessories Included
$29.95
Lot of 5 Nextel Blackberry 7520 and 1 7510 - For Parts - Accessories Included pictureLot of 14 Blackberry 9650 Verizon Smartphone (As-Is)
$100.0
Lot of 14 Blackberry 9650 Verizon Smartphone (As-Is) pictureLot of 27 Blackberry 9930 Verizon Smartphone (As-Is)
$100.0
Lot of 27 Blackberry 9930 Verizon Smartphone (As-Is) pictureBlackBerry Unlock Code AT&T USA Blackberry Curve 8320 8520 Clean imei only
$1.99
BlackBerry Unlock Code AT&T USA Blackberry Curve 8320 8520 Clean imei only pictureBlackBerry Unlock Code AT&T USA Blackberry STL100 3 Clean imei only
$20.0
BlackBerry Unlock Code AT&T USA Blackberry STL100 3 Clean imei only picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.