Originally Posted by
jps
I don't see where the text area is ever added to the frame.
I don't see where the frame is ever set visible.
It is okay to post code snippets, (even encouraged to do so), but you should include enough code to get the complete picture. (In this case the code that adds ta to jframe and where jframe is setVisible)
More of the code:
JFrame jframe = new JFrame ();
jframe.setVisible (true);
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTextArea ta = new JTextArea(20,40);
jframe.getContentPane().add(new JScrollPane(ta));
jframe.pack();
if (args[2].equals ("bi")) {
try {
FileReader fr = new FileReader ("indice.txt");
BufferedReader br = new BufferedReader (fr);
System.out.println ("O arquivo-indice existe!");
ta.setText ("TESTE1");
ta.setText ("O arquivo-indice existe!");
ta.setText ("TESTE2");
if (fm.checkFileList ())
//System.out.println ("Arquivo indice nao foi modificado. Nada a fazer");
ta.setText ("Arquivo indice nao foi modificado. Nada a fazer");
else {
//System.out.println ("Arquivo índice foi modificado. Atualizando arquivo índice de reserva: ");
ta.setText ("Arquivo índice foi modificado. Atualizando arquivo índice de reserva: ");
fm.printFileList();
}
The words "doesn't work" does not offer much insight to the problem. Try to explain exactly what does happen, and exactly what you want to happen. Also try to explain where in the code things seem to go unexpected.
Does the frame even show?
This code
ta.setText ("TESTE1");
ta.setText ("O arquivo-indice existe!");
ta.setText ("TESTE2");
doesn't show up in the window. The rest work as intended. Simple like that
UPDATED: I figured out what it is the problem. It is showing only the last line. More precisely, it overwrites the last line when it receives a new one. So in my example it is gonna show what it is inside the if/else clause. But what I need to do so the frame keep the old lines?
UPDATED2: I find out that the problem was that I was using SetText. Instead I should be using the append method