/* WARNING: THIS METHOD WILL BE REGENERATED. */
 private java.awt.Dialog getDialog1() {
   if (ivjDialog1 == null) {
     try {
       ivjDialog1 = new java.awt.Dialog(new java.awt.Frame());
       ivjDialog1.setName("Dialog1");
       ivjDialog1.setLayout(new java.awt.BorderLayout());
       ivjDialog1.setBounds(65, 335, 204, 95);
       getDialog1().add(getContentsPane(), "Center");
       // user code begin {1}
       // user code end
     } catch (java.lang.Throwable ivjExc) {
       // user code begin {2}
       // user code end
       handleException(ivjExc);
     }
   }
   return ivjDialog1;
 }
Ejemplo n.º 2
0
  void showWarning(Frame frame, String warning) {
    warningDialog = new Dialog(frame, "警告", true);
    warningDialog.setSize(200, 100);
    warningDialog.setLayout(new FlowLayout());
    warningDialog.setResizable(false);
    warningDialog.setLocationRelativeTo(frame);

    warningText = new Label(warning);
    warningButton = new Button("确认");

    warningDialog.add(warningText);
    warningDialog.add(warningButton);

    warningDialog.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            warningDialog.setVisible(false);
            warningDialog.dispose();
          }
        });

    warningButton.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            int keyCode = e.getKeyCode();

            if (keyCode == KeyEvent.VK_ENTER) {
              warningDialog.setVisible(false);
              warningDialog.dispose();
            }
          }
        });

    warningButton.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            warningDialog.setVisible(false);
            warningDialog.dispose();
          }
        });

    warningDialog.setVisible(true);
  }
Ejemplo n.º 3
0
  private void openDialog(String title, String string) {
    // TODO Auto-generated method stub
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension dialogSize = new Dimension(200, 120);
    final Dialog dialog = new Dialog((Frame) getParent(), title);
    dialog.setSize(dialogSize);
    dialog.setLayout(null);
    dialog.setResizable(true);

    Label label = new Label(string);
    label.setSize(400, 50);
    label.setLocation(20, 30);
    dialog.add(label, "Center");

    Button enter = new Button("Return");
    enter.setSize(50, 25);
    enter.setLocation(75, 80);
    enter.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            // TODO Auto-generated method stub
            dialog.dispose();
          }
        });
    dialog.add(enter);

    dialog.setLocation(
        (screenSize.width - dialogSize.width + 50) / 2,
        (screenSize.height - dialogSize.height + 40) / 2);
    dialog.setModal(true);
    dialog.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent arg0) {
            // TODO Auto-generated method stub
            dialog.dispose();
          }
        });
    dialog.setVisible(true);
  }
Ejemplo n.º 4
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.º 5
0
 public static void main(String[] args) {
   Common.initRobot();
   final JButton start = new JButton("start");
   start.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent ae) {
           act0();
           Common.robot.delay(500);
           act1();
           Common.robot.delay(1000);
           act2();
           //				Common.robot.delay(500);
           //				act3();
           //				Common.robot.delay(500);
           //				act4();
           //				Common.robot.delay(500);
           //				act5();
           //				Common.robot.delay(500);
           //				act6();
           //				Common.robot.delay(500);
           //				act7();
           start.setText("stopped");
         }
       });
   dashBoard.setLayout(new FlowLayout());
   dashBoard.add(start);
   dashBoard.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
   dashBoard.setLocation(new Point(10, 650));
   dashBoard.setSize(300, 70);
   dashBoard.setAlwaysOnTop(true);
   dashBoard.setVisible(true);
 }
Ejemplo n.º 6
0
  public void makeTheWarning(
      int X,
      int Y,
      int width,
      int height,
      Color fg,
      Color bg,
      String title,
      String text,
      boolean oneLine,
      Frame frame) {

    Font warnFont = new java.awt.Font("SanSerif", Font.BOLD, 12);
    FontMetrics warnFontMetrics = getFontMetrics(warnFont);

    // Create Dialog window with modal blocking set to true.
    // Make final so inner class below can access it.

    final Dialog mww = new Dialog(frame, title, true);
    mww.setLayout(new BorderLayout());
    mww.setSize(width, height);
    mww.setLocation(X, Y);

    // Use Label for 1-line warning

    if (oneLine) {
      Label hT = new Label(text, Label.CENTER);
      hT.setForeground(fg);
      hT.setBackground(bg);
      hT.setFont(warnFont);
      mww.add("Center", hT);

      // Use TextArea for multiline warning

    } else {
      TextArea hT = new TextArea("", height, width, TextArea.SCROLLBARS_NONE);
      hT.setEditable(false);
      hT.setForeground(fg);
      hT.setBackground(bg); // no effect once setEditable (false)?
      hT.setFont(warnFont);
      mww.add("Center", hT);
      hT.appendText(text);
    }

    mww.setTitle(title);

    // Add dismiss button

    Panel botPanel = new Panel();
    botPanel.setBackground(Color.lightGray);
    Label label1 = new Label();
    Label label2 = new Label();

    Button dismissButton = new Button("Dismiss");
    botPanel.add(label1);
    botPanel.add(dismissButton);
    botPanel.add(label2);

    // Add inner class event handler for Dismiss button.  This must be
    // added to the dismissButton before botPanel is added to mww.

    dismissButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            mww.hide();
            mww.dispose();
          }
        });

    mww.add("South", botPanel);

    // Add window closing button (inner class)

    mww.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            mww.hide();
            mww.dispose();
          }
        });

    mww.show(); // Note that this show must come after all the above
    // additions; otherwise they are not added before the
    // window is displayed.
  }
Ejemplo n.º 7
0
  public static void main(final String[] args) throws Exception {
    /* Make sure AirReceiver shuts down gracefully */
    Runtime.getRuntime()
        .addShutdownHook(
            new Thread(
                new Runnable() {
                  @Override
                  public void run() {
                    onShutdown();
                  }
                }));

    /* Create about dialog */
    final Dialog aboutDialog = new Dialog((Dialog) null);
    final GridBagLayout aboutLayout = new GridBagLayout();
    aboutDialog.setLayout(aboutLayout);
    aboutDialog.setVisible(false);
    aboutDialog.setTitle("About AirReceiver");
    aboutDialog.setResizable(false);
    {
      /* Message */
      final TextArea title = new TextArea(AboutMessage.split("\n").length + 1, 64);
      title.setText(AboutMessage);
      title.setEditable(false);
      final GridBagConstraints titleConstraints = new GridBagConstraints();
      titleConstraints.gridx = 1;
      titleConstraints.gridy = 1;
      titleConstraints.fill = GridBagConstraints.HORIZONTAL;
      titleConstraints.insets = new Insets(0, 0, 0, 0);
      aboutLayout.setConstraints(title, titleConstraints);
      aboutDialog.add(title);
    }
    {
      /* Done button */
      final Button aboutDoneButton = new Button("Done");
      aboutDoneButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent evt) {
              aboutDialog.setVisible(false);
            }
          });
      final GridBagConstraints aboutDoneConstraints = new GridBagConstraints();
      aboutDoneConstraints.gridx = 1;
      aboutDoneConstraints.gridy = 2;
      aboutDoneConstraints.anchor = GridBagConstraints.PAGE_END;
      aboutDoneConstraints.fill = GridBagConstraints.NONE;
      aboutDoneConstraints.insets = new Insets(0, 0, 0, 0);
      aboutLayout.setConstraints(aboutDoneButton, aboutDoneConstraints);
      aboutDialog.add(aboutDoneButton);
    }
    aboutDialog.setVisible(false);
    aboutDialog.setLocationByPlatform(true);
    aboutDialog.pack();

    /* Create tray icon */
    final URL trayIconUrl = AirReceiver.class.getClassLoader().getResource("icon_32.png");
    final TrayIcon trayIcon = new TrayIcon((new ImageIcon(trayIconUrl, "AirReceiver").getImage()));
    trayIcon.setToolTip("AirReceiver");
    trayIcon.setImageAutoSize(true);
    final PopupMenu popupMenu = new PopupMenu();
    final MenuItem aboutMenuItem = new MenuItem("About");
    aboutMenuItem.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent evt) {
            aboutDialog.setLocationByPlatform(true);
            aboutDialog.setVisible(true);
          }
        });
    popupMenu.add(aboutMenuItem);
    final MenuItem exitMenuItem = new MenuItem("Quit");
    exitMenuItem.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent evt) {
            onShutdown();
            System.exit(0);
          }
        });
    popupMenu.add(exitMenuItem);
    trayIcon.setPopupMenu(popupMenu);
    SystemTray.getSystemTray().add(trayIcon);

    /* Create AirTunes RTSP server */
    final ServerBootstrap airTunesRtspBootstrap =
        new ServerBootstrap(new NioServerSocketChannelFactory(ExecutorService, ExecutorService));
    airTunesRtspBootstrap.setPipelineFactory(new RaopRtspPipelineFactory());
    airTunesRtspBootstrap.setOption("reuseAddress", true);
    airTunesRtspBootstrap.setOption("child.tcpNoDelay", true);
    airTunesRtspBootstrap.setOption("child.keepAlive", true);
    s_allChannels.add(
        airTunesRtspBootstrap.bind(
            new InetSocketAddress(Inet4Address.getByName("0.0.0.0"), AirtunesServiceRTSPPort)));
    s_logger.info("Launched RTSP service on port " + AirtunesServiceRTSPPort);

    /* Create mDNS responders. */
    synchronized (s_jmDNSInstances) {
      for (final NetworkInterface iface :
          Collections.list(NetworkInterface.getNetworkInterfaces())) {
        if (iface.isLoopback()) continue;
        if (iface.isPointToPoint()) continue;
        if (!iface.isUp()) continue;

        for (final InetAddress addr : Collections.list(iface.getInetAddresses())) {
          if (!(addr instanceof Inet4Address) && !(addr instanceof Inet6Address)) continue;

          try {
            /* Create mDNS responder for address */
            final JmDNS jmDNS = JmDNS.create(addr, HostName + "-jmdns");
            s_jmDNSInstances.add(jmDNS);

            /* Publish RAOP service */
            final ServiceInfo airTunesServiceInfo =
                ServiceInfo.create(
                    AirtunesServiceType,
                    HardwareAddressString + "@" + HostName + " (" + iface.getName() + ")",
                    AirtunesServiceRTSPPort,
                    0 /* weight */,
                    0 /* priority */,
                    AirtunesServiceProperties);
            jmDNS.registerService(airTunesServiceInfo);
            s_logger.info(
                "Registered AirTunes service '" + airTunesServiceInfo.getName() + "' on " + addr);
          } catch (final Throwable e) {
            s_logger.log(Level.SEVERE, "Failed to publish service on " + addr, e);
          }
        }
      }
    }
  }
Ejemplo n.º 8
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 = "";
      }
    }
  }