This section illustrates you how to browse a file.
In SWT, the class FileDialog allow the user to navigate the file system and select a file name. In order to layout the text, we have used the method text.setLayoutData(data). The method file.isFile() tests whether the file denoted by the pathname is a normal file. The method file.list() returns an array of files and directories. The method text.setText(files[i]) sets the selected file in the text. The method text.setEditable(true) sets the editable state.
Here is the code of FileBrowser.java
import java.io.File;
|
Output will be displayed as:

On clicking the browse button, file dialog will open:

After clicking the open button, output will be displayed as:

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: SWT File Browser View All Comments
Post your Comment