DisplayFile - /* / DisplayFile.java Author: Lewis/Loftus /...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // DisplayFile.java Author: Lewis/Loftus // // Solution to Programming Project 8.11 //******************************************************************** / import java.io.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; i public class DisplayFile { private JTextArea ta; private File file; //----------------------------------------------------------------- // Opens a file chooser dialog, reads the selected file and // loads it into a text area. //----------------------------------------------------------------- public void run() throws IOException { JFrame frame = new JFrame ("Display File"); frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); ta = new JTextArea (20, 30); JFileChooser chooser = new JFileChooser(); int status = chooser.showOpenDialog (null); if (status != JFileChooser.APPROVE_OPTION) ta.setText ("No File Chosen"); else { file = chooser.getSelectedFile(); FileReader fr = new FileReader (file);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/17/2011 for the course COP 3530 taught by Professor Davis during the Spring '08 term at University of Florida.

Page1 / 2

DisplayFile - /* / DisplayFile.java Author: Lewis/Loftus /...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online