Java by API/org.eclipse.swt.widgets/FileDialog
Содержание
FileDialog: open()
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
public class MainClass {
public static void main(String[] a) {
Shell s = new Shell();
FileDialog fd = new FileDialog(s, SWT.OPEN);
fd.setText("Open");
fd.setFilterPath("C:/");
String[] filterExt = {"*.txt","*.doc", ".rtf", "*.*"};
fd.setFilterExtensions(filterExt);
String selected = fd.open();
System.out.println(selected);
}
}
FileDialog: setFilterExtensions(String[] filters)
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
public class MainClass {
public static void main(String[] a) {
Shell s = new Shell();
FileDialog fd = new FileDialog(s, SWT.OPEN);
fd.setText("Open");
fd.setFilterPath("C:/");
String[] filterExt = {"*.txt","*.doc", ".rtf", "*.*"};
fd.setFilterExtensions(filterExt);
String selected = fd.open();
System.out.println(selected);
}
}
FileDialog: setFilterPath(String path)
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
public class MainClass {
public static void main(String[] a) {
Shell s = new Shell();
FileDialog fd = new FileDialog(s, SWT.OPEN);
fd.setText("Open");
fd.setFilterPath("C:/");
String[] filterExt = {"*.txt","*.doc", ".rtf", "*.*"};
fd.setFilterExtensions(filterExt);
String selected = fd.open();
System.out.println(selected);
}
}
new FileDialog(Shell parent, int style) (SWT.OPEN)
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
public class MainClass {
public static void main(String[] a) {
Shell s = new Shell();
FileDialog fd = new FileDialog(s, SWT.OPEN);
fd.setText("Open");
fd.setFilterPath("C:/");
String[] filterExt = {"*.txt","*.doc", ".rtf", "*.*"};
fd.setFilterExtensions(filterExt);
String selected = fd.open();
System.out.println(selected);
}
}
new FileDialog(Shell parent, int style) (SWT.SAVE)
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
public class MainClass {
public static void main(String[] a) {
Shell s = new Shell();
FileDialog fd = new FileDialog(s, SWT.SAVE);
fd.setText("Save");
fd.setFilterPath("C:/");
String[] filterExt = {"*.txt","*.doc", ".rtf", "*.*"};
fd.setFilterExtensions(filterExt);
String selected = fd.open();
System.out.println(selected);
}
}