new problem trying to view the contents of a text file in JTextArea
hello hunter9000.
thanks for the help. i did what you told me to do as much as i possibly could. but when i run the program and press View Order this time, "null" appears in the Compile Messages section of the jGRASP console. what have i done wrong this time? how can i improve my code in order for it to function properly?
import java.awt.BorderLayout;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.io.*;
publicclass ViewOrderextends JFrame{
JPanel pnlText, pnlBody, pnlFooter;
JButton btnViewOrder;
JButton btnReturnToOrderSystem;
JLabel jl;
JTextArea jtaDescription =new JTextArea();
Container contentpane;
public ViewOrder(){
super("View Order");
contentpane = getContentPane();
contentpane.setLayout(new BorderLayout());
pnlText =new JPanel();
pnlBody =new JPanel();
pnlFooter =new JPanel();
jtaDescription =new JTextArea();
jtaDescription.setFont(new Font("Serif", Font.PLAIN, 14));
// Set lineWrap and wrapStyleWord true for the text area
jtaDescription.setLineWrap(true);
jtaDescription.setWrapStyleWord(true);
jtaDescription.setEditable(false);
pnlBody.add(jtaDescription);
// Create a scroll pane to hold the text area
JScrollPane scrollPane =new JScrollPane(jtaDescription);
// Set BorderLayout for the panel, add label and scrollpane
pnlBody.add(scrollPane, BorderLayout.CENTER);
jl =new JLabel("Text retrieved from file:");
btnViewOrder =new JButton("View Order");
btnReturnToOrderSystem =new JButton("Return to Order System Menu");
pnlText.add(jl);
pnlFooter.add(btnViewOrder);
pnlFooter.add(btnReturnToOrderSystem);
contentpane.add(pnlText,BorderLayout.NORTH);
contentpane.add(pnlBody,BorderLayout.CENTER);
contentpane.add(pnlFooter,BorderLayout.SOUTH);
pack();
setVisible(true);
btnViewOrder.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent e){
String s =null;
System.out.println(s +"\n");
//Read from file
try{
String inputFileName ="Order.txt";
File inputFile =new File(inputFileName);
FileInputStream in =new FileInputStream(inputFile);
BufferedReader iS =new BufferedReader(new InputStreamReader(in));
String iL ="";
iL = iS.readLine();
setDescription(iL);
iS.close();
}
catch(java.io.IOException ex){
System.out.println("Cannot read from file");
}
}
});
btnReturnToOrderSystem.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent e){
setVisible(false);
//OrderSystem os = new OrderSystem();
//os.setVisible(true);
}
});
}
/** Set the text description */
publicvoid setDescription(String s){
jtaDescription.setText(s);
}
publicstaticvoid main(String[] args){
new ViewOrder();
}
}

