Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.io.BufferedInputStream;
- import java.io.DataInputStream;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.net.URL;
- import javax.swing.JEditorPane;
- import javax.swing.JFrame;
- import javax.swing.JScrollPane;
- public class display{
- private static ActionListener chat;
- public String[] je = null;
- class chat implements ActionListener {
- public void actionPerformed(ActionEvent evt) {
- String dir = System.getProperty("user.dir");
- BufferedInputStream mybuffer = null;
- FileInputStream fileinput = null;
- DataInputStream datainput = null;
- try {
- fileinput = new FileInputStream(dir +"\\chat.html");
- } catch (FileNotFoundException e1) {
- e1.printStackTrace();
- }
- mybuffer = new BufferedInputStream(fileinput);
- datainput = new DataInputStream(mybuffer);
- try {
- while(datainput.available() == 1){
- while(JFrame.EXIT_ON_CLOSE != 1){
- try {
- fileinput.close();
- mybuffer.close();
- datainput.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- public static void main(String[] args) {
- String dir = System.getProperty("user.dir");
- JFrame jf = new JFrame();
- JEditorPane je = new JEditorPane();
- je.setEditable(false);
- JScrollPane js = new JScrollPane();
- js.getViewport().add(je);
- jf.getContentPane().add(js);
- jf.setSize(500,520);
- jf.setVisible(true);
- jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- try{
- URL url = new URL("file:///" +dir +"/chat.html");
- je.setPage(url);
- }
- catch(Exception e){}
- javax.swing.Timer t = new javax.swing.Timer(1000, display.chat);
- t.start();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement