importjava.awt.Color;importjava.io.BufferedReader;importjava.io.FileReader;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JScrollPane;publicclasstest...
import java.awt.Color;
import java.io.BufferedReader;
import java.io.FileReader;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
public class test018 extends JFrame{
JLabel jl=new JLabel();
JScrollPane jsp=new JScrollPane(jl);
{
this.add(jsp);
jsp.setBounds(100, 100, 400, 400);
}
public test018()throws Exception {
this.setBounds(300, 100, 600, 600);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setLayout(null);
this.getContentPane().setBackground(Color.DARK_GRAY);
this.setVisible(true);
liu();
}
void liu() throws Exception{
FileReader fr=new FileReader("E:\\2.txt");
BufferedReader br=new BufferedReader(fr);
String str;
while((str=br.readLine())!=null){
jl.setText(str);
System.out.println(str);
}
br.close();
fr.close();
}
public static void main(String[] args)throws Exception {
new test018();
}
}
展开