home *** CD-ROM | disk | FTP | other *** search
/ Australian PC Authority 1999 May / may1999.iso / May / JBUILDER / JSAMPLES.Z / Notepad$FileLoader.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-30  |  2.2 KB  |  52 lines

  1. import com.sun.java.swing.JProgressBar;
  2. import com.sun.java.swing.text.AttributeSet;
  3. import com.sun.java.swing.text.BadLocationException;
  4. import com.sun.java.swing.text.Document;
  5. import java.io.File;
  6. import java.io.FileReader;
  7. import java.io.IOException;
  8. import java.io.Reader;
  9.  
  10. class Notepad$FileLoader extends Thread {
  11.    // $FF: synthetic field
  12.    private final Notepad this$0;
  13.    Document doc;
  14.    // $FF: renamed from: f java.io.File
  15.    File field_0;
  16.  
  17.    Notepad$FileLoader(Notepad var1, File var2, Document var3) {
  18.       this.this$0 = var1;
  19.       this.this$0 = var1;
  20.       ((Thread)this).setPriority(4);
  21.       this.field_0 = var2;
  22.       this.doc = var3;
  23.    }
  24.  
  25.    public void run() {
  26.       try {
  27.          Notepad.access$3(this.this$0).removeAll();
  28.          JProgressBar var1 = new JProgressBar();
  29.          var1.setMinimum(0);
  30.          var1.setMaximum((int)this.field_0.length());
  31.          Notepad.access$3(this.this$0).add(var1);
  32.          Notepad.access$3(this.this$0).revalidate();
  33.          FileReader var2 = new FileReader(this.field_0);
  34.          char[] var3 = new char[4096];
  35.  
  36.          int var4;
  37.          while((var4 = ((Reader)var2).read(var3, 0, var3.length)) != -1) {
  38.             this.doc.insertString(this.doc.getLength(), new String(var3, 0, var4), (AttributeSet)null);
  39.             var1.setValue(var1.getValue() + var4);
  40.          }
  41.  
  42.          this.doc.addUndoableEditListener(this.this$0);
  43.          Notepad.access$3(this.this$0).removeAll();
  44.          Notepad.access$3(this.this$0).revalidate();
  45.       } catch (IOException var5) {
  46.          System.err.println(((Throwable)var5).toString());
  47.       } catch (BadLocationException var6) {
  48.          System.err.println(((Throwable)var6).getMessage());
  49.       }
  50.    }
  51. }
  52.