Beispiel #1
0
 /**
  * Called by the browser or applet viewer to inform this JApplet that it has been loaded into the
  * system. It is always called before the first time that the start method is called.
  */
 public void init() {
   // this is a workaround for a security conflict with some browsers
   // including some versions of Netscape & Internet Explorer which do
   // not allow access to the AWT system event queue which JApplets do
   // on startup to check access. May not be necessary with your browser.
   JRootPane rootPane = this.getRootPane();
   rootPane.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);
   setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10));
   b1 = new Button("Choose this card");
   add(b1);
   b1.addActionListener(this);
   // provide any initialisation necessary for your JApplet
 }
Beispiel #2
0
  public GuiClient() {
    setLayout(new FlowLayout());

    /** ** We define the textfields and buttons****** */
    lbIP = new Label("Enter the IP address of the server: "); // Construct Label
    add(lbIP);

    tfIP = new TextField(110); // Construct TextField
    add(tfIP); // "super" Frame adds TextField
    tfIP.setText("10.16.31.163"); // Set a default value

    tfIP.addActionListener(this);
    // Hitting Enter on TextField fires ActionEvent
    // tfInput (TextField) registers this instance as ActionEvent listener

    lblInput = new Label("Enter a link below: ");
    add(lblInput);

    tfInput = new TextField(110);
    add(tfInput);
    tfInput.setText("http://vodlocker.com/budq9rt5wt0e");
    tfInput.addActionListener(this);

    lblOutput = new Label("The download link is below: ");
    add(lblOutput);

    tfOutput = new TextField(110);
    tfOutput.setEditable(false); // read-only
    add(tfOutput);

    /** ************Stream************** */
    Butstr = new Button("Stream"); // construct Button
    add(Butstr); // "super" Frame adds Button

    Butstr.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            streamvidlink(getvidlink());
            tfOutput.setText("The video is being streamed");
          }
        });

    /** ************Download************** */
    Butdow = new Button("Download");
    add(Butdow);

    Butdow.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            downvidlink(getvidlink());
            tfOutput.setText("The video is being downloaded");
          }
        });

    /** ************QR CODE************** */
    Butqr = new Button("Qr Code");
    add(Butqr);

    Butqr.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // we load the qrvidlink() function that saves the image locally
            qrvidlink();
            try {
              // we display the image that is saved
              Runtime.getRuntime().exec("display qrcode.png");
              tfOutput.setText("The Qr code will be generated");
            } catch (Exception ex) {
              System.out.println("Qr Code failed: " + ex);
            }
          }
        });

    setTitle("Client"); // "super" Frame sets title
    setSize(900, 400); // "super" Frame sets initial window size
    setVisible(true); // "super" Frame shows
  }