|
-
August 3rd, 2009, 10:50 AM
#1
GUI Help Java Program
I don't know what to use, a JFileChooser, or a JTextArea?
It's suppose to read in a social security (sample) file, if it contains anything other than the 9 digits, it will show the exception. Line by line is read into a GUI via a text file.
I only got it to work to open an empty GUI with the appropriate heading.
Code:
import javax.swing.*;
import java.awt.*;
import java.io.*;
public class GUI extends JPanel implements ActionListener{
protected JTextField textField;
protected JTextArea textArea;
private final static String newline = "\n";
JFrame myFrame;
//Need to display an error message for the line of error in txt
//file in a text box.
//JFileChooser fc = new JFileChooser();
textField = new JTextField(20);
textField.addActionListener(this);
textArea = new JTextArea(10, 20);
textArea.setEditable(false);
JScrollPane scrollPane = new JScrollPane(textArea);
//Main
public static void main(String[]args){
GUI gui = new GUI();
}
GUI(){
myFrame = new JFrame();
myFrame.setSize(500,500);
myFrame.setLocation(250,250);
myFrame.setTitle("Social Security Numbers");
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myFrame.setVisible(true);
}
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|