深入浅出JavaSwing程序设计一书的源代码
源代码在线查看: readdoccontent.java
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.swing.text.*;
public class ReadDocContent implements Runnable{
JFrame mainframe;
JTextPane textpane = null;
JInternalFrame innerframe = null;
JFileChooser fileChooser = null;
Thread athread;
SimpleAttributeSet attrset = new SimpleAttributeSet();
public ReadDocContent(JTextPane pane,JFrame mf,JInternalFrame current){
this.mainframe = mf;
this.textpane = pane;
this.innerframe = current;
fileChooser = new JFileChooser();
athread = new Thread(this);
athread.start();
}//end of ReadDocContent()
public void run() {
File file = null;
int result = fileChooser.showOpenDialog(mainframe);
textpane.setText("");
if (result == JFileChooser.APPROVE_OPTION) {
file = fileChooser.getSelectedFile();
innerframe.setTitle("眤匡拒