home *** CD-ROM | disk | FTP | other *** search
- import java.awt.BorderLayout;
- import java.awt.Button;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Event;
- import java.awt.GridLayout;
- import java.awt.Panel;
- import java.awt.TextArea;
-
- public class CompDragAndDrop extends JDPClassLayout {
- JDPUser user;
- JDPJagg jaggSQL;
- JDPPopupMessage popuppanel;
- JDPMaskEdit JDPMaskEditMain;
- String moduleParameter;
- Panel Main;
- JDPDragItem DragAndDrop1;
- JDPChiselFramePanel ChiselPanel1;
- Panel Panel2;
- Panel Panel1;
- Button Button1;
- Button Button2;
- Button Button3;
- Button Button4;
- Button Button5;
- TextArea TextArea1;
-
- public void InitClass(JDPUser var1, Panel var2, String var3) {
- this.user = var1;
- this.moduleParameter = var3;
- this.jaggSQL = new JDPJagg(var1.jaggPath);
- ((Container)this).setLayout(new BorderLayout());
- this.popuppanel = new JDPPopupMessage(var1, this);
- ((Container)this).add(this.popuppanel);
- this.JDPMaskEditMain = new JDPMaskEdit();
- this.Main = new Panel();
- this.DragAndDrop1 = new JDPDragItem(var1.getJDPUser(), this.Main);
- this.ChiselPanel1 = new JDPChiselFramePanel(var1, "Component Drag and Drop demo");
- this.Panel2 = new Panel();
- this.Panel1 = new Panel();
- this.Button1 = new Button("Button1");
- this.Button2 = new Button("Button2");
- this.Button3 = new Button("Button3");
- this.Button4 = new Button("Button4");
- this.Button5 = new Button("Button5");
- this.TextArea1 = new TextArea("", 3, 20);
- this.Main.setLayout(new BorderLayout());
- ((Container)this).add("Center", this.Main);
- this.Main.add("Center", this.DragAndDrop1);
- this.Main.add("Center", this.ChiselPanel1);
- this.ChiselPanel1.add("Center", this.Panel2);
- this.Panel2.setLayout(new BorderLayout());
- this.Panel2.add("North", this.Panel1);
- this.Panel1.setLayout(new GridLayout(1, 5));
- this.Panel1.add(this.Button1);
- this.Panel1.add(this.Button2);
- this.Panel1.add(this.Button3);
- this.Panel1.add(this.Button4);
- this.Panel1.add(this.Button5);
- this.Panel2.add("Center", this.TextArea1);
- this.Button1.disable();
- this.Button1.disable();
- this.Button2.disable();
- this.Button2.disable();
- this.Button3.disable();
- this.Button3.disable();
- this.Button4.disable();
- this.Button4.disable();
- this.Button5.disable();
- this.Button5.disable();
- this.TextArea1.setText("Drag a button and drop it on this textarea");
- this.InitComponents();
- var1.gParm.addElement(this);
- }
-
- public boolean handleEvent(Event var1) {
- switch (var1.id) {
- case 502:
- if (var1.target.equals(this.Panel1)) {
- if (this.DragAndDrop1.isVisible()) {
- this.DragAndDrop1.postEvent(var1);
- }
-
- return true;
- }
-
- return false;
- case 503:
- case 504:
- case 505:
- this.popuppanel.postEvent(var1);
- return false;
- case 506:
- if (var1.target.equals(this.Panel1)) {
- this.DragAndDrop1.postEvent(var1);
- return true;
- }
-
- return false;
- case 1001:
- if (var1.target.equals(this.DragAndDrop1)) {
- Component var2 = this.DragAndDrop1.getDraggedComponent();
- if (var2 != null && var2 instanceof Button) {
- this.TextArea1.setText(((Button)var2).getLabel());
- }
-
- if (var2 != null && var2 instanceof JDPButton) {
- this.TextArea1.setText(((JDPButton)var2).getLabel());
- }
-
- return true;
- }
-
- return false;
- default:
- return false;
- }
- }
-
- public void InitComponents() {
- this.DragAndDrop1.addDragComponent(this.Button1, this.Panel1, "DragButton");
- this.DragAndDrop1.addDragComponent(this.Button2, this.Panel1, "DragButton");
- this.DragAndDrop1.addDragComponent(this.Button3, this.Panel1, "DragButton");
- this.DragAndDrop1.addDragComponent(this.Button4, this.Panel1, "DragButton");
- this.DragAndDrop1.addDragComponent(this.Button5, this.Panel1, "DragButton");
- this.DragAndDrop1.addDropComponent(this.TextArea1, this.Panel2, "DragButton", "Drop Here");
- }
- }
-