home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Java / JDesignerPro / Jdp3_0.exe / data1.cab / Program_Files / CompDragAndDrop.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-04-09  |  3.7 KB  |  129 lines

  1. import java.awt.BorderLayout;
  2. import java.awt.Button;
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Event;
  6. import java.awt.GridLayout;
  7. import java.awt.Panel;
  8. import java.awt.TextArea;
  9.  
  10. public class CompDragAndDrop extends JDPClassLayout {
  11.    JDPUser user;
  12.    JDPJagg jaggSQL;
  13.    JDPPopupMessage popuppanel;
  14.    JDPMaskEdit JDPMaskEditMain;
  15.    String moduleParameter;
  16.    Panel Main;
  17.    JDPDragItem DragAndDrop1;
  18.    JDPChiselFramePanel ChiselPanel1;
  19.    Panel Panel2;
  20.    Panel Panel1;
  21.    Button Button1;
  22.    Button Button2;
  23.    Button Button3;
  24.    Button Button4;
  25.    Button Button5;
  26.    TextArea TextArea1;
  27.  
  28.    public void InitClass(JDPUser var1, Panel var2, String var3) {
  29.       this.user = var1;
  30.       this.moduleParameter = var3;
  31.       this.jaggSQL = new JDPJagg(var1.jaggPath);
  32.       ((Container)this).setLayout(new BorderLayout());
  33.       this.popuppanel = new JDPPopupMessage(var1, this);
  34.       ((Container)this).add(this.popuppanel);
  35.       this.JDPMaskEditMain = new JDPMaskEdit();
  36.       this.Main = new Panel();
  37.       this.DragAndDrop1 = new JDPDragItem(var1.getJDPUser(), this.Main);
  38.       this.ChiselPanel1 = new JDPChiselFramePanel(var1, "Component Drag and Drop demo");
  39.       this.Panel2 = new Panel();
  40.       this.Panel1 = new Panel();
  41.       this.Button1 = new Button("Button1");
  42.       this.Button2 = new Button("Button2");
  43.       this.Button3 = new Button("Button3");
  44.       this.Button4 = new Button("Button4");
  45.       this.Button5 = new Button("Button5");
  46.       this.TextArea1 = new TextArea("", 3, 20);
  47.       this.Main.setLayout(new BorderLayout());
  48.       ((Container)this).add("Center", this.Main);
  49.       this.Main.add("Center", this.DragAndDrop1);
  50.       this.Main.add("Center", this.ChiselPanel1);
  51.       this.ChiselPanel1.add("Center", this.Panel2);
  52.       this.Panel2.setLayout(new BorderLayout());
  53.       this.Panel2.add("North", this.Panel1);
  54.       this.Panel1.setLayout(new GridLayout(1, 5));
  55.       this.Panel1.add(this.Button1);
  56.       this.Panel1.add(this.Button2);
  57.       this.Panel1.add(this.Button3);
  58.       this.Panel1.add(this.Button4);
  59.       this.Panel1.add(this.Button5);
  60.       this.Panel2.add("Center", this.TextArea1);
  61.       this.Button1.disable();
  62.       this.Button1.disable();
  63.       this.Button2.disable();
  64.       this.Button2.disable();
  65.       this.Button3.disable();
  66.       this.Button3.disable();
  67.       this.Button4.disable();
  68.       this.Button4.disable();
  69.       this.Button5.disable();
  70.       this.Button5.disable();
  71.       this.TextArea1.setText("Drag a button and drop it on this textarea");
  72.       this.InitComponents();
  73.       var1.gParm.addElement(this);
  74.    }
  75.  
  76.    public boolean handleEvent(Event var1) {
  77.       switch (var1.id) {
  78.          case 502:
  79.             if (var1.target.equals(this.Panel1)) {
  80.                if (this.DragAndDrop1.isVisible()) {
  81.                   this.DragAndDrop1.postEvent(var1);
  82.                }
  83.  
  84.                return true;
  85.             }
  86.  
  87.             return false;
  88.          case 503:
  89.          case 504:
  90.          case 505:
  91.             this.popuppanel.postEvent(var1);
  92.             return false;
  93.          case 506:
  94.             if (var1.target.equals(this.Panel1)) {
  95.                this.DragAndDrop1.postEvent(var1);
  96.                return true;
  97.             }
  98.  
  99.             return false;
  100.          case 1001:
  101.             if (var1.target.equals(this.DragAndDrop1)) {
  102.                Component var2 = this.DragAndDrop1.getDraggedComponent();
  103.                if (var2 != null && var2 instanceof Button) {
  104.                   this.TextArea1.setText(((Button)var2).getLabel());
  105.                }
  106.  
  107.                if (var2 != null && var2 instanceof JDPButton) {
  108.                   this.TextArea1.setText(((JDPButton)var2).getLabel());
  109.                }
  110.  
  111.                return true;
  112.             }
  113.  
  114.             return false;
  115.          default:
  116.             return false;
  117.       }
  118.    }
  119.  
  120.    public void InitComponents() {
  121.       this.DragAndDrop1.addDragComponent(this.Button1, this.Panel1, "DragButton");
  122.       this.DragAndDrop1.addDragComponent(this.Button2, this.Panel1, "DragButton");
  123.       this.DragAndDrop1.addDragComponent(this.Button3, this.Panel1, "DragButton");
  124.       this.DragAndDrop1.addDragComponent(this.Button4, this.Panel1, "DragButton");
  125.       this.DragAndDrop1.addDragComponent(this.Button5, this.Panel1, "DragButton");
  126.       this.DragAndDrop1.addDropComponent(this.TextArea1, this.Panel2, "DragButton", "Drop Here");
  127.    }
  128. }
  129.