Klasa okno :
public class okno extends JFrame{
JTextArea jtout;
public JFrame jf;
okno(){
JTextField jt1, jt2;
String disp = "";
//TextHandler handler = null;
JFrame jf = new JFrame("oooo");
Container kontener = jf.getContentPane();
kontener.setLayout(new FlowLayout());
JButton jb = new JButton("Uo");
JButton jb1 = new JButton("Wo");
JButton jb2=new JButton("Zao");
jt2 = new JTextField("Program Uruchomi aplikacje R", 20);
jt2.setEditable(false);
jtout = new JTextArea(20, 60);
jtout.setCaretPosition(jtout.getDocument().getLength());
jtout.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
JScrollPane scroller = new JScrollPane(jtout);
scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
jf.setLocation(200,200);
jf.setSize(800,500);
jf.setDefaultCloseOperation(jf.EXIT_ON_CLOSE);
jf.add(jt2);
//jf.add(jt1);
jf.add(jb);
jf.add(jb1);
jf.add(jb2);
jf.add(scroller);
kontener.setBackground(Color.gray);
kontener.setForeground(Color.YELLOW);
jf.setVisible(true);
jf.validate();
jb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
System.out.println("naciśnięte - Uruchom_R");
jtout.append("LICZY czekaj ..."); <ort>I TO SIE NIE POKAZUJE ODRAZU!!</ort>
Uruchom uruchom = new Uruchom();
Thread watek1 = new Thread(uruchom);
watek1.run();
//odczyt_txt();
// odczyt_txt tekst = new odczyt_txt();
// Thread watek2 = new Thread(tekst);
// watek2.run();
}
});
jb1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
System.out.println("naciśnięte - Wyświetl haetmapę");
//new pobraz(sciezka);
System.out.println("CZEKAM 1 sekunde "+"\n");
pobraz obr = new pobraz(sciezka);
Thread watek = new Thread(obr);
watek.run();
}
});
jb2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
System.exit(0);
}
});
}
}
a odczyt jest w klasie:
public class odczyt_txt extends okno implements Runnable {
public void run(){
try{
Thread.sleep(1000);
}catch(InterruptedException exc) {return;}
}
public odczyt_txt() {
try{
BufferedReader in = new BufferedReader(new FileReader("C:/..../wynik.txt"));
String str;
while ((str = in.readLine()) != null) {
jtout.append(str+"\n");
}
in.close();
}catch (IOException e) {}
}
}