All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.TextPreview

java.lang.Object
   |
   +----java.awt.Component
           |
           +----com.sun.java.swing.TextPreview

public class TextPreview
extends Component
implements FilePreview
A component to preview a text file, intended to fit into the preview slot of a FileChooser. In normal usage, only the ask method is of interest: it pops up a dialog box with a FileChooser containing an instance of this previewer and filtering for appropriate files.


Constructor Index

 o TextPreview()

Method Index

 o ask(JFrame, String, File, ChangeListener, FileChooserFilter)
Convenience method to prompt for the name of a text file.
 o getMinimumSize()
 o getPreferredSize()
 o paint(Graphics)
 o setBounds(int, int, int, int)
 o setPreviewFile(File)
 o setSize(int, int)

Constructors

 o TextPreview
 public TextPreview()

Methods

 o ask
 public static File ask(JFrame parent,
                        String title,
                        File dfc,
                        ChangeListener target,
                        FileChooserFilter fcf)
Convenience method to prompt for the name of a text file. For example:
File f = ImagePreview.ask(null,"Open file",previousFile,
                null,new FileChooserFilter("Config file (cfg)"));

Parameters:
fparent - the parent frame for the dialog box. fparent may be null if a default parent has been established with StandardDialog
description - a description string that will be shown to the user to indicate what is being requested
initial - the initial value for the string
columns - the default width (in 'm's) of the TextField
target - the ChangeListener that will be informed if the OK or Apply buttons are hit.
fcf - a FileChooserFilter for selecting the file names to be presented in the dialog box.
Returns:
If target is null, the dialog box will be modal and the method will return the final result, or null if cancelled. Otherwise, the dialog box is non-modal, the method returns null immediatly, and the listener is informed when appropriate. The source of the change event will be a FileChooser.
See Also:
StandardDialog
 o setPreviewFile
 public void setPreviewFile(File f)
 o setSize
 public void setSize(int w,
                     int h)
Overrides:
setSize in class Component
 o setBounds
 public void setBounds(int x,
                       int y,
                       int width,
                       int height)
Overrides:
setBounds in class Component
 o getPreferredSize
 public Dimension getPreferredSize()
Overrides:
getPreferredSize in class Component
 o getMinimumSize
 public Dimension getMinimumSize()
Overrides:
getMinimumSize in class Component
 o paint
 public void paint(Graphics g)
Overrides:
paint in class Component

All Packages  Class Hierarchy  This Package  Previous  Next  Index