Loading a file into a GUI

Hello there, i'm having real problems trying to implement a way for my GUI to load a file (in this case a text file) and then display the contents. I have used the following code to implement the part of the Menu to instigate this method, but I am unsure how to actually write the "openFile();" method to do the action.

JMenuItem openItem =new JMenuItem("Open");

openItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, SHORTCUT_MASK));

openItem.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent e){ openFile();}

});

fileMenu.add(openItem);

Any help will be greatly appeciated.

cjr87.

[943 byte] By [cjr87a] at [2007-11-26 23:53:03]
# 1

1. get into the habit of using Actions when putting functionality in menus etc, they will make you life a lot easier in the long run

2. look into classes such as File and FileReader to read the text in

3. look into classes like JTextArea to display it

4. don't even think of reading the file on the Event Dispatch Thread - read this first, http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html

itchyscratchya at 2007-7-11 15:33:33 > top of Java-index,Desktop,Core GUI APIs...