|
To access the contents, click the chapter and section titles.
Sams Teach Yourself Visual J++ 6 in 21 Days
The last method were going to talk about in this chapter sets the windows visibility to either visible or invisible. The setVisible() method takes a Boolean argument. The value of true makes the window visible; the value of false makes it invisible. The following example shows how to make a window invisible: setVisible( false ); SummaryDialogs are a powerful tool in your user-interface arsenal. And Visual J++ makes it easy to create and use them. After youve worked your way through this chapter, you should take some time and create dialogs of your own design. This experimentation will go far toward helping you feel comfortable with dialogs in Visual J++. Q&AQ Why are dialogs so important in Windows programs? A They allow you to present many types of information to users and to ask for all kinds of information that the application needs in order to function. For instance, you might need to ask for the users name and address. You might want to ask other users to select from a list of choices. Q Whats the difference between a Form and a dialog? A Not much in the way theyre created and designed. To add a dialog, you start by adding a Form to your project. You use the same user-interface objects, such as combo boxes, buttons, and list boxes, to add functionality. Where they differ is in how theyre displayed. A dialog is displayed with the showDialog() method. This method then shows the dialog as a modal window. Q How can you get input from OK and Cancel buttons? A You start by adding them to the Form. Then you have to set the button dialogResult properties to OK and Cancel. Finally, in the dialogs Form class, set the acceptButton property to the OK button and the cancelButton property to the Cancel button. Q Why should dialogs be modal? Why should interaction with the main program be paused until users are finished with the dialog? A The main purpose for a dialog is to get information from a user thats needed to continue program execution. In most cases, the program wouldnt be able to continue without the information requested by the dialog, so its only natural to pause the program until all the information has been given. Q What are some dialog donts? A Dont have minimize and maximize buttons on dialogs. Dont use pull-down menus in dialogs. Make sure that users can answer all queries and enter all information without having to refer to something in the main program. Exercises
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |