4. Dialog Box
• Dialog boxes are primarily used to obtain user
input
• They are similar to frame windows, except that
dialog boxes are always child windows of a top-
level window
• Dialog boxes don’t have menu bars
5. Dialog Box contd..
• Dialog boxes may be modal or modeless
• Modal means
– Focus is always on the current dialog box
6. Dialog Box contd..
• Two commonly used
constructors are shown
here
– Dialog(Frame
parentWindow, boolean
mode)
– Dialog(Frame
parentWindow, String title,
boolean mode)
– Here, parentWindow is the
owner of the dialog box. If
mode is true, the dialog
box is modal
– Otherwise, it is modeless
7. swings
Struts
jdbc
hibernate
home
java previous question papers
OCT/NOV-2012 QUESTION PAPER
April / May 2012 c-09
October/ November-2011 c-09
April/ May 2011 c-09
April/ May 2011 c-05
Home 7
8. Methods of Dialog Box
• Commonly used methods
– void show()
• Shows the dialog
– String getTitle()
• Returns the title of the dialog
– void setTitle(String title)
• Sets the dialog title
– boolean isModal()
• Checks whether the dialog is modal or not
9. Methods of Dialog Box contd..
• void setModal(boolean flag)
– Sets the current dialog to modal
• boolean isResizable()
– Returns whether the dialog is resizable
• setResizable(boolean flag)
– Sets the dialog to be resizable
10. Example Program
import java.awt.*
import java.awt.event.*;
public class DialogDemoextendfs Frame{
public DialogDemo{
setTitle(“MyDialog”);
setSize(250,200);
setVisible(true);
Dialog myDialog = new Dialog(this,”Dialog”);
myDialog.setSize(150,100:
myDialog.show();
}
11. Example Program contd..
public static void main(String args[]){
new DialoDemo();
}
}
12. Summary
• In this class we have learnt
– Different constructors of Dialog
– Methods of Dialog class
– Example program
13. Quiz
1. The method useful for setting a dialog to be
modal
a) getModal()
b) setTitle()
c) setModal()
d) isModal()
14. Frequently Asked Questions
1. List and explain the constructors of Dialog class
2. List and explain the methods of dialog class
15. swings
Struts
jdbc
hibernate
home
java previous question papers
OCT/NOV-2012 QUESTION PAPER
April / May 2012 c-09
October/ November-2011 c-09
April/ May 2011 c-09
April/ May 2011 c-05
Home 15