FileDocCategorySizeDatePackage
FileTextField.javaAPI DocExample4273Thu Nov 08 00:23:54 GMT 2001com.ora.rmibook.gui

FileTextField

public class FileTextField extends JPanel

Fields Summary
private JTextField
_fileNameField
private JFileChooser
_fileChooser
Constructors Summary
public FileTextField()

        super (new GridBagLayout());
        buildBasicGUI();
    
public FileTextField(Action thingToDoWithFile)

        super (new GridBagLayout());
        buildBasicGUI();
        addButton(thingToDoWithFile, 4);
    
public FileTextField(String label)

        super (new GridBagLayout());
        setBorder(BorderFactory.createTitledBorder(label));
        buildBasicGUI();
    
public FileTextField(Action thingToDoWithFile, String label)

        super (new GridBagLayout());
        buildBasicGUI();
        setBorder(BorderFactory.createTitledBorder(label));
        addButton(thingToDoWithFile, 4);
    
Methods Summary
private voidaddButton(javax.swing.Action buttonAction, int location)

        GridBagConstraints buttonPosition = new GridBagConstraints();

        buttonPosition.gridx = location;
        buttonPosition.gridwidth = 1;
        buttonPosition.gridy = 0;
        buttonPosition.gridheight = 1;
        buttonPosition.weightx = 0.0;
        add(new ActionButton(buttonAction), buttonPosition);
    
protected voidbuildBasicGUI()

        createFileNameField();
        addButton(new BrowseButtonAction(), 3);
    
private voidcreateFileNameField()

        _fileNameField = new JTextField();
        GridBagConstraints textFieldPosition = new GridBagConstraints();

        textFieldPosition.gridx = 0;
        textFieldPosition.gridwidth = 3;
        textFieldPosition.gridy = 0;
        textFieldPosition.gridheight = 1;
        textFieldPosition.weightx = 1.0;
        textFieldPosition.fill = GridBagConstraints.HORIZONTAL;
        add(_fileNameField, textFieldPosition);
    
public java.io.FilegetFile()

        String fileName = _fileNameField.getText();

        if (null != fileName) {
            return new File(fileName);
        }
        return null;
    
public java.io.FileInputStreamgetFileInputStream()

        String fileName = _fileNameField.getText();

        if (null != fileName) {
            try {
                return new FileInputStream(fileName);
            } catch (java.io.FileNotFoundException e) {
            }
        }
        return null;
    
public java.lang.StringgetFileName()

        return _fileNameField.getText();
    
public java.io.FileOutputStreamgetFileOutputStream()

        String fileName = _fileNameField.getText();

        if (null != fileName) {
            try {
                return new FileOutputStream(fileName);
            } catch (java.io.FileNotFoundException e) {
            }
        }
        return null;
    
public java.io.FileReadergetFileReader()

        String fileName = _fileNameField.getText();

        if (null != fileName) {
            try {
                return new FileReader(fileName);
            } catch (java.io.FileNotFoundException e) {
            }
        }
        return null;
    
public java.io.FileWritergetFileWriter()

        String fileName = _fileNameField.getText();

        if (null != fileName) {
            try {
                return new FileWriter(fileName);
            } catch (java.io.IOException e) {
            }
        }
        return null;