Class PsDialog
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- java.awt.Window
-
- java.awt.Dialog
-
- jv.object.PsDialog
-
- All Implemented Interfaces:
- java.awt.event.ActionListener, java.awt.event.ContainerListener, java.awt.event.KeyListener, java.awt.event.WindowListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, PsUpdateIf
- Direct Known Subclasses:
- PdColor_Dialog, PgExport_Dialog, PjImportModel_Dialog, PjWorkshop_Dialog, PnExplode_Dialog, PsConsole, PsLicense_IP, PwIntegralLine_Dialog
public class PsDialog extends java.awt.Dialog implements PsUpdateIf, java.awt.event.ActionListener, java.awt.event.ContainerListener, java.awt.event.KeyListener, java.awt.event.WindowListener
Basic class for dialogs extending java.awt.Dialog by some minor features. E.g. dialog is destroyed when it receives a WINDOW.DESTROY event, and it has an easy mechanism to insert standard buttons at bottom part of dialog. The actionPerformed() method supplies default event handling which is usually sufficient.When dialog window is canceled by pressing the cross in one of its corners, then the same operations are performed as if the user had pressed the CANCEL button.
- See Also:
PsPanel, Serialized Form- Author:
- Konrad Polthier
- Version:
- 15.11.12, 3.10 revised (kp) Button Apply added.
01.10.06, 3.00 revised (kp) Handle ESC key and cancel dialog.
06.02.05, 2.30 revised (kp) Flag BUTTON_CANCEL_DISABLED removed since handled elsewhere.
23.07.03, 2.20 revised (kp) No longer implements ItemListener interface.
06.03.03, 2.10 revised (kp) New optional button clear added.
09.11.02, 2.00 revised (kp) ActionSupport implemented.
03.11.02, 1.80 revised (kp) When window is cancelled then perform same operations as with CANCEL button.
22.03.02, 1.70 revised (ur) Internationalization.
01.11.00, 1.60 revised (kp) New button type BUTTON_SAVE added.
26.09.00, 1.50 revised (kp) Methods addPanel() and addBottomButtons() removed.
20.04.00, 1.40 revised (kp) Viewer removed as key listener.
03.10.99, 1.30 revised (kp) Implemented WindowListener instead of separate windowAdapter.
07.08.99, 1.20 revised (kp) Conversion to AWT 1.1
12.06.99, 1.10 revised (kp) Added hide button.
00.00.98, 1.00 created (kp)
-
-
Nested Class Summary
-
Field Summary
Fields Modifier and Type Field and Description static intBUTTON_APPLYstatic intBUTTON_CANCELstatic intBUTTON_CLEARstatic intBUTTON_CLOSEstatic intBUTTON_HIDEstatic intBUTTON_LOADstatic intBUTTON_OKstatic intBUTTON_RESETstatic intBUTTON_SAVE
-
Constructor Summary
Constructors Constructor and Description PsDialog(java.awt.Frame frame, boolean modal)Create an initially invisible new dialog without title and modal status.PsDialog(java.awt.Frame frame, java.lang.String name, boolean modal)Create an initially invisible new dialog with given title and modal status.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description voidactionPerformed(java.awt.event.ActionEvent event)Method forwards action events issued by buttons.voidaddActionListener(java.awt.event.ActionListener listener)Action events are sent when a user clicks on OK or CANCEL button, presses ESC, doubleclicks on a model in the model dialog or presses <return> in the textfield of the small info panel.voidcomponentAdded(java.awt.event.ContainerEvent evt)This function is called whenever a Component or a Container is added to another Container belonging to this Dialog.voidcomponentRemoved(java.awt.event.ContainerEvent evt)This function is called whenever a Component or a Container is removed from another Container belonging to this Dialog.java.awt.PanelgetBottomButtons(int flag)Convenient way to get a panel with standard buttons.PsUpdateIfgetFather()Return parent of this dialog.java.awt.InsetsgetInsets()OverwriteContainer.getInsets()to create a border measured in pixels around this panel.intgetUserAction()Get index of standard button pressed by user.voidinit()This initialization method simply set the font of this dialog.booleaninstanceOf(java.lang.String aClassName)Deprecated.use "if (getClass() == PsObject.class)" insteadvoidkeyPressed(java.awt.event.KeyEvent evt)This function is called whenever a Component belonging to this Dialog (or the Dialog itself) gets the KEY_PRESSED event.voidkeyReleased(java.awt.event.KeyEvent evt)This function is called whenever a Component belonging to this Dialog (or the Dialog itself) gets the KEY_RELEASED event.voidkeyTyped(java.awt.event.KeyEvent evt)Unused method of interface KeyListener.voidremoveActionListener(java.awt.event.ActionListener listener)Removes (one occurrence of) a listener from internal list.voidreset()Method should be overridden by subclasses, maybe to reset itself.java.awt.LabelsetHeader(java.lang.String header)Set string of panel header and return labelm_lHeader.voidsetInsetSize(int size)Set the global inset size.voidsetLocation(int x, int y)Overwrites superclass method, better have an own method setLocationDPI() to avoid multiple invocations of method.voidsetParent(PsUpdateIf object)Set parent of this dialog.voidsetSize(int w, int h)Overwrites superclass method, better have an own method setSizeDPI() to avoid multiple invocations of method.booleanupdate(java.lang.Object event)Update the class whenever a child has changed.voidwindowActivated(java.awt.event.WindowEvent event)Method does nothing.voidwindowClosed(java.awt.event.WindowEvent event)Method does nothing.voidwindowClosing(java.awt.event.WindowEvent event)Dispose window if user clicks on 'delete'-cross of title bar.voidwindowDeactivated(java.awt.event.WindowEvent event)Method does nothing.voidwindowDeiconified(java.awt.event.WindowEvent event)Method does nothing.voidwindowIconified(java.awt.event.WindowEvent event)Method does nothing.voidwindowOpened(java.awt.event.WindowEvent event)Method does nothing.-
Methods inherited from class java.awt.Dialog
addNotify, getAccessibleContext, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, setVisible, 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, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, 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, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, 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, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jv.object.PsUpdateIf
getName
-
-
-
-
Field Detail
-
BUTTON_CANCEL
public static final int BUTTON_CANCEL
- See Also:
- Constant Field Values
-
BUTTON_HIDE
public static final int BUTTON_HIDE
- See Also:
- Constant Field Values
-
BUTTON_OK
public static final int BUTTON_OK
- See Also:
- Constant Field Values
-
BUTTON_RESET
public static final int BUTTON_RESET
- See Also:
- Constant Field Values
-
BUTTON_CLOSE
public static final int BUTTON_CLOSE
- See Also:
- Constant Field Values
-
BUTTON_SAVE
public static final int BUTTON_SAVE
- See Also:
- Constant Field Values
-
BUTTON_CLEAR
public static final int BUTTON_CLEAR
- See Also:
- Constant Field Values
-
BUTTON_LOAD
public static final int BUTTON_LOAD
- See Also:
- Constant Field Values
-
BUTTON_APPLY
public static final int BUTTON_APPLY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PsDialog
public PsDialog(java.awt.Frame frame, java.lang.String name, boolean modal)Create an initially invisible new dialog with given title and modal status. Arguments are passed in the same order to java.awt.Dialog.Initial layout manager is jv.object.PsStackLayout.
- Parameters:
frame- parent frame is owner of this dialogname- title of this dialogmodal- if true, dialog blocks input to the parent window when shown- See Also:
PsDialog(Frame, boolean)
-
PsDialog
public PsDialog(java.awt.Frame frame, boolean modal)Create an initially invisible new dialog without title and modal status. Arguments are passed in the same order to java.awt.Dialog.Initial layout manager is jv.object.PsStackLayout.
- Parameters:
frame- parent frame is owner of this dialogmodal- if true, dialog blocks input to the parent window when shown- See Also:
PsDialog(Frame, String, boolean)
-
-
Method Detail
-
init
public void init()
This initialization method simply set the font of this dialog.
-
setLocation
public void setLocation(int x, int y)Overwrites superclass method, better have an own method setLocationDPI() to avoid multiple invocations of method.- Overrides:
setLocationin classjava.awt.Window- Since:
- JavaView 4.65.001
- Version:
- 29.09.16, 1.00 created (kp).
- HACK:
- (kp, 29.09.16) Overwrites superclass method to provide scaling for HDPI.
-
setSize
public void setSize(int w, int h)Overwrites superclass method, better have an own method setSizeDPI() to avoid multiple invocations of method.- Overrides:
setSizein classjava.awt.Window- Since:
- JavaView 4.65.001
- Version:
- 29.09.16, 1.00 created (kp).
- ToDo:
- (kp, 29.09.16) Overwrites superclass method to provide scaling for HDPI.
-
getInsets
public java.awt.Insets getInsets()
OverwriteContainer.getInsets()to create a border measured in pixels around this panel. The border is either uniformly determined by setInsetSize(int) or by, additionally, specifying a vertical inset size using setInsetSizeVertical(int).- Overrides:
getInsetsin classjava.awt.Container- Since:
- JavaView 3.97.032
- See Also:
PsPanel.setInsetSize(int),PsPanel.setInsetSizeVertical(int),PsPanel.setBorderType(int)- Version:
- 25.11.06, 1.00 created (kp) Copied from PsPanel.
-
setInsetSize
public void setInsetSize(int size)
Set the global inset size. This call resets a previous vertical inset size to the new global inset size.- Since:
- JavaView 3.97.032
- Version:
- 25.11.06, 1.00 created (kp) Copied from PsPanel.
-
getBottomButtons
public java.awt.Panel getBottomButtons(int flag)
Convenient way to get a panel with standard buttons. The return panel with buttons is not yet added to this dialog. The class PsDialog manages ActionEvents issued by the buttons. Overwrite actionPerformed() to perform your own action.Usage:
Panel pButtons = dialog.getBottomButtons(PsDialog.BUTTON_CANCEL | PsDialog.BUTTON_OK); dialog.add(pButtons, BorderLayout.SOUTH);
If a modal dialog returns, the dialog can be asked about the user action:if (dialog.getUserAction() == PsDialog.BUTTON_CANCEL) { ... }- Parameters:
flag- one of the static buttons identifiers like PsDebug.BUTTON_OK.- Returns:
- panel with buttons to be added to this dialog.
-
setHeader
public java.awt.Label setHeader(java.lang.String header)
Set string of panel header and return labelm_lHeader. Method does not add the header to the panel.
-
instanceOf
public final boolean instanceOf(java.lang.String aClassName)
Deprecated. use "if (getClass() == PsObject.class)" insteadReturn true iff string is exact classname of current instance. Even if string denotes a super class method returnsfalse. This method is different from Java operatorinstanceofwhich is true even if current instance is subclass of class 'aClassName'.The current implementation checks the string only against the classname without the prefixed package names. This may change in future implementations of this method.
- Parameters:
aClassName- name of class without package identifiers- Returns:
- true if current object is exact instance of class
-
getFather
public PsUpdateIf getFather()
Return parent of this dialog.- Specified by:
getFatherin interfacePsUpdateIf- Returns:
- parent of this dialog
- See Also:
setParent(PsUpdateIf),update(Object)
-
setParent
public void setParent(PsUpdateIf object)
Set parent of this dialog. Should be overwritten by subclasses to initialize according to the data of the parent object. Subclasses should call super.setParent(object) as one of the first statements.- Specified by:
setParentin interfacePsUpdateIf- Parameters:
object- will receive events whichthisdoes not handle- See Also:
getFather(),update(Object)
-
update
public boolean update(java.lang.Object event)
Update the class whenever a child has changed. Method is usually invoked from a child.- Specified by:
updatein interfacePsUpdateIf- Parameters:
event- carries a lot of information- Returns:
- true if event has been handled, otherwise false
- See Also:
getFather(),setParent(PsUpdateIf)
-
reset
public void reset()
Method should be overridden by subclasses, maybe to reset itself. This method does nothing here but allows to reset the dialog from a script.- Version:
- 23.07.03, 1.10 revised (kp) No longer update parent.
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent event)
Method forwards action events issued by buttons. Method first calls setUserAction with the appropriate button identifier and then calls dispose(), hide(), or reset() methods of this dialog.- Specified by:
actionPerformedin interfacejava.awt.event.ActionListener
-
getUserAction
public int getUserAction()
Get index of standard button pressed by user. Possible values are PsDialog.BUTTON_OK, PsDialog.BUTTON_CANCEL etc.
-
windowOpened
public void windowOpened(java.awt.event.WindowEvent event)
Method does nothing.- Specified by:
windowOpenedin interfacejava.awt.event.WindowListener
-
windowClosed
public void windowClosed(java.awt.event.WindowEvent event)
Method does nothing.- Specified by:
windowClosedin interfacejava.awt.event.WindowListener
-
windowDeiconified
public void windowDeiconified(java.awt.event.WindowEvent event)
Method does nothing.- Specified by:
windowDeiconifiedin interfacejava.awt.event.WindowListener
-
windowIconified
public void windowIconified(java.awt.event.WindowEvent event)
Method does nothing.- Specified by:
windowIconifiedin interfacejava.awt.event.WindowListener
-
windowDeactivated
public void windowDeactivated(java.awt.event.WindowEvent event)
Method does nothing.- Specified by:
windowDeactivatedin interfacejava.awt.event.WindowListener
-
windowActivated
public void windowActivated(java.awt.event.WindowEvent event)
Method does nothing.- Specified by:
windowActivatedin interfacejava.awt.event.WindowListener
-
windowClosing
public void windowClosing(java.awt.event.WindowEvent event)
Dispose window if user clicks on 'delete'-cross of title bar. Currently, method just callsdispose().- Specified by:
windowClosingin interfacejava.awt.event.WindowListener- Version:
- 03.11.02, 1.20 revised (kp) When window is cancelled then perform same operations as with CANCEL button.
04.09.00, 1.10 revised (kp) Invocation of reset() deactivated since PuDouble_Config sets all values to default.
-
addActionListener
public void addActionListener(java.awt.event.ActionListener listener)
Action events are sent when a user clicks on OK or CANCEL button, presses ESC, doubleclicks on a model in the model dialog or presses <return> in the textfield of the small info panel.The event is sent after the model is loaded. You can check the type of the action via
getUserAction().Listeners will receive an ActionEvent whose keyId is one of the possibilities of PsDialog.BUTTON_{OK, CANCEL, ...}. For example, workshop dialog use such events to reset the scene when CANCEL or ESC has been pressed.
-
removeActionListener
public void removeActionListener(java.awt.event.ActionListener listener)
Removes (one occurrence of) a listener from internal list. Registered listeners will be effected byfireAction(ActionEvent).
-
componentAdded
public void componentAdded(java.awt.event.ContainerEvent evt)
This function is called whenever a Component or a Container is added to another Container belonging to this Dialog.Method is part of container listener interface.
- Specified by:
componentAddedin interfacejava.awt.event.ContainerListener
-
componentRemoved
public void componentRemoved(java.awt.event.ContainerEvent evt)
This function is called whenever a Component or a Container is removed from another Container belonging to this Dialog.Method is part of container listener interface.
- Specified by:
componentRemovedin interfacejava.awt.event.ContainerListener
-
keyPressed
public void keyPressed(java.awt.event.KeyEvent evt)
This function is called whenever a Component belonging to this Dialog (or the Dialog itself) gets the KEY_PRESSED event.- Specified by:
keyPressedin interfacejava.awt.event.KeyListener
-
keyReleased
public void keyReleased(java.awt.event.KeyEvent evt)
This function is called whenever a Component belonging to this Dialog (or the Dialog itself) gets the KEY_RELEASED event.- Specified by:
keyReleasedin interfacejava.awt.event.KeyListener
-
keyTyped
public void keyTyped(java.awt.event.KeyEvent evt)
Unused method of interface KeyListener.- Specified by:
keyTypedin interfacejava.awt.event.KeyListener
-
-
"