You Are Here:

Community: Developer Discussion Boards

#1 Old Form's init function with Alert Box - 2003-10-19, 15:19

Join Date: Oct 2003
Posts: 41
Location: Pakistan, Karachi
farhanx
Offline
Registered User
HI!
How can i initialize the Alert(as forever) in a Form extended class as when the class get start? when i put alert in init function it doesnt show it why ? while on kepressing and comand listener its working.

thanks
farhan
Reply With Quote

#2 Old 2003-10-19, 16:53

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
I don't understand what you are trying to do.
Maybe post some relevant code.

shmoove
Reply With Quote

#3 Old 2003-10-19, 17:17

Join Date: Oct 2003
Posts: 41
Location: Pakistan, Karachi
farhanx
Offline
Registered User
i am trying this but its not showing alert ....

this class is extended from FORM

/**Component initialization*/
private void jbInit() throws Exception {
addCommand(new Command("Back", Command.BACK, 1));

try{

i= i.createImage("/born4pure/images/solder.png");
imageItem1.setImage(i);
}
catch (java.io.IOException e) {
System.out.println(e.getMessage());
System.out.println("image not found");
}

showMessage();
}


//this method is for alert
public void showMessage()
{

Alert a= new Alert("ERROR");
a.setImage(i);
a.setTimeout(Alert.FOREVER);
Display.getDisplay(Born4Pure.instance).setCurrent(a);
}


i am putting this inside the init function because , when user will come at this java file then he must see the Forever Alert message untill he wont dismiss by him self. So because of that reason i am trying to put alert in JBINIT but its not working , while on comand lsitener it works.....
Reply With Quote

#4 Old 2003-10-19, 18:14

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
I don't know what is calling jbInit() so I can't be sure why the alert doesn't display.
But, I don't know if you are aware of this, but Display.setCurrent() has another variation that might be of use to you:
Code:
public void setCurrent(Alert alert, Displayable nextDisplayable)
It puts an alert on screen, and when the alert is dismissed it puts nextDisplayable on screen.
You could use this to display the alert and then the form (as your nextDisplayable), instead of displaying the alert from the form's startup code.
Reply With Quote

#5 Old 2003-10-19, 18:20

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
My guess though as to why your code doesn't work is that you are asking to display the alert before asking to display the form.
If jbInit() is called from the Forms constructor (as the name suggests) then the call to setCurrent() for the alert is coming before any calls to setCurrent() for the form.
Reply With Quote

#6 Old 2003-10-19, 18:23

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
Example (assuming the form's class is called MyForm):
Code:
// there is no way to call setCurrent any faster for the form!!
Display.getDisplay(Born4Pure.instance).setCurrent(new MyForm());
First the "new MyForm()" part of the code will be called -> this will call the initializing function -> this calls display.setCurrent() for the alert (the alert might even get shown for a fraction of a second here!), and then the call to setCurrent() with the form is called, so the form's runs over the alert.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia