Hi, is there an easy way to add FileReader to this GUI? I just want the program to read a specific file and thne print the first line of the file in the text field.
Code:import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
public class Navigation extends JFrame implements ActionListener
{
JButton myButton = new JButton("Forward");
JButton myButton2 = new JButton("Go Back");
JTextArea myText = new JTextArea("My text");
JPanel bottomPanel = new JPanel();
JPanel holdAll = new JPanel();
public Navigation()
{
bottomPanel.setLayout(new FlowLayout());
bottomPanel.add(myButton);
bottomPanel.add(myButton2);
holdAll.setLayout(new BorderLayout());
holdAll.add(bottomPanel, BorderLayout.SOUTH);
holdAll.add(myText, BorderLayout.CENTER);
getContentPane().add(holdAll, BorderLayout.CENTER);
myButton.addActionListener(this);
myButton2.addActionListener(this);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
public static void main(String[] args)
{
Navigation myApplication = new Navigation();
myApplication.setLocation(10, 10);
myApplication.setSize(300, 300);
// Display!
myApplication.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == myButton)
myText.setText("A button click");
else
myText.setText("E ...?");
if (e.getSource() == myButton2)
myText.setText("going forward");
else
myText.setText("E ...?");
}
}

