Hello there
i'm trying to make a button where i push that and it display what is in the text file on the JTextArea, but i can't not make it to work when i press the button i have no idea how to make it work. I can make it display the file when i write in where it is supose to be but i would like to choose from what file it is suppose to show
Here is my code so far:
import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; public class login implements ActionListener { public void actionPerformed(ActionEvent event) { JFrame frame2 = new JFrame(); frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame2.setSize(new Dimension(600, 300)); frame2.setLocation(new Point(300, 300)); frame2.setLayout(new BorderLayout()); frame2.setTitle("Home");; //buttons JButton overforPenge = new JButton(); overforPenge.setText("Overfør penge"); JButton konti1 = new JButton(); overforPenge.setText("Brugs konti"); JButton konti2 = new JButton(); overforPenge.setText("Opsparing"); //north JPanel North = new JPanel(new GridLayout(1,3)); North.add(new JLabel("")); North.add(new JLabel("CAC Bank")); North.add(new JLabel("")); // venstre række JPanel West = new JPanel(new GridLayout(4,1)); West.add(new JButton("Se konti")); West.add(overforPenge); West.add(new JButton("Indtast løn")); West.add(new JButton("Indtast udgifter")); overforPenge.addActionListener(new Overfor()); //Center JTextArea Center = new JTextArea(400, 500); try{Center.read(new FileReader("logfile1.txt"),null);}catch(IOException ioe){} //East JPanel East = new JPanel(new GridLayout(8,2)); East.add(konti1); East.add(new JLabel("Tilrådighed")); East.add(konti2); East.add(new JLabel("Tilrådighed")); East.add(new JButton("Konti")); East.add(new JLabel("Tilrådighed")); East.add(new JButton("Konti")); East.add(new JLabel("Tilrådighed")); East.add(new JLabel("")); East.add(new JLabel("")); East.add(new JLabel("")); East.add(new JLabel("")); East.add(new JLabel("")); East.add(new JLabel("")); East.add(new JLabel("")); East.add(new JLabel("")); //South JPanel South = new JPanel (new GridLayout(1,3)); South.add(new JLabel(" ")); South.add(new JLabel(" ")); South.add(new JButton("Log out")); //layout frame2.add(North, BorderLayout.NORTH); frame2.add(West, BorderLayout.WEST); frame2.add(Center, BorderLayout.CENTER); frame2.add(East, BorderLayout.EAST); frame2.add(South, BorderLayout.SOUTH); frame2.setVisible(true); } }