public class MessageWidget
extends javax.swing.JPanel
This widget is invisible and appears only when a message must be notified
to the user.
When the user presses the Ok button, the panel hides itself.
The method removeError() allows to hide the panel programmatically.
The look of the panel changes if a detailed description of the error is present.
If it is the case, the panel shows a title label on top.
If instead the detailed description is not defined, then the label and the detailed panel are hidden.
This allows to use the component as "light" or "heavy" by setting a detailed description.
Which of the two modality is in use is returned by the boolean of the two showMessage(...) methods.
| Modifier and Type | Class and Description |
|---|---|
static class |
MessageWidget.MessageType
The type of the message shown by the glass pane
|
static interface |
MessageWidget.MessageWidgetListener
The listener to be notified when the user acknowledge
the message by pressing the button
|
javax.swing.JPanel.AccessibleJPaneljavax.swing.JComponent.AccessibleJComponentlistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW| Constructor and Description |
|---|
MessageWidget()
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAckListener(MessageWidget.MessageWidgetListener listener)
Add a listener to be notified when the user presses the ack button.
|
javax.swing.JButton |
getAckButton() |
boolean |
removeAckListener(MessageWidget.MessageWidgetListener listener)
Remove a listener from the listeners to be notified when the user
acknowledges the message.
|
void |
removeMessage()
Hide the error panel.
|
boolean |
showMessage(MessageWidget.MessageType messageType,
java.lang.String shortDescription,
java.lang.String description)
Show the glass pane and catches all the events until the user acknowledges the message
by pressing the button.
|
boolean |
showMessage(java.lang.String shortDescription,
java.lang.Throwable t)
Show the glass pane and catches all the events until the user acknowledges the message
by pressing the button.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIaddAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateadd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCyclepublic MessageWidget()
client - The LoggingClient that owns this glass panepublic boolean showMessage(MessageWidget.MessageType messageType, java.lang.String shortDescription, java.lang.String description)
The message type and the short description are mandatory to present to the user the message. A detailed description can also be given to better explain what's going on. It might be a stack trace, for example.
messageType - The type of the messageshortDescription - A short description of the messagedescription - The detailed description; it can be null or empty.true if the detailed description is not empty i.e. the description
scroll panel is visiblepublic boolean showMessage(java.lang.String shortDescription,
java.lang.Throwable t)
This method shows an error message, by setting the stack trace of the passed Throwable
in the detailed description of the error.
The throwable and the short description are mandatory to present to the user the
message.
shortDescription - A short description of the messaget - The not null throwable to be displayed in the detailed text area.true if the detailed description is not empty i.e. the description
scroll panel is visiblepublic void removeMessage()
This happens when the user presses the OK button but it might happen when the abnormal situation has been fixed and therefore jlog has no reason to ask for the attention of the user. One example could be that of an automatic reconnection.
public javax.swing.JButton getAckButton()
public void addAckListener(MessageWidget.MessageWidgetListener listener)
listener - The listener to add to the list of listeners;
the listener is not added if it is already in the listpublic boolean removeAckListener(MessageWidget.MessageWidgetListener listener)
listener - The listener to remove from the list of listeners;true if an element was removed as a result of this call