FileDocCategorySizeDatePackage
OnTopProblem.javaAPI DocAzureus 3.0.3.43786Thu Feb 09 19:43:18 GMT 2006org.gudy.azureus2.ui.swt.snippets

OnTopProblem

public class OnTopProblem extends Object

Fields Summary
private static int[]
sizes
org.eclipse.swt.widgets.Display
display
org.eclipse.swt.widgets.Shell
mainShell
org.eclipse.swt.widgets.Shell
onTopShell
org.eclipse.swt.widgets.Label
labelIter
int
iter
Constructors Summary
public OnTopProblem()

  
  
    
    display = new Display();
    mainShell = new Shell(display,SWT.SHELL_TRIM);        
    mainShell.setText("OnTopProblem");
    
    mainShell.setLayout(new FillLayout());
    
    Button btnClose = new Button(mainShell,SWT.PUSH);
    btnClose.setText("Close");
    btnClose.addListener(SWT.Selection,new Listener() {
    	public void handleEvent(Event arg0) {
    		mainShell.dispose();
    	} 
    });    
    
    mainShell.setSize(300,200);
    mainShell.open();
    
    onTopShell = new Shell(mainShell,SWT.ON_TOP);
    onTopShell.setSize(200,30);
    onTopShell.open();
    
    onTopShell.setLayout(new FillLayout());
    
    labelIter = new Label(onTopShell,SWT.NULL);
    
    Tray tray = display.getSystemTray();
    TrayItem trayItem = new TrayItem(tray,SWT.NULL);
    trayItem.addListener(SWT.DefaultSelection, new Listener() {
      public void handleEvent(Event e) {
       mainShell.setVisible(true); 
      }
    });
    
    mainShell.addListener(SWT.Close, new Listener(){
        public void handleEvent(Event e) {
        	e.doit = false;
          mainShell.setVisible(false);
          onTopShell.setVisible(true);
        }
    });
    
    Thread t = new AEThread("OnTopProblem") {
      public void runSupport() {
       while(updateDisplay()) {
        try { Thread.sleep(100); } catch(Exception ignore) {}   
       }
      }
     };
     
     t.start();
    
    waitForDispose();
    display.dispose();
  
Methods Summary
public static voidmain(java.lang.String[] args)

    new OnTopProblem();
  
public booleanupdateDisplay()

    if(display != null && ! display.isDisposed() ) {
      display.asyncExec(new AERunnable() {
        public void runSupport() {
          iter++;
          labelIter.setText("" + iter);
          onTopShell.setSize(sizes[iter % sizes.length],20);
        }
      });
      return true;
    }
    return false;
  
public voidwaitForDispose()

    while(!mainShell.isDisposed()) {
      if(!display.readAndDispatch())
        display.sleep();
    }