1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
   |  
 
class C1 extends Composite {
   text t1=null;
   text t2=null;
   text t3=null;
   String id="";
 
   C1(Composite parent, String id) {
      super(parent,SWT.NONE);
      this.id=id;
      initialize();
   }
 
   void initialize() {
      t1 = new Text(this,...);
      t1.addFocusListener(new FocusListener() {
         public void focusLost(org.eclipse.swt.events.FocusEvent e) {
            System.out.println("t1 lost");
         }
         public void focusGained(FocusEvent e) {
            System.out.println("t1 gained");
         }
      });
 
      t2 = new Text(this,...);
      t2.addFocusListener(new FocusListener() {
         public void focusLost(org.eclipse.swt.events.FocusEvent e) {
            System.out.println("t2 lost");
         }
         public void focusGained(FocusEvent e) {
            System.out.println("t2 gained");
         }
      });
 
      t3 = new Text(this,...);
      t3.addFocusListener(new FocusListener() {
         public void focusLost(org.eclipse.swt.events.FocusEvent e) {
            System.out.println("t3 lost");
         }
         public void focusGained(FocusEvent e) {
            System.out.println("t3 gained");
         }
      });
 
      Control [] tl = { t1, t2, t3 };
      this.setTabList(tl);
      this.addFocusListener(new FocusListener() {
         public void focusLost(org.eclipse.swt.events.FocusEvent e) {
            System.out.println("C" + id + " lost");
         }
         public void focusGained(FocusEvent e) {
            System.out.println("C" + id + " gained");
         }
      });
   }
}
 
 
class application {
 
void createSShell() {
      Shell s1 = new Shell() // je simplifie...
      c1 = new C1(s1,"1");
      c2 = new C1(s1,"2"); 
      c3 = new C1(s1,"3")
      ...
      Control [] tl = { c1, c2, c3 };
      this.setTabList(tl);
   }
} | 
Partager