Using advanced dialog boxes and device-related features in mobile applications
Multipagedialog, Querydialog, Timedmessagebox, MobileDevice, screen, and Input
Brief introduction
Introduction to the ESWT Mobile extensions in this series, part 1th: Using simple widgets to quickly build mobile applications "quickly build mobile applications with simple widgets" provides an overview of mobile expansion packs. It also describes some of the basic controls (Captionedcontrol, Constrainedtext, Dateeditor, ListBox, and ListView).
Introduction to ESWT Mobile Extensions, part 2nd: Using advanced controls in mobile applications using advanced controls in mobile applications covers some of the advanced controls (Mobileshell, SortedList, HyperLink, Textextension, and Tasktip).
In this article, learn how to use:
Multipagedialog Create a tab dialog box.
Querydialog gives a prompt dialog box for the user to get data input.
Timedmessagebox simply informs the user of limited information.
MobileDevice get more information about device features and features.
Screen represents a display that you can use for your application.
Input represents a key-based input attribute.
MultiPageDialog
MultiPageDialog
The instance of the class represents a tab dialog box. This dialog box contains multiple pages. Each page contains a composite component (composite). At any given moment, only one page is visible. Whether the page is visible can be selected by the end user or by application programming. Each page should have a label. This label can be displayed as text, an icon, or both in the platform. The size and position of the page label depends on the implementation. The boundaries of the dialog box also depend on the implementation. After the page is created, the application can query the actual size of the page by Page.getbounds.
There is no fixed limit on the number of pages. However, if there is not enough resources to create a new page, a Run-time exception is thrown.
Page-related commands are available only if the page is visible. These commands can also be associated with the entire multipagedialog, simply by setting the shell of the dialog box as the associated control for these commands, as follows:
Command c = new Command(page.getShell(), Command.GENERAL, 10)
Multipagedialog is a modal dialog box that supports the following styles. It relies on implementation; the actual appearance and behavior may vary depending on the device.
SYSTEM_MODAL
APPLICATION_MODAL
PRIMARY_MODAL
Listing 1 shows the sample code for creating the Multipagedialog.
Listing 1. Create Multipagedialog
composite pages[] = new Composite[3];
Multipagedialog MPD = new Multipagedialog (shell);
Pages[0] = mpd.createpage ("Personal", null);
Pages[1] = mpd.createpage ("Business", null);
Pages[2] = mpd.createpage ("Travel", null);
Pages[0].setlayout New Rowlayout (SWT. VERTICAL));
//Name
Captionedcontrol name = new Captionedcontrol (Pages[0], SWT. Left_to_right);
Name.settext ("Name:");
Text userName = new text (name, SWT. Single);
Username.settext ("John");
Username.seteditable (TRUE);
//Surname
Captionedcontrol Surname = new Captionedcontrol (Pages[0], SWT. Left_to_right);
Surname.settext ("surname:");
Text usersurname = new text (surname, SWT. Single);
Usersurname.settext ("Marshall");
//Date of birth
Captionedcontrol birthdate = new Captionedcontrol (Pages[0], SWT. Left_to_right);
Birthdate.setsize (200,30);
Birthdate.settext ("Date of Birth:");
Dateeditor birthdateeditor = new Dateeditor (birthdate, SWT. NORMAL, DateediTor. DATE |
Dateeditor.full);
//Phone number
Captionedcontrol phonenumber = new Captionedcontrol (Pages[0], SWT. Left_to_right);
Phonenumber.settext ("Phone number:");
Constrainedtext userphonenumber = new Constrainedtext (PhoneNumber, SWT. NORMAL,
Constrainedtext.phonenumber);
Userphonenumber.settext ("6902690369");
Pages[0].layout ();
Mpd.open ();