Loading

Whois Gui Application

Submitted by: 
Language: 
Visitors have accessed this post 2732 times.




  1. import java.awt.*;
  2. import javax.swing.*;
  3. import java.awt.event.*;
  4. import java.net.*;
  5. import java.io.*;
  6.  
  7. public class Whois extends JFrame
  8. {
  9. JTextField t1;
  10. TextArea t2;
  11. JButton b1;
  12. FlowLayout f;
  13. JProgressBar pb;
  14. Timer timer;
  15. final static int interval = 1000;
  16. int cc=0;
  17. Whois(String s)
  18. { super(s);
  19. t1= new JTextField(30);
  20. t2=new TextArea();
  21.  
  22.  
  23. b1=new JButton("Submit");
  24. t2.setEditable(false);
  25. f=new FlowLayout();
  26. pb = new JProgressBar(0,1);
  27. pb.setValue(0);
  28. pb.setStringPainted(true);
  29. pb.setPreferredSize(new Dimension(350,20));
  30. setLayout(f);
  31.  
  32. add(t1);
  33. add(b1);
  34. add(pb);
  35. add(t2);
  36.  
  37. b1.addActionListener(new ButtonListener());
  38. setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  39. setResizable(false);
  40. setLocation(250,250);
  41. resize(400,255);
  42. show();
  43.  
  44.  
  45. timer = new Timer(interval, new ActionListener() {
  46. public void actionPerformed(ActionEvent ae)
  47. {
  48. try{
  49.  
  50. int c;
  51. Socket s=new Socket("whois.geektools.com",43);
  52. InputStream in=s.getInputStream();
  53. OutputStream out=s.getOutputStream();
  54. String args[]=new String[200];
  55. String st=t1.getText();
  56. args[0]=t1.getText();
  57. String str=(args.length==0?st:args[0])+"\n";
  58. byte buf[]=str.getBytes();
  59. out.write(buf);
  60. String st1="";
  61. while((c=in.read())!= -1)
  62. {
  63. st1=st1+(char)c+"";
  64. cc=cc+1;
  65. pb.setValue(cc);
  66.  
  67. }
  68.  
  69. t2.setText(st1);
  70. timer.stop();
  71. b1.setEnabled(true);
  72. s.close();
  73. }
  74. catch(UnknownHostException e)
  75. {
  76. }
  77. catch(IOException e)
  78. {
  79. }
  80.  
  81. }});}
  82.  
  83. class ButtonListener implements ActionListener {
  84. public void actionPerformed(ActionEvent ae) {
  85. b1.setEnabled(false);
  86. pb.setValue(0);
  87. cc=0;
  88. timer.start();
  89. }
  90. }
  91. public static void main(String args[])
  92. {
  93.  
  94.  
  95. SwingUtilities.invokeLater(new Runnable() {
  96.  
  97. @Override
  98. public void run() {
  99.  
  100. try {
  101. UIManager.setLookAndFeel(UIManager.
  102. getSystemLookAndFeelClassName());
  103. } catch (ClassNotFoundException e) {
  104. } catch (InstantiationException e) {
  105. } catch (IllegalAccessException e) {
  106. } catch (UnsupportedLookAndFeelException e) {
  107. }
  108.  
  109. Whois ob = new Whois("Whois");
  110. }
  111. });
  112.  
  113. }
  114. }
Download Code: 

Tags: 

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Add new comment