1.4 AWT Controls & Layout Manager Part-4
1.4 AWT Controls & Layout Manager Part-4
-The Dialog control represents a top level window with a border and a title used to take some form of input from the
user.
- It inherits the Window class.
-Unlike Frame, it doesn't have maximize and minimize buttons.
-Frame and Dialog both inherits Window class. Frame has maximize and minimize buttons but Dialog doesn't have.
There are two kinds of Dialog windows –
1.Modal Dialog window-
When a modal dialog window is active, all the user inputs are directed to it and all the other parts of
application are inaccessible until this model dialog is closed.
2.Modeless Dialog window-
When a modeless dialog window is active, the other parts of application are still accessible as normal and
inputs can be directed to them, without needing to close this modeless dialog window.
Constructors-
Dialog(Frame parentWindow, boolean mode)
Dialog(Frame parentWindow, String title, boolean mode)
FileDialog
The FileDialog class displays a dialog window from which the user can select a file.
Constructor-
1. FileDialog (Frame frmobj)- Creates a file dialog for loading a file.
2.FileDialog(Frame frmobj, String title)- Creates a file dialog window with the specified title for loading a file.
3.FileDialog(Frame frmobj, String title, int mode)-Creates a file dialog window with the specified title for loading or
saving a file.
mode- 1. FileDialog.LOAD -- This constant value indicates that the purpose of the file dialog window is to locate a file
from which to read.
2. FileDialog.SAVE -- This constant value indicates that the purpose of the file dialog window is to locate a file to
which to write.
Methods-
1. String getDirectory()- Gets the directory of this file dialog.
2. String getFile()- Gets the selected file of this file dialog.
3. int getMode()- Indicates whether this file dialog box is for loading from a file or for saving to a file.
4. void setMode(int mode)-Sets the mode of the file dialog.
5.void setDirectory(String directory)-set the directory of this file
6.void setFIle(String file)-set the file
FileDialog