Ejemplo n.º 1
0
  /* DESCRIPTION
   *	Connect button event method,
   *  Call the connect method
   * ARGUMENTS
   *	ip - Peer IP variable, integer
   *	port - Peer Port variable, integer
   *  dlg - Warning dialog, Dialog
   *  msg - Warning message, Label
   *  ok - confirm button on the warning dialog
   */
  protected void connect_btnMouseClicked(MouseEvent evt) {

    ip = ip_text.getText();
    port = Integer.parseInt(port_text.getText());

    final Dialog dlg = new Dialog(this, "Warning!");
    dlg.setSize(300, 100);
    Label msg = new Label("Input the correct Ip address and Port number.", Label.CENTER);
    Button ok = new Button("OK");

    dlg.setLayout(new FlowLayout());
    dlg.add(msg);
    dlg.add(ok);

    ok.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            dlg.dispose();
          }
        });

    // if user didn't a peer ip, it shows alarm dialog
    if (ip.equals("")) {
      dlg.setVisible(true);
    }

    // Call the connect method
    else {

      try {
        connect();

      } catch (Exception e) {

        dlg.setVisible(true);
        System.out.println(e);
      }
    }
  }
Ejemplo n.º 2
0
    @NotNull
    @SuppressWarnings("UseJBColor")
    protected Dialog getOrCreatePickerDialog() {
      Dialog pickerDialog = getPickerDialog();
      if (pickerDialog == null) {
        pickerDialog = super.getOrCreatePickerDialog();
        pickerDialog.addMouseListener(
            new MouseAdapter() {
              @Override
              public void mouseExited(MouseEvent event) {
                updatePipette();
              }
            });
        pickerDialog.addMouseMotionListener(
            new MouseAdapter() {
              @Override
              public void mouseMoved(MouseEvent e) {
                updatePipette();
              }
            });
        pickerDialog.addFocusListener(
            new FocusAdapter() {
              @Override
              public void focusLost(FocusEvent e) {
                if (e.isTemporary()) {
                  pickAndClose();
                } else {
                  cancelPipette();
                }
              }
            });

        pickerDialog.setSize(DIALOG_SIZE, DIALOG_SIZE);
        myMaskImage = UIUtil.createImage(SIZE, SIZE, BufferedImage.TYPE_INT_ARGB);
        Graphics2D maskG = myMaskImage.createGraphics();
        maskG.setColor(Color.BLUE);
        maskG.fillRect(0, 0, SIZE, SIZE);

        maskG.setColor(Color.RED);
        maskG.setComposite(AlphaComposite.SrcOut);
        maskG.fillRect(0, 0, SIZE, SIZE);
        maskG.dispose();

        myPipetteImage =
            UIUtil.createImage(
                AllIcons.Ide.Pipette.getIconWidth(),
                AllIcons.Ide.Pipette.getIconHeight(),
                BufferedImage.TYPE_INT_ARGB);
        Graphics2D graphics = myPipetteImage.createGraphics();
        //noinspection ConstantConditions
        AllIcons.Ide.Pipette.paintIcon(null, graphics, 0, 0);
        graphics.dispose();

        myImage =
            myParent
                .getGraphicsConfiguration()
                .createCompatibleImage(SIZE, SIZE, Transparency.TRANSLUCENT);

        myGraphics = (Graphics2D) myImage.getGraphics();
        myGraphics.setRenderingHint(
            RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
      }

      return pickerDialog;
    }
Ejemplo n.º 3
0
  /* DESCRIPTION
   *	Send button event method,
   *  Send the data to socket
   * ARGUMENTS
   *	sendstr - send data, String
   *  hexstr -  send data converted to hex, String
   *  dlg - Warning dialog, Dialog
   *  msg - Warning message, Label
   *  ok - confirm button on the warning dialog
   *  pw - output stream
   */
  protected void send_btnMouseClicked(MouseEvent evt) {

    String sendstr = "";
    String hexstr = "";

    // if the user click the send button when the socket is close, it shows warning dialog
    if (sock == null) {

      final Dialog dlg = new Dialog(this, "Warning!");
      dlg.setSize(300, 100);
      Label msg = new Label("Connect the socket, first.", Label.CENTER);
      Button ok = new Button("OK");

      dlg.setLayout(new FlowLayout());
      dlg.add(msg);
      dlg.add(ok);

      ok.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              dlg.dispose();
            }
          });

      dlg.setVisible(true);
    }

    // send the data to socket
    else {

      sendstr = send_text.getText();

      if (sendstr.equals("") && cr_check.isSelected() == false && lf_check.isSelected() == false) {

        final Dialog dlg = new Dialog(this, "Warning!");
        dlg.setSize(300, 100);
        Label msg = new Label("Insert the message", Label.CENTER);
        Button ok = new Button("OK");

        dlg.setLayout(new FlowLayout());
        dlg.add(msg);
        dlg.add(ok);

        ok.addMouseListener(
            new MouseAdapter() {
              public void mouseClicked(MouseEvent e) {
                dlg.dispose();
              }
            });

        dlg.setVisible(true);
      } else {
        pw.print(sendstr);

        if (cr_check.isSelected()) {
          pw.print("\r");
          sendstr = sendstr + "\r";
        }
        if (lf_check.isSelected()) {
          pw.print("\n");
          sendstr = sendstr + "\n";
        }
        pw.flush();

        hexstr = StringtoHex(sendstr);

        data.append("Send data : ");
        data.append(hexstr + " | ");
        data.append(sendstr);
        data.append("\n");

        send_text.setText("");
        sendstr = "";
      }
    }
  }