BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 10-15-2004, 09:15 AM   #1
igfarm
New Member
 
Join Date: Oct 2004
Posts: 2
Default Dialog with fields

Please Login to Remove!

I am trying to create a simple popup dialog that propmpts for a user name and password, and an OK and Cancel buttons using the following code:

public final class LoginDialog extends Dialog
{
private EditField userNameField;
private EditField passwordField;

public LoginDialog(String choices[], int values[])
{
super("Login Information", choices, values,
Dialog.OK, Bitmap.getPredefinedBitmap(Bitmap.INFORMATION), Dialog.GLOBAL_STATUS);

userNameField = new EditField
("User Name: ", "", 50, EditField.EDITABLE);
add(userNameField);

passwordField = new EditField
("Password: ", "", 50, EditField.EDITABLE);
add(passwordField);
}
}


The problem I have is that the two fields are displayed "below" the Ok and Cancel buttons.

I also tried replacing the adds by inserts as follows:

insert(userNameField, 3);
...
insert(passwordField, 3);

but this just give me a dialog, but the fields do not show up. Using an index of 0 or 4 gives me a ArrayIndexOutOfBounds exception. Using index of 1,2, or 3 give me a dialog without fields.

How can I make the two fields show above the buttons?

Thanks,
Jaime
Offline  
Old 10-15-2004, 10:54 AM   #2
jbartel
Knows Where the Search Button Is
 
Join Date: Sep 2004
Posts: 17
Default

try this:

Code:
public final class TestDialog extends Dialog
xxx123;
    private EditField userNameField;
    private EditField passwordField;

    public TestDialogxxx40;String choicesxxx91;xxx93;, int valuesxxx91;xxx93;xxx41;
    xxx123;
        superxxx40;"Login Information", choices, values, Dialog.OK, Bitmap.getPredefinedBitmapxxx40;Bitmap.INFORMATIONxxx41;, Dialog.GLOBAL_STATUSxxx41;;
        
        userNameField = new EditFieldxxx40;"User Namexxx58; ", "", 50, EditField.EDITABLExxx41;;        
        passwordField = new EditFieldxxx40;"Passwordxxx58; ", "", 50, EditField.EDITABLExxx41;;
        
        Manager delegate = getDelegatexxx40;xxx41;;
        ifxxx40; delegate instanceof DialogFieldManager xxx41;
        xxx123;
            DialogFieldManager dfm = xxx40;DialogFieldManagerxxx41;delegate;
            Manager manager = dfm.getCustomManagerxxx40;xxx41;;
            ifxxx40; manager != null xxx41;
            xxx123;
                manager.insertxxx40;userNameField, 0xxx41;;
                manager.insertxxx40;passwordField, 1xxx41;;
            xxx125;
        xxx125;
        
    xxx125;    
xxx125;
Offline  
Old 10-15-2004, 01:32 PM   #3
igfarm
New Member
 
Join Date: Oct 2004
Posts: 2
Default

That works great. The only caviot is the that the "values" parameter of the constructor should be padded with two extra fields at the beginig, otherwise the return value is not picked correctly:

String choices[] = {"OK", "Cancel"};
int values[] = {0, 0, Dialog.OK, Dialog.CANCEL};

TestDialog pw = new TestDialog(choices, values);
if (pw.doModal() == Dialog.OK)
{
...
}

Many thanks!

Jaime
Offline  
Closed Thread



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


CH341A 24 25 Series EEPROM Flash BIOS USB Programmer Module + SOIC8 Test Clip picture

CH341A 24 25 Series EEPROM Flash BIOS USB Programmer Module + SOIC8 Test Clip

$5.88



US Stock 5pcs W27C512-45Z W27C512 DIP IC EEPROM 512KBIT 45NS picture

US Stock 5pcs W27C512-45Z W27C512 DIP IC EEPROM 512KBIT 45NS

$17.75



EEPROM BIOS USB Programmer CH341A + SOP8 Clip + 1.8V Adapter + SOP8 Adapter picture

EEPROM BIOS USB Programmer CH341A + SOP8 Clip + 1.8V Adapter + SOP8 Adapter

$14.50



10PCS W27C512-45Z W27C512 DIP IC EEPROM 512KBIT 45NS Winbond EEPROMs USA picture

10PCS W27C512-45Z W27C512 DIP IC EEPROM 512KBIT 45NS Winbond EEPROMs USA

$17.98



10PCS W27C512-45Z W27C512 DIP IC EEPROM 512KBIT 45NS Winbond EEPROMs USA picture

10PCS W27C512-45Z W27C512 DIP IC EEPROM 512KBIT 45NS Winbond EEPROMs USA

$19.49



10PCS DIP-28 Eeproms Programmable Flash Chip For SST27SF512-70-3C-PG SST 27SF512 picture

10PCS DIP-28 Eeproms Programmable Flash Chip For SST27SF512-70-3C-PG SST 27SF512

$27.89







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