Whois Gui Application

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

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

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.