Java by API/org.eclipse.swt.widgets/DirectoryDialog — различия между версиями

Материал из Java эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 14:16, 31 мая 2010

DirectoryDialog: open()

import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class MainClass {
  public static void main(String[] a) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    DirectoryDialog dlg = new DirectoryDialog(shell);
    dlg.setFilterPath("c:/");
    dlg.setText("SWT"s DirectoryDialog");
    dlg.setMessage("Select a directory");
    String dir = dlg.open();
    if (dir != null) {
      System.out.println(dir);
    }
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    display.dispose();
  }
}





DirectoryDialog: setFilterPath(String path)

import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class MainClass {
  public static void main(String[] a) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    DirectoryDialog dlg = new DirectoryDialog(shell);
    dlg.setFilterPath("c:/");
    dlg.setText("SWT"s DirectoryDialog");
    dlg.setMessage("Select a directory");
    String dir = dlg.open();
    if (dir != null) {
      System.out.println(dir);
    }
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    display.dispose();
  }
}





DirectoryDialog: setMessage(String message)

import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class MainClass {
  public static void main(String[] a) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    DirectoryDialog dlg = new DirectoryDialog(shell);
    dlg.setFilterPath("c:/");
    dlg.setText("SWT"s DirectoryDialog");
    dlg.setMessage("Select a directory");
    String dir = dlg.open();
    if (dir != null) {
      System.out.println(dir);
    }
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    display.dispose();
  }
}





new DirectoryDialog(Shell shell)

import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class MainClass {
  public static void main(String[] a) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    DirectoryDialog dlg = new DirectoryDialog(shell);
    dlg.setFilterPath("c:/");
    dlg.setText("SWT"s DirectoryDialog");
    dlg.setMessage("Select a directory");
    String dir = dlg.open();
    if (dir != null) {
      System.out.println(dir);
    }
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    display.dispose();
  }
}