Java Tutorial/SWT/WindowManagers

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

WindowManagers

WindowManagers groups windows. Then you can close them as a group.



   <source lang="java">

import org.eclipse.jface.window.ApplicationWindow; import org.eclipse.jface.window.WindowManager; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.ruposite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; public class ApplicationWindowManager {

 public static void main(String[] args) {
   MainWindow main = new MainWindow();
   MainWindow main2 = new MainWindow();
   
   WindowManager wm = new WindowManager();
   wm.add(main);
   wm.add(main2);
   if (!wm.close()){
     System.err.println("Windows failed to close");
   }
 }

} class MainWindow extends ApplicationWindow {

 public MainWindow() {
   super(null);
   // Don"t return from open() until window closes

// setBlockOnOpen(true);

   // Open the main window
   open();
   // Dispose the display
   Display.getCurrent().dispose();
 }
 protected Control createContents(Composite parent) {
   // Create a Hello, World label
   Label label = new Label(parent, SWT.CENTER);
   label.setText("www.jexp.ru");
   return label;
 }

}</source>