public class GenericTextFrame extends JFrame implements ClipboardOwner, ManagedWindow
Modifier and Type | Field and Description |
---|---|
(package private) boolean |
editable |
private JMenu |
editMenu |
private JMenu |
fileMenu |
(package private) File |
fullPathFile |
private JMenuBar |
jMenuBar1 |
JLabel |
mainLabel |
private JMenuItem |
menuEditClear |
private JMenuItem |
menuEditCopy |
private JMenuItem |
menuEditCut |
private JMenuItem |
menuEditPaste |
private JMenuItem |
menuEditSelectAll |
private JMenuItem |
menuFileClose |
private JMenuItem |
menuFileSave |
JPanel |
optionPanel |
(package private) JFrame |
ownerFrame |
protected JScrollPane |
scroller |
JEditorPane |
theText |
private JMenu |
windowMenu |
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Constructor and Description |
---|
GenericTextFrame(JFrame owner)
Creates new form GenericTextFrame
|
GenericTextFrame(JFrame owner,
String title,
String label,
String text,
File suggestedFile)
Creates a new TextDisplayFrame with no text in it; use setText to fill
it.
|
Modifier and Type | Method and Description |
---|---|
private void |
formComponentResized(ComponentEvent evt) |
private void |
formWindowClosing(WindowEvent evt) |
String |
getFilename()
If there's a file associated with the window, return its name; null
otherwise.
|
String |
getMenuItemLabel()
Tells a window manager what label to put on the menu to select this
window
|
String |
getTheText() |
JMenu |
getWindowMenu()
The window menu to be populated by the window manager.
|
private void |
initComponents()
This method is called from within the constructor to initialize the form.
|
void |
loadFile()
Read the frame's suggested file into the frame's text area for editing.
|
void |
lostOwnership(Clipboard clipboard,
Transferable contents) |
private void |
menuEditClearActionPerformed(ActionEvent evt) |
private void |
menuEditCopyActionPerformed(ActionEvent evt) |
private void |
menuEditCutActionPerformed(ActionEvent evt) |
private void |
menuEditSelectAllActionPerformed(ActionEvent evt) |
private void |
menuFileCloseActionPerformed(ActionEvent evt) |
private void |
menuFileSaveActionPerformed(ActionEvent evt) |
void |
setContentType(String type) |
void |
setEditable(boolean b) |
void |
setLabel(String label)
Sets the descriptive label appearing above the text (not the title).
|
void |
setMenuItems()
Determines for each menu item whether to be enabled or disabled ("gray'ed
out" )
|
void |
setOptionPanel(JPanel optionPane)
Allows subclasses to add their own option panel to the form without inconvenience.
|
void |
setSuggestedFile(File suggestedFile)
Sets the suggested file path in case the user wants to save.
|
void |
setTextFont(Font f)
Sets up the given font for the text display part of the frame only.
|
void |
setTheText(String text) |
private void |
setup(JFrame owner,
String title,
String label,
String text,
File suggestedFile) |
private void |
theTextCaretUpdate(CaretEvent evt) |
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFront
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
JFrame ownerFrame
File fullPathFile
boolean editable
private JMenu editMenu
private JMenu fileMenu
private JMenuBar jMenuBar1
public JLabel mainLabel
private JMenuItem menuEditClear
private JMenuItem menuEditCopy
private JMenuItem menuEditCut
private JMenuItem menuEditPaste
private JMenuItem menuEditSelectAll
private JMenuItem menuFileClose
private JMenuItem menuFileSave
public JPanel optionPanel
protected JScrollPane scroller
public JEditorPane theText
private JMenu windowMenu
public GenericTextFrame(JFrame owner)
public GenericTextFrame(JFrame owner, String title, String label, String text, File suggestedFile)
owner
- the frame which spawned this onetitle
- the window's titlelabel
- a descriptive header label (not the window title)text
- the text to be included in the text areasuggestedFile
- a file to save the text to (null if not used)public void setOptionPanel(JPanel optionPane)
optionPane
- The new panel to be added just above the text area.private void setup(JFrame owner, String title, String label, String text, File suggestedFile)
public String getTheText()
public void setTheText(String text)
public void setLabel(String label)
label
- the label to be displayed.public void setEditable(boolean b)
public void setSuggestedFile(File suggestedFile)
suggestedFile
- a reasonably named file to start the user off.public void loadFile() throws FileNotFoundException, IOException
FileNotFoundException
IOException
public void setTextFont(Font f)
f
- the font to be displayed.public void setContentType(String type)
public void setMenuItems()
public String getMenuItemLabel()
getMenuItemLabel
in interface ManagedWindow
public String getFilename()
getFilename
in interface ManagedWindow
public JMenu getWindowMenu()
ManagedWindow
getWindowMenu
in interface ManagedWindow
public void lostOwnership(Clipboard clipboard, Transferable contents)
lostOwnership
in interface ClipboardOwner
private void initComponents()
private void menuFileCloseActionPerformed(ActionEvent evt)
private void menuEditClearActionPerformed(ActionEvent evt)
private void menuEditCopyActionPerformed(ActionEvent evt)
private void menuEditSelectAllActionPerformed(ActionEvent evt)
private void menuFileSaveActionPerformed(ActionEvent evt)
private void menuEditCutActionPerformed(ActionEvent evt)
private void formWindowClosing(WindowEvent evt)
private void theTextCaretUpdate(CaretEvent evt)
private void formComponentResized(ComponentEvent evt)