Advertisement
Guest User

WebLauncherInput

a guest
May 28th, 2020
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 KB | None | 0 0
  1. package test;
  2.  
  3.  
  4. import javax.swing.*;
  5. import java.awt.*;
  6. import java.awt.event.*;
  7. import java.io.IOException;
  8. import java.net.URI;
  9. import java.net.URISyntaxException;
  10.  
  11.  
  12.     public class Test1
  13.     {
  14.     public static void main(String... ar)
  15.     {
  16.     SwingUtilities.invokeLater(new Runnable() {
  17.     public void run()
  18.     {
  19.     new A();
  20.     }
  21.     });
  22.  
  23.     }//Closing the main method
  24.     }//Closing the class A
  25.  
  26.  
  27.     class A implements ActionListener
  28.     {
  29.        
  30.     JButton button;
  31.     JLabel label1;
  32.     JTextField field1;
  33.     JFrame jf;
  34.    
  35.     A()
  36.     {
  37.     jf = new JFrame("Camera Reboot");
  38.     jf.setSize(400,150);
  39.  
  40.     label1= new JLabel("Enter Camera Name (uppercase no dashes)");
  41.  
  42.     field1 = new JTextField(5);
  43.  
  44.     button = new JButton("Reboot");
  45.  
  46.     jf.setLayout(new FlowLayout());
  47.  
  48.     jf.add(label1);
  49.     jf.add(field1);
  50.     jf.add(button);
  51.  
  52.     button.addActionListener(this);
  53.  
  54.     jf.setVisible(true);
  55.     }
  56.  
  57.     public void actionPerformed(ActionEvent ae)
  58.     {
  59.         String input = field1.getText();
  60.    
  61.     if(ae.getActionCommand().equals("Reboot"))
  62.         if (input == "9") {
  63.             try {
  64.                   Desktop desktop = java.awt.Desktop.getDesktop();
  65.                   URI oURL = new URI("http://www.google.com");
  66.                   desktop.browse(oURL);
  67.                 } catch (Exception e) {
  68.                   e.printStackTrace();
  69.                 }
  70.         }
  71.             else { System.out.println("Check camera name");}   
  72.     }
  73.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement