Class ErrorWindow

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

    public class ErrorWindow
    extends javax.swing.JDialog
    implements java.awt.event.ActionListener
    This class provides an error window for presenting any error message on the screen. It is very important in this class to prevent a method to throw any error or exception (maximum error handling and error robustness).

    ToDo: Replace the extends to JDialog or something like that to enable modal behavior. Also make it possible to set the window on top of any other window...and so on...
    Version:
    0.1
    Author:
    Thoralf Rickert
    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
      protected boolean actionPerformed  
      protected javax.swing.JButton cancelButton  
      protected boolean cleanShutdown  
      protected javax.swing.JButton detailsButton  
      protected javax.swing.text.JTextComponent errorDescription  
      protected javax.swing.JTextArea errorMessage  
      protected javax.swing.JButton okButton  
      protected javax.swing.JScrollPane scrollPane  
      protected boolean showCancel  
      protected boolean shutdownOnCancel  
      static java.lang.String UNKNOWN_ERROR_MESSAGE  
      protected int xSize  
      protected int ySize  
      • 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
      ErrorWindow()  
      ErrorWindow​(java.awt.Dialog owner, java.lang.String message, java.lang.String description, java.lang.Throwable throwable)  
      ErrorWindow​(java.awt.Frame owner, java.lang.String message, java.lang.String description, java.lang.Throwable throwable)  
      ErrorWindow​(java.lang.String message)  
      ErrorWindow​(java.lang.String message, java.lang.String description, java.lang.Throwable throwable)  
      ErrorWindow​(java.lang.String message, java.lang.Throwable throwable)  
      ErrorWindow​(java.lang.Throwable throwable)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent event)  
      void close()  
      protected void hideDetails()  
      protected boolean isDetailed()  
      void open()  
      void setCleanShutdown​(boolean cleanShutdown)  
      void setErrorMessage​(java.lang.String message)
      Sets the error message of an error inside this dialog.
      void setErrorMessage​(java.lang.String message, java.lang.String description)
      Sets the error message and description of an error inside this dialog.
      void setErrorMessage​(java.lang.String message, java.lang.String description, java.lang.Throwable throwable)
      Sets the error message and description of an error inside this dialog.
      void setErrorMessage​(java.lang.String message, java.lang.Throwable throwable)
      Sets the error message and description of an error inside this dialog.
      void setShutdownOnCancel​(boolean shutdownOnCancel)
      Whether to stop the application with a System.exit(0) or not.
      protected void setup()  
      void setVisible​(boolean b)  
      void setWindowSize​(int xSize, int ySize)
      This method sets the window dimension and positions the window to the center of the screen.
      protected void showDetails()  
      void windowClosing()  
      • 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

      • UNKNOWN_ERROR_MESSAGE

        public static final java.lang.String UNKNOWN_ERROR_MESSAGE
      • errorMessage

        protected javax.swing.JTextArea errorMessage
      • errorDescription

        protected javax.swing.text.JTextComponent errorDescription
      • scrollPane

        protected javax.swing.JScrollPane scrollPane
      • shutdownOnCancel

        protected boolean shutdownOnCancel
      • cleanShutdown

        protected boolean cleanShutdown
      • okButton

        protected javax.swing.JButton okButton
      • cancelButton

        protected javax.swing.JButton cancelButton
      • detailsButton

        protected javax.swing.JButton detailsButton
      • xSize

        protected int xSize
      • ySize

        protected int ySize
      • actionPerformed

        protected boolean actionPerformed
      • showCancel

        protected boolean showCancel
    • Constructor Detail

      • ErrorWindow

        public ErrorWindow()
      • ErrorWindow

        public ErrorWindow​(java.lang.String message)
        Parameters:
        message - is a user friendly message with a question that the user can answer with "OK" or "Cancel".
      • ErrorWindow

        public ErrorWindow​(java.lang.String message,
                           java.lang.Throwable throwable)
        Parameters:
        message - is a user friendly message with a question that the user can answer with "OK" or "Cancel".
        throwable - is an occured exception or error, that couldn't be served or catched.
      • ErrorWindow

        public ErrorWindow​(java.lang.Throwable throwable)
        Parameters:
        throwable - is an occured exception or error, that couldn't be served or catched.
      • ErrorWindow

        public ErrorWindow​(java.lang.String message,
                           java.lang.String description,
                           java.lang.Throwable throwable)
        Parameters:
        message - is a user friendly message with a question that the user can answer with "OK" or "Cancel".
        description - is a longer description of the error for experts.
        throwable - is an occured exception or error, that couldn't be served or catched.
      • ErrorWindow

        public ErrorWindow​(java.awt.Frame owner,
                           java.lang.String message,
                           java.lang.String description,
                           java.lang.Throwable throwable)
        Parameters:
        owner - is the parent window where the error occured.
        message - is a user friendly message with a question that the user can answer with "OK" or "Cancel".
        description - is a longer description of the error for experts.
        throwable - is an occured exception or error, that couldn't be served or catched.
      • ErrorWindow

        public ErrorWindow​(java.awt.Dialog owner,
                           java.lang.String message,
                           java.lang.String description,
                           java.lang.Throwable throwable)
        Parameters:
        owner - is the parent window where the error occured.
        message - is a user friendly message with a question that the user can answer with "OK" or "Cancel".
        description - is a longer description of the error for experts.
        throwable - is an occured exception or error, that couldn't be served or catched.
    • Method Detail

      • setErrorMessage

        public void setErrorMessage​(java.lang.String message)
        Sets the error message of an error inside this dialog.
        Parameters:
        message - is a user friendly message with a question that the user can answer with "OK" or "Cancel".
      • setErrorMessage

        public void setErrorMessage​(java.lang.String message,
                                    java.lang.Throwable throwable)
        Sets the error message and description of an error inside this dialog.
        Parameters:
        message - is a user friendly message with a question that the user can answer with "OK" or "Cancel".
        throwable - is an occured exception or error, that couldn't be served or catched.
      • setErrorMessage

        public void setErrorMessage​(java.lang.String message,
                                    java.lang.String description)
        Sets the error message and description of an error inside this dialog.
        Parameters:
        message - is a user friendly message with a question that the user can answer with "OK" or "Cancel".
        description - is a longer description of the error for experts.
      • setErrorMessage

        public void setErrorMessage​(java.lang.String message,
                                    java.lang.String description,
                                    java.lang.Throwable throwable)
        Sets the error message and description of an error inside this dialog.
        Parameters:
        message - is a user friendly message with a question that the user can answer with "OK" or "Cancel".
        description - is a longer description of the error for experts.
        throwable - is an occured exception or error, that couldn't be served or catched.
      • setup

        protected void setup()
      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent event)
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
      • windowClosing

        public void windowClosing()
      • open

        public void open()
      • close

        public void close()
      • setVisible

        public void setVisible​(boolean b)
        Overrides:
        setVisible in class java.awt.Dialog
        See Also:
        Dialog.setVisible(boolean)
      • isDetailed

        protected boolean isDetailed()
      • showDetails

        protected void showDetails()
      • hideDetails

        protected void hideDetails()
      • setShutdownOnCancel

        public void setShutdownOnCancel​(boolean shutdownOnCancel)
        Whether to stop the application with a System.exit(0) or not.
      • setWindowSize

        public void setWindowSize​(int xSize,
                                  int ySize)
        This method sets the window dimension and positions the window to the center of the screen.
      • setCleanShutdown

        public void setCleanShutdown​(boolean cleanShutdown)
        Parameters:
        cleanShutdown - Wenn der Wert wahr ist, dann wird ein sauberer Shutdown durchgeführt und ErrorWindow.shutdown aufgerufen. Wenn der Wert falsch ist, dann wird direkt System.exit aufgerufen und nur noch der Start-ShutdownHook Prozess wird gestartet.