SalesPoint Framework v3.1

sale
Class JDisplayDialog

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Dialog
                  extended byjavax.swing.JDialog
                      extended bysale.JDisplayDialog
All Implemented Interfaces:
Accessible, Display, FormSheetContainer, ImageObserver, MenuContainer, RootPaneContainer, Serializable, WindowConstants

public class JDisplayDialog
extends JDialog
implements Display, FormSheetContainer

A JDialog that can display Form- and MenuSheets.

You can use this frame to pop up messages and dialogs in extra windows, while maintaining consistency with the rest of the GUI by using the familiar FormSheet look'n'feel.

The frame will display one FormSheet, and, by default, will close when the FormSheet is closed. Closing the frame using the systems menu or any other OS dependent gesture will result in a call to FormSheet.cancel() on the FormSheet.

Also, the frame may display a MenuSheet. It can therefore be used wherever a Display can be used.

Attention: This class is not meant to be serialized.

Since:
v2.0
Author:
Steffen Zschaler
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JDialog
JDialog.AccessibleJDialog
 
Nested classes inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog
 
Nested classes inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  EventListenerList m_ellListeners
          The list of listeners.
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JDisplayDialog()
          Create a new JDisplayDialog.
JDisplayDialog(JFrame jfOwner)
          Create a new JDisplayDialog with the given owner.
 
Method Summary
 void addFormSheetListener(FormSheetListener fsl)
          Add a listener to receive notification on the JDisplayDialog's FormSheet.
 void closeFormSheet()
          Close the current FormSheet.
 void closeFormSheet(FormSheet fs)
          Close a FormSheet.
 void dispose()
          In addition to disposing of the peer resources, remove the FormSheet and the MenuSheet.
protected  void fireFormSheetRemoved(FormSheet fs, boolean fExplicit)
          Fire an event to all FormSheetListeners indicating that a FormSheet was removed from this display.
protected  void fireFormSheetSet(FormSheet fs)
          Fire an event to all FormSheetListeners indicating that a FormSheet was set on this display.
protected  void formSheetClosed()
          Hook method called when the FormSheet was closed.
 FormSheet getFormSheet()
          Return the FormSheet that is currently attached to the display.
 MenuSheet getMenuSheet()
          Return the MenuSheet that is currently attached to the display.
 boolean isUseableDisplay()
          Return true to indicate this is a useable display.
 void load(ObjectInputStream ois)
          Restores the display from a stream.
static void main(String[] args)
          JDisplayDialog test suite.
 void onFormSheetButtonAdded(FormSheet fs, FormSheet.FormButton fb)
          Notification event informing that a button was added to the FormSheet's button bar.
 void onFormSheetButtonRemoved(FormSheet fs, FormSheet.FormButton fb)
          Notification event informing that a button was removed from the FormSheet's button bar.
 void onFormSheetButtonsCleared(FormSheet fs)
          Notification event informing that all buttons were removed from a FormSheet's button bar.
 void onFormSheetCaptionChanged(FormSheet fs, String sNewCaption)
          Notification event informing about a change of a FormSheet's caption.
 void onFormSheetComponentChanged(FormSheet fs, JComponent jcmpNew)
          Notification event informing about a change of a FormSheet's component.
 void popUpFormSheet(FormSheet fs)
          Open a fresh JDisplayDialog and display the FormSheet in it.
 void popUpFormSheet(FormSheet fsParent, FormSheet fsToSet)
          Opens a fresh JDisplayDialog which is assigned to a FormSheet and displays another FormSheet in it.
 void removeFormSheetListener(FormSheetListener fsl)
          Remove a listener to receive notification on the JDisplayDialog's FormSheet.
 void save(ObjectOutputStream oos)
          Writes the display to a stream.
 void setFormSheet(FormSheet fs)
          Set and display a FormSheet.
 void setMenuSheet(MenuSheet ms)
          Remove any old MenuSheet and display the new one.
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Dialog
addNotify, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, toBack, 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, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, 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, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, 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, isOpaque, 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, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface sale.Display
getBounds, setBounds, toFront
 

