|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JScrollPane visad.util.TextEditor
public class TextEditor
A general-purpose editor for reading and writing text files.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JScrollPane |
---|
JScrollPane.AccessibleJScrollPane, JScrollPane.ScrollBar |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected boolean |
changed
whether the text has changed since last save |
protected File |
currentFile
file being edited |
static boolean |
DEBUG
debugging flag |
static Font |
MONO
monospaced font |
protected JTextArea |
text
main text area |
protected UndoManager |
undo
undo manager |
Fields inherited from class javax.swing.JScrollPane |
---|
columnHeader, horizontalScrollBar, horizontalScrollBarPolicy, lowerLeft, lowerRight, rowHeader, upperLeft, upperRight, verticalScrollBar, verticalScrollBarPolicy, viewport |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
TextEditor()
constructs a TextEditor |
|
TextEditor(String filename)
constructs a TextEditor containing text from the given filename |
Method Summary | |
---|---|
void |
addUndoableEditListener(UndoableEditListener l)
add an undoable edit listener |
boolean |
canRedo()
returns whether a redo command is possible |
boolean |
canUndo()
returns whether an undo command is possible |
void |
copy()
copies the selected text to the clipboard |
void |
cut()
cuts the selected text to the clipboard |
protected JFileChooser |
doMakeFileChooser()
Create and initialize the the file chooser |
File |
getFile()
returns the file being edited |
protected JFileChooser |
getFileChooser()
Create if needed and return the file chooser |
String |
getFilename()
returns the filename being edited |
String |
getRedoName()
returns the name of the redo command |
String |
getText()
returns a string containing the text of the document |
JTextComponent |
getTextComponent()
Provide direct access to the text component |
String |
getUndoName()
returns the name of the undo command |
boolean |
hasChanged()
returns whether the document has changed since the last save |
void |
insertText(String textToInsert)
Insert the given text at the caret |
void |
newFile()
starts from scratch with a blank document |
boolean |
openDialog()
pops up a dialog box for the user to select a file to open |
void |
openFile(File file)
opens the given file |
void |
openFile(String filename)
opens the given file |
void |
paste()
pastes the clipboard into the text document |
void |
redo()
redoes the last undone edit |
void |
removeUndoableEditListener(UndoableEditListener l)
remove an undoable edit listener |
boolean |
saveDialog()
pops up a dialog box for the user to select a file to save |
boolean |
saveFile()
saves the file under its current name |
void |
saveFile(File file)
saves the given file |
void |
saveFile(String filename)
saves the given file |
void |
setText(String text)
sets the text of this document to the current string |
void |
undo()
undoes the last edit |
void |
undoableEditHappened(UndoableEditEvent e)
handle undoable edits |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Font MONO
public static final boolean DEBUG
protected JTextArea text
protected UndoManager undo
protected File currentFile
protected boolean changed
Constructor Detail |
---|
public TextEditor()
public TextEditor(String filename)
Method Detail |
---|
protected JFileChooser doMakeFileChooser()
protected JFileChooser getFileChooser()
public void newFile()
public void openFile(String filename) throws IOException
IOException
public void openFile(File file) throws IOException
IOException
public void saveFile(String filename) throws IOException
IOException
public void saveFile(File file) throws IOException
IOException
public boolean openDialog()
public boolean saveDialog()
public boolean saveFile()
public void undo() throws CannotUndoException
CannotUndoException
public void redo() throws CannotRedoException
CannotRedoException
public void cut()
public void copy()
public void paste()
public JTextComponent getTextComponent()
public String getText()
public void setText(String text)
public void insertText(String textToInsert)
textToInsert
- the textpublic String getFilename()
public File getFile()
public boolean canUndo()
public boolean canRedo()
public String getUndoName()
public String getRedoName()
public boolean hasChanged()
public void undoableEditHappened(UndoableEditEvent e)
undoableEditHappened
in interface UndoableEditListener
public void addUndoableEditListener(UndoableEditListener l)
public void removeUndoableEditListener(UndoableEditListener l)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |