Class JDialogText

  • All Implemented Interfaces:
    DialogDefaultsInterface, java.awt.event.ActionListener, java.awt.event.FocusListener, java.awt.event.ItemListener, java.awt.event.WindowListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants
    Direct Known Subclasses:
    JDialogFileInfoMinc, JDialogTextGE, JDialogTextGE4X

    public class JDialogText
    extends JDialogBase
    This is simple text dialog that displays in the center of the screen. It automatically adjusts the dialog size to the length of the input string.
    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) or setText(String)) is formatted as plain-text, with PLAIN_FORMAT. The user-code can reformat using setFormat(String), and either PLAIN_FORMAT HTML_FORMAT, or RTF_FORMAT as 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:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JDialog

        javax.swing.JDialog.AccessibleJDialog
      • Nested classes/interfaces inherited from class java.awt.Dialog

        java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType
      • Nested classes/interfaces inherited from class java.awt.Window

        java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private javax.swing.JPanel buttonPanel
      DOCUMENT ME!
      protected java.awt.Dimension DEFAULT_SIZE
      Describes the initial size of the textual display area when the dialog is created.
      private boolean followingScroll
      DOCUMENT ME!
      static java.lang.String HTML_FORMAT
      Specifis the output display of the text-box to be formatted using basic HTML rules, as defined by MIME-format "text/html".
      private java.lang.StringBuffer message
      DOCUMENT ME!
      static java.lang.String PLAIN_FORMAT
      Specifies that the textbox not format the text in the display, as is defined by MIME type "text/plain".
      static java.lang.String RTF_FORMAT
      Specifies the output display of the text-box to be formatted using the RTF rules.
      private javax.swing.JScrollPane scrollPane
      DOCUMENT ME!
      private static long serialVersionUID
      Use serialVersionUID for interoperability.
      private javax.swing.JEditorPane textArea
      DOCUMENT ME!
      • Fields inherited from class javax.swing.JDialog

        accessibleContext, rootPane, rootPaneCheckingEnabled
      • Fields inherited from class java.awt.Dialog

        DEFAULT_MODALITY_TYPE
      • 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
      • Fields inherited from interface javax.swing.WindowConstants

        DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
    • Constructor Summary

      Constructors 
      Constructor Description
      JDialogText​(java.awt.Frame parent, java.lang.String title)
      Constructs resizable dialog with text area in the middle.
      JDialogText​(java.awt.Frame parent, java.lang.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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent event)
      Closes dialog box when the "Close" button is pressed.
      void append​(java.lang.String appMessage)
      Appends the text area with the message.
      protected javax.swing.JPanel getButtonPanel()
      Accessor to the JPanel which holds the buttons at the bottom of the dialog.
      protected void init​(java.lang.String title)
      Initializes the dialog box to a certain size and adds the components.
      void setContent​(java.lang.String type, java.io.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 with PLAIN_FORMAT if it can not determine how to display the content).
      void setContent​(java.lang.String type, java.lang.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 with PLAIN_FORMAT if it can't determine the how to display the content).
      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.
      void setFormat​(java.lang.String type)
      Sets the editor kit that renders the dialog's text area to the type given.
      void setMessage​(java.lang.String message)
      Sets the text area to the message, erasing what was there earlier.
      void setScrollPaneTop()
      Sets the caret to the top of the scroll pane.
      • Methods 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, update
      • Methods inherited from class java.awt.Dialog

        addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, show, toBack
      • Methods 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, toFront
      • Methods 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, validateTree
      • Methods 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        Use serialVersionUID for interoperability.
        See Also:
        Constant Field Values
      • HTML_FORMAT

        public static final java.lang.String 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:
        Constant Field Values
      • RTF_FORMAT

        public static final java.lang.String RTF_FORMAT
        Specifies the output display of the text-box to be formatted using the RTF rules.
        See Also:
        Constant Field Values
      • PLAIN_FORMAT

        public static final java.lang.String 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:
        Constant Field Values
      • DEFAULT_SIZE

        protected final java.awt.Dimension 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

        private javax.swing.JPanel buttonPanel
        DOCUMENT ME!
      • followingScroll

        private boolean followingScroll
        DOCUMENT ME!
      • message

        private java.lang.StringBuffer message
        DOCUMENT ME!
      • scrollPane

        private javax.swing.JScrollPane scrollPane
        DOCUMENT ME!
      • textArea

        private javax.swing.JEditorPane textArea
        DOCUMENT ME!
    • Constructor Detail

      • JDialogText

        public JDialogText​(java.awt.Frame parent,
                           java.lang.String title)
        Constructs resizable dialog with text area in the middle.
        Parameters:
        parent - Parent frame.
        title - Title of dialog frame.
      • JDialogText

        public JDialogText​(java.awt.Frame parent,
                           java.lang.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).
        Parameters:
        parent - parent frame
        title - title of the dialog frame
        followScroll - true means that the scroll bar should stay at the bottom of the text area where appended messages would go. false will not dynamically update the scroll bar location.
    • Method Detail

      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent event)
        Closes dialog box when the "Close" button is pressed.
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
        Overrides:
        actionPerformed in class JDialogBase
        Parameters:
        event - Event that triggers this function.
      • append

        public void append​(java.lang.String appMessage)
        Appends the text area with the message.
        Parameters:
        appMessage - The message to append to the text area.
      • setContent

        public void setContent​(java.lang.String type,
                               java.lang.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 with PLAIN_FORMAT if it can't determine the how to display the content).
        Parameters:
        type - Either a MIME-type or PLAIN_FORMAT, RTF_FORMAT, or HTML_FORMAT.
        content - The String for the dialog to display in its text area.
      • setContent

        public void setContent​(java.lang.String type,
                               java.io.File content)
                        throws java.io.FileNotFoundException,
                               java.io.IOException
        Attempts to read the given file, place its contents into the dialog's display area and format it using the specified MIME-type (or with PLAIN_FORMAT if it can not determine how to display the content).
        Parameters:
        type - Either a MIME-type or PLAIN_FORMAT, RTF_FORMAT, or HTML_FORMAT.
        content - The File whose contents the dialog is to display in its text area.
        Throws:
        java.io.FileNotFoundException - DOCUMENT ME!
        java.io.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 of MipavUtil.font12 width.
        rows - The number of text-columns of MipavUtil.font12 height.
      • setFormat

        public void setFormat​(java.lang.String type)
        Sets the editor kit that renders the dialog's text area to the type given.

        A PLAIN_FORMAT or content-type that is unrecognized (and subsequently set to PLAIN_FORMAT) will be set to use a fixed-width font. The content is then re-loaded.

        Parameters:
        type - Either a MIME-type or PLAIN_FORMAT, RTF_FORMAT, or HTML_FORMAT.
      • setMessage

        public void setMessage​(java.lang.String message)
        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

        protected javax.swing.JPanel getButtonPanel()
        Accessor to the JPanel which holds the buttons at the bottom of the dialog.
        Returns:
        DOCUMENT ME!
      • init

        protected void init​(java.lang.String title)
        Initializes the dialog box to a certain size and adds the components.
        Parameters:
        title - Title of the dialog box.