Class JDialogText
- All Implemented Interfaces:
DialogDefaultsInterface,ActionListener,FocusListener,ItemListener,WindowListener,ImageObserver,MenuContainer,Serializable,EventListener,Accessible,RootPaneContainer,WindowConstants
- Direct Known Subclasses:
JDialogFileInfoMinc,JDialogTextGE,JDialogTextGE4X
- Version:
- 0.1 Oct 1, 1998, 2.0 2003-April-9
- Author:
- Matthew J. McAuliffe, Ph.D.
Defaults to an interface very similar to the original version, however now supports plain text, HTML and Rich-Text format. Perhaps the most significant difference is that when text is too long to fit entirely within the width of the display-area, it is wrapped around to the other side, rather than the scroll-area increasing in size.
Plain text format is handled by the DefaultEditorKit. The HTML formatting is handled by the HTML editor kit. HTMLEditorKit parses HTML 3.2, so be sure to see the World Wide Web Consortium's (w3) definitive reference for HTML 3.2. The RTF parsing is handled by the RTF Editor Kit, which appears to only be a bare-bones implementation.
By default, all text sent to this editor (use the method
append(String)orsetText(String)) is formatted as plain-text, withPLAIN_FORMAT. The user-code can reformat usingsetFormat(String), and eitherPLAIN_FORMATHTML_FORMAT, orRTF_FORMATas any predefined setting, or any normal MIME type. Refer to the RFC list or RFC 2045 (MIME Types, part 1) and RFC 2045 (MIME Types part 2) for more on MIME types. - See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class gov.nih.mipav.view.dialogs.JDialogBase
JDialogBase.CancelAction, JDialogBase.HelpAction, JDialogBase.OKActionNested classes/interfaces inherited from class javax.swing.JDialog
JDialog.AccessibleJDialogNested classes/interfaces inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityTypeNested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow, Window.TypeNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate JPanelDOCUMENT ME!protected final DimensionDescribes the initial size of the textual display area when the dialog is created.private booleanDOCUMENT ME!static final StringSpecifis the output display of the text-box to be formatted using basic HTML rules, as defined by MIME-format "text/html".private StringBufferDOCUMENT ME!static final StringSpecifies that the textbox not format the text in the display, as is defined by MIME type "text/plain".static final StringSpecifies the output display of the text-box to be formatted using the RTF rules.private JScrollPaneDOCUMENT ME!private static final longUse serialVersionUID for interoperability.private JEditorPaneDOCUMENT ME!Fields inherited from class gov.nih.mipav.view.dialogs.JDialogBase
applyButton, bar, cancelButton, cancelFlag, closeButton, HELP, helpButton, mainDialogPanel, NEW, OKButton, parentFrame, progressBar, REPLACE, runInSeparateThread, runningScriptFlag, runQuiet, serif12, serif12B, voiManagerFields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabledFields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPEFields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE -
Constructor Summary
ConstructorsConstructorDescriptionJDialogText(Frame parent, String title) Constructs resizable dialog with text area in the middle.JDialogText(Frame parent, String title, boolean followScroll) Constructs a resizable dialog with a text area which can be filled; the scrollbar can be set to keep up with the updates (at the bottom). -
Method Summary
Modifier and TypeMethodDescriptionvoidactionPerformed(ActionEvent event) Closes dialog box when the "Close" button is pressed.voidAppends the text area with the message.protected JPanelAccessor to theJPanelwhich holds the buttons at the bottom of the dialog.protected voidInitializes the dialog box to a certain size and adds the components.voidsetContent(String type, File content) Attempts to read the given file, place its contents into the dialog's display area and format it using the specified MIME-type (or withPLAIN_FORMATif it can not determine how to display the content).voidsetContent(String type, String content) Uses the input string as the text to display in the dialog's text area, formats it with the specified MIME-type (or withPLAIN_FORMATif it can't determine the how to display the content).voidsetDocumentSize(int columns, int rows) Attempts to set the size of the text display area to the supplied number of text-columns and rows.voidSets the editor kit that renders the dialog's text area to the type given.voidsetMessage(String message) Sets the text area to the message, erasing what was there earlier.voidSets the caret to the top of the scroll pane.Methods inherited from class gov.nih.mipav.view.dialogs.JDialogBase
buildApplyButton, buildButtons, buildCancelButton, buildCancelButton, buildCloseButton, buildHelpButton, buildImageComboBox, buildOKButton, buildOKButton, buildOKCancelButtons, buildTitledBorder, buildTitledBorder, createLabel, createProgressBar, createProgressBar, createTextField, focusGained, focusLost, getDialogName, isCancelled, isQuietRunning, isRunInSeparateThread, isScriptRunning, itemStateChanged, loadDefaults, loadDefaults, makeImageName, makeString, openNewFrame, saveDefaults, saveDefaults, setLeftHandSystem, setQuietRunning, setScriptRunning, setSeparateThread, setVisible, setVisible, setVisibleMenuBar, setVisibleStandard, setVOIManager, setWCSystem, testParameter, testParameterMin, updateFFTFileInfo, updateFileInfo, updateFileInfoOtherModality, updateFileInfoStatic, updateFileInfoStatic, updateFileTypeInfo, updateFileTypeInfo, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpenedMethods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, updateMethods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, show, toBackMethods inherited from class java.awt.Window
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, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, toFrontMethods inherited from class java.awt.Container
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, validateTreeMethods inherited from class java.awt.Component
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, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDUse serialVersionUID for interoperability.- See Also:
-
HTML_FORMAT
Specifis the output display of the text-box to be formatted using basic HTML rules, as defined by MIME-format "text/html".For more information, consult RFC 1866 (HTML 2.0), section 4.1, which defines the MIME type with all valid options; since RFC 1866 is out-dated, see also RFC 2854, a more more up-to-date source on "text/html" practices. RFC 2854, however, details HTML 4.0, which carries tags not deciphered by the decoder here; for information on HTML 3.2 (and the tags which may be used in included texts), see World Wide Web Consortium's (w3) definitive reference for HTML 3.2.
- See Also:
-
RTF_FORMAT
Specifies the output display of the text-box to be formatted using the RTF rules.- See Also:
-
PLAIN_FORMAT
Specifies that the textbox not format the text in the display, as is defined by MIME type "text/plain". In addition, this setting will also reset the font to serif10.- See Also:
-
DEFAULT_SIZE
Describes the initial size of the textual display area when the dialog is created. The value is given in pixel size rather than the number of characters since the display area has no characters to display. -
buttonPanel
DOCUMENT ME! -
followingScroll
private boolean followingScrollDOCUMENT ME! -
message
DOCUMENT ME! -
scrollPane
DOCUMENT ME! -
textArea
DOCUMENT ME!
-
-
Constructor Details
-
JDialogText
Constructs resizable dialog with text area in the middle.- Parameters:
parent- Parent frame.title- Title of dialog frame.
-
JDialogText
Constructs a resizable dialog with a text area which can be filled; the scrollbar can be set to keep up with the updates (at the bottom).- Parameters:
parent- parent frametitle- title of the dialog framefollowScroll-truemeans that the scroll bar should stay at the bottom of the text area where appended messages would go.falsewill not dynamically update the scroll bar location.
-
-
Method Details
-
actionPerformed
Closes dialog box when the "Close" button is pressed.- Specified by:
actionPerformedin interfaceActionListener- Overrides:
actionPerformedin classJDialogBase- Parameters:
event- Event that triggers this function.
-
append
Appends the text area with the message.- Parameters:
appMessage- The message to append to the text area.
-
setContent
Uses the input string as the text to display in the dialog's text area, formats it with the specified MIME-type (or withPLAIN_FORMATif it can't determine the how to display the content).- Parameters:
type- Either a MIME-type orPLAIN_FORMAT,RTF_FORMAT, orHTML_FORMAT.content- The String for the dialog to display in its text area.
-
setContent
Attempts to read the given file, place its contents into the dialog's display area and format it using the specified MIME-type (or withPLAIN_FORMATif it can not determine how to display the content).- Parameters:
type- Either a MIME-type orPLAIN_FORMAT,RTF_FORMAT, orHTML_FORMAT.content- The File whose contents the dialog is to display in its text area.- Throws:
FileNotFoundException- DOCUMENT ME!IOException- DOCUMENT ME!
-
setDocumentSize
public void setDocumentSize(int columns, int rows) Attempts to set the size of the text display area to the supplied number of text-columns and rows.Negative or zero values are ignored, and the current value for text display area size is used in that dimension.
The font size is assumed to be the size of a character of
MipavUtil.font12, a fixed-width font. Obviously, this means that content-types displaying HTML may be larger (or smaller) so although the size will be set, it will not have much meaning for these texts.- Parameters:
columns- The number of text-columns ofMipavUtil.font12width.rows- The number of text-columns ofMipavUtil.font12height.
-
setFormat
Sets the editor kit that renders the dialog's text area to the type given.A
PLAIN_FORMATor content-type that is unrecognized (and subsequently set toPLAIN_FORMAT) will be set to use a fixed-width font. The content is then re-loaded.- Parameters:
type- Either a MIME-type orPLAIN_FORMAT,RTF_FORMAT, orHTML_FORMAT.
-
setMessage
Sets the text area to the message, erasing what was there earlier.- Parameters:
message- Message to display in the text area.
-
setScrollPaneTop
public void setScrollPaneTop()Sets the caret to the top of the scroll pane. -
getButtonPanel
Accessor to theJPanelwhich holds the buttons at the bottom of the dialog.- Returns:
- DOCUMENT ME!
-
init
Initializes the dialog box to a certain size and adds the components.- Parameters:
title- Title of the dialog box.
-