Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.00 KB | None | 0 0
  1. import java.awt.event.ActionEvent;
  2. import java.awt.event.ActionListener;
  3. import java.io.BufferedInputStream;
  4. import java.io.DataInputStream;
  5. import java.io.FileInputStream;
  6. import java.io.FileNotFoundException;
  7. import java.io.IOException;
  8. import java.net.URL;
  9. import javax.swing.JEditorPane;
  10. import javax.swing.JFrame;
  11. import javax.swing.JScrollPane;
  12. public class display{
  13.         private static ActionListener chat;
  14.         public String[] je = null;
  15.         class chat implements ActionListener {
  16.             public void actionPerformed(ActionEvent evt) {
  17.                 String dir = System.getProperty("user.dir");
  18.               BufferedInputStream mybuffer = null;
  19.               FileInputStream fileinput = null;
  20.               DataInputStream datainput = null;
  21.               try {
  22.                 fileinput = new FileInputStream(dir +"\\chat.html");
  23.             } catch (FileNotFoundException e1) {
  24.                 e1.printStackTrace();
  25.             }
  26.               mybuffer = new BufferedInputStream(fileinput);
  27.               datainput = new DataInputStream(mybuffer);
  28.               try {
  29.                 while(datainput.available() == 1){
  30.                       while(JFrame.EXIT_ON_CLOSE != 1){
  31.                       try {
  32.                         fileinput.close();
  33.                       mybuffer.close();
  34.                       datainput.close();
  35.                     } catch (IOException e) {
  36.                         e.printStackTrace();
  37.                     }
  38.                       }
  39.                   }
  40.             } catch (IOException e) {
  41.                 e.printStackTrace();
  42.             }
  43.             }
  44.             }
  45.             public static void main(String[] args) {
  46.               String dir = System.getProperty("user.dir");
  47.               JFrame jf = new JFrame();
  48.               JEditorPane je = new JEditorPane();
  49.               je.setEditable(false);
  50.               JScrollPane js = new JScrollPane();
  51.               js.getViewport().add(je);
  52.               jf.getContentPane().add(js);
  53.               jf.setSize(500,520);
  54.               jf.setVisible(true);
  55.               jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  56.                       try{
  57.                         URL url = new URL("file:///" +dir +"/chat.html");
  58.                         je.setPage(url);
  59.                         }
  60.      catch(Exception e){}
  61.         javax.swing.Timer t = new javax.swing.Timer(1000, display.chat);
  62.         t.start();
  63.         }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement