Ejemplo n.º 1
0
  public AndItem(boolean preview, Window w) {
    super(preview);
    this.w = w;
    FlowLayout fl = new FlowLayout(FlowLayout.CENTER, 1, 1);
    this.setLayout(fl);
    lefthand = new ParameterSlot(Parameter.Condition, "lefthand", preview, w);
    this.add(lefthand);
    JLabel la = new JLabel(" AND ");
    this.add(la);
    righthand = new ParameterSlot(Parameter.Condition, "righthand", preview, w);
    this.add(righthand);
    ToolTipItem tti = new ToolTipItem();
    tti.setToolTipText(
        "<html>This is an if item, if the specified condition <br> is fulfilled, the following block will be executed</html>");
    this.add(tti);
    this.setBackground(new Color(108, 45, 199));
    this.setBorder(BorderFactory.createLineBorder(Color.black));
    if (preview) {
      DragSource ds = new DragSource();
      ParameterDragGestureListener pdgl = new ParameterDragGestureListener();
      ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY, pdgl);
      ds.addDragSourceMotionListener(pdgl);
      ds.addDragSourceListener(
          new DragSourceListener() {
            @Override
            public void dropActionChanged(DragSourceDragEvent dsde) {}

            @Override
            public void dragOver(DragSourceDragEvent dsde) {}

            @Override
            public void dragExit(DragSourceEvent dse) {}

            @Override
            public void dragEnter(DragSourceDragEvent dsde) {}

            @Override
            public void dragDropEnd(DragSourceDropEvent dsde) {
              ImageMover.stop();
            }
          });
    }
  }
Ejemplo n.º 2
0
  public VariablePanel(String variableName, boolean preview, Window w) {
    super(preview);
    this.w = w;
    if (preview) {
      w.spellItems.put(variableName, this);
    }
    this.s = variableName;
    JLabel jl = new JLabel(variableName);
    this.setLayout(new BorderLayout());
    this.add(jl, BorderLayout.CENTER);
    this.setBorder(BorderFactory.createLineBorder(Color.black));
    this.setBackground(Color.lightGray);
    DragSource ds = new DragSource();
    VariableDragGestureListener pdgl = new VariableDragGestureListener();
    ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY, pdgl);
    ds.addDragSourceMotionListener(pdgl);
    ds.addDragSourceListener(
        new DragSourceListener() {
          @Override
          public void dropActionChanged(DragSourceDragEvent dsde) {}

          @Override
          public void dragOver(DragSourceDragEvent dsde) {}

          @Override
          public void dragExit(DragSourceEvent dse) {}

          @Override
          public void dragEnter(DragSourceDragEvent dsde) {}

          @Override
          public void dragDropEnd(DragSourceDropEvent dsde) {
            ImageMover.stop();
          }
        });
  }