Field Detail

m_ellListeners

protected transient EventListenerList m_ellListeners
The list of listeners.

Constructor Detail

JDisplayDialog

public JDisplayDialog()
Create a new JDisplayDialog.


JDisplayDialog

public JDisplayDialog(JFrame jfOwner)
Create a new JDisplayDialog with the given owner.

Parameters:
jfOwner - the JFrame owning the display dialog.
Method Detail

closeFormSheet

public void closeFormSheet(FormSheet fs)
Close a FormSheet.

If a FormSheet is closed, by default, the JDisplayDialog containing it is also closed. You can, however, alter this behavior by overriding formSheetClosed().

Specified by:
closeFormSheet in interface FormSheetContainer
Parameters:
fs - the FormSheet to be closed.
Override:
Never Instead override formSheetClosed().

formSheetClosed

protected void formSheetClosed()
Hook method called when the FormSheet was closed.

Override:
Sometimes The default implementation closes the JDisplayDialog.

dispose

public void dispose()
In addition to disposing of the peer resources, remove the FormSheet and the MenuSheet.

Override:
Never

onFormSheetCaptionChanged

public void onFormSheetCaptionChanged(FormSheet fs,
                                      String sNewCaption)
Notification event informing about a change of a FormSheet's caption.

Specified by:
onFormSheetCaptionChanged in interface FormSheetContainer
Parameters:
fs - the FormSheet whose caption changed.
sNewCaption - the new caption of the FormSheet.
Override:
Never

onFormSheetComponentChanged

public void onFormSheetComponentChanged(FormSheet fs,
                                        JComponent jcmpNew)
Notification event informing about a change of a FormSheet's component.

Specified by:
onFormSheetComponentChanged in interface FormSheetContainer
Parameters:
fs - the FormSheet whose component changed.
jcmpNew - the new component of the FormSheet.
Override:
Never

onFormSheetButtonAdded

public void onFormSheetButtonAdded(FormSheet fs,
                                   FormSheet.FormButton fb)
Notification event informing that a button was added to the FormSheet's button bar.

Specified by:
onFormSheetButtonAdded in interface FormSheetContainer
Parameters:
fs - the FormSheet whose button bar changed.
fb - the button that was added to the FormSheet.
Override:
Never

onFormSheetButtonRemoved

public void onFormSheetButtonRemoved(FormSheet fs,
                                     FormSheet.FormButton fb)
Notification event informing that a button was removed from the FormSheet's button bar.

Specified by:
onFormSheetButtonRemoved in interface FormSheetContainer
Parameters:
fs - the FormSheet whose button bar changed.
fb - the button that was removed from the FormSheet.
Override:
Never

onFormSheetButtonsCleared

public void onFormSheetButtonsCleared(FormSheet fs)
Notification event informing that all buttons were removed from a FormSheet's button bar.

Specified by:
onFormSheetButtonsCleared in interface FormSheetContainer
Parameters:
fs - the FormSheet whose button bar was cleared.
Override:
Never

setFormSheet

public void setFormSheet(FormSheet fs)
                  throws InterruptedException
Set and display a FormSheet.

If fs.waitResponse() returns true, setFormSheet() blocks, until the FormSheet is closed by a matching call to closeFormSheet(sale.FormSheet).

Specified by:
setFormSheet in interface Display
Parameters:
fs - the FormSheet to be displayed.
Throws:
InterruptedException - if an interrupt occurs while waiting for the FormSheet to be closed.
Override:
Never

getFormSheet

public FormSheet getFormSheet()
Return the FormSheet that is currently attached to the display.

Specified by:
getFormSheet in interface Display

closeFormSheet

public void closeFormSheet()
Close the current FormSheet.

Specified by:
closeFormSheet in interface Display
Override:
Never

popUpFormSheet

public void popUpFormSheet(FormSheet fs)
                    throws InterruptedException
Open a fresh JDisplayDialog and display the FormSheet in it.

Specified by:
popUpFormSheet in interface Display
Parameters:
fs - the FormSheet to be displayed.
Throws:
InterruptedException - if an interrupt occured while waiting for the FormSheet to be closed.
Override:
Never

popUpFormSheet

public void popUpFormSheet(FormSheet fsParent,
                           FormSheet fsToSet)
                    throws InterruptedException
Opens a fresh JDisplayDialog which is assigned to a FormSheet and displays another FormSheet in it.

Parameters:
fsParent - the FormSheet to which the JDisplayDialog is assigned.
fsToSet - the FormSheet which is displayed by the JDisplayDialog.
Throws:
InterruptedException - if an interrupt occured while waiting for the FormSheet to be closed.
Override:
Never

setMenuSheet

public void setMenuSheet(MenuSheet ms)
Remove any old MenuSheet and display the new one.

Specified by:
setMenuSheet in interface Display
Parameters:
ms - the MenuSheet to be displayed.
Override:
Never

getMenuSheet

public MenuSheet getMenuSheet()
Return the MenuSheet that is currently attached to the display.

Specified by:
getMenuSheet in interface Display

isUseableDisplay

public boolean isUseableDisplay()
Return true to indicate this is a useable display.

Specified by:
isUseableDisplay in interface Display
Override:
Never

addFormSheetListener

public void addFormSheetListener(FormSheetListener fsl)
Add a listener to receive notification on the JDisplayDialog's FormSheet.

Specified by:
addFormSheetListener in interface Display
Parameters:
fsl - the FormSheetListener to be registered.
Override:
Never

removeFormSheetListener

public void removeFormSheetListener(FormSheetListener fsl)
Remove a listener to receive notification on the JDisplayDialog's FormSheet.

Specified by:
removeFormSheetListener in interface Display
Parameters:
fsl - the FormSheetListener to be unregistered.
Override:
Never

fireFormSheetSet

protected void fireFormSheetSet(FormSheet fs)
Fire an event to all FormSheetListeners indicating that a FormSheet was set on this display. As FormSheet setting is always explicit, no extra parameter is necessary.

Parameters:
fs - the FormSheet that was set
Override:
Never

fireFormSheetRemoved

protected void fireFormSheetRemoved(FormSheet fs,
                                    boolean fExplicit)
Fire an event to all FormSheetListeners indicating that a FormSheet was removed from this display.

Parameters:
fs - the FormSheet that was set
fExplicit - true, if the FormSheet was closed explicitly, i.e. either by a call to one of the closeFormSheet methods or by setFormSheet (null).
See Also:
closeFormSheet(), closeFormSheet(FormSheet), setFormSheet(sale.FormSheet)
Override:
Never

main

public static void main(String[] args)
JDisplayDialog test suite.


load

public void load(ObjectInputStream ois)
          throws IOException,
                 ClassNotFoundException
Description copied from interface: Display
Restores the display from a stream.

As displays should not be serialized when making the Shop persistent, they cannot be normally deserialized. Instead they should individually read the attributes they previously saved. The attributes must be read in the same order they have previously been writtn.

Attention: The current class that has been written by the save() method must not be read here!

Example:
 FormSheet fsCurrent = (FormSheet)ois.readObject();
 MenuSheet msCurrent = (MenuSheet)ois.readObject();
 ...
 

Specified by:
load in interface Display
Parameters:
ois - the stream to read attributes from
Throws:
IOException
ClassNotFoundException

save

public void save(ObjectOutputStream oos)
          throws IOException
Description copied from interface: Display
Writes the display to a stream.

Displays should not be serialized as a whole. Instead use this method to individually write all attributes of the display to the stream.

Attention: The very first attribute to be written must be the display's class!

Example:
 oos.writeObject(getClass());
 oos.writeObject(fsCurrent); //current FormSheet
 oos.writeObject(msCurrent); //current MenuSheet
 ...
 

Specified by:
save in interface Display
Throws:
IOException

SalesPoint Framework v3.1