com.ccg.swing
Class OkCancelDialog

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by javax.swing.JDialog
                      extended by com.ccg.swing.OkCancelDialog
All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants

public class OkCancelDialog
extends JDialog
implements ActionListener

Not ready for prime time - please ignore for now.

 class Example {
   public void main(String[] args) {
     com.ccg.swing.OkCancelDialog o = new com.ccg.swing.OkCancelDialog();
          System.out.println(o);
   }
 }
 

Since:
1.0
Version:
$Revision: 1.2 $
Author:
$Author: pkb $
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JDialog
JDialog.AccessibleJDialog
 
Nested classes/interfaces inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog
 
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int CANCEL
          Constant returned by getResult() when "Cancel" button pressed.
static int OK
          Constant returned by getResult() when "OK" button pressed.
 
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
OkCancelDialog(JFrame parent, JComponent yourPanel, ResourceBundle rb, String id)
          Initializes object using values from a ResourceBundle.
 
Method Summary
 void actionPerformed(ActionEvent ae)
          Callback method when the "OK" or "Cancel" button are pressed.
 int getResult()
          Get the results (whether user hit "Cancel" or "Ok").
 boolean onCancel()
          Method invoked when the "Cancel" button is pressed.
 boolean onOK()
          Method invoked when the "OK" button is pressed.
 void setResult(int val)
          Set the results (whether user hit "Cancel" or "Ok").
 
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, dispose, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, 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, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, 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, 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, isOpaque, 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, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OK

public static final int OK
Constant returned by getResult() when "OK" button pressed.

Since:
1.0
See Also:
getResult(), Constant Field Values

CANCEL

public static final int CANCEL
Constant returned by getResult() when "Cancel" button pressed.

Since:
1.0
See Also:
getResult(), Constant Field Values
Constructor Detail

OkCancelDialog

public OkCancelDialog(JFrame parent,
                      JComponent yourPanel,
                      ResourceBundle rb,
                      String id)
Initializes object using values from a ResourceBundle.

This method constructs a "OK", "Cancel" type of dialog box using strings from a resource bundle. This allows one to add any JComponent to the dialog box.

The static strings which are used come from the resource bundle passed to the constructor (prefixed by the "id" parameter). For example, if you set your "id" parameter to "pizza", then you would want the following entries in your resource bundle:

 pizza.title=Pizza Order Input
 pizza.ok=Place Order
 pizza.cancel=Forget It
 

The above resources MUST be found in the resource bundle provided (we aren't forgiving). If additional resources are recognized in the future, the will be optional (we won't break old code).

Since:
1.0
See Also:
onOK()
Method Detail

onCancel

public boolean onCancel()
Method invoked when the "Cancel" button is pressed.

This method will be invoked if the user presses the "Cancel" button. This method needs to return true if you want to permit the user to do the "Cancel" operation. For the most part, you should always want to allow the customer to do this - however, if you need to validate something first (which you shouldn't on a "Cancel" operation), you can do so here and return "false" if the contents entered in the dialog box are invalid.

Returns:
true if it's OK to "Cancel" (this default implementation always returns true).
Since:
1.0
See Also:
onOK()

actionPerformed

public void actionPerformed(ActionEvent ae)
Callback method when the "OK" or "Cancel" button are pressed.

This method is called when the user presses the "OK" or "Cancel" button. If we are able to validate the panel (via onOK() or onCancel()) we will set the result value appropriately and close the dialog box.

Specified by:
actionPerformed in interface ActionListener
Parameters:
ae - The ActionEvent object associated with the cause.
Since:
1.0
See Also:
onOK()

onOK

public boolean onOK()
Method invoked when the "OK" button is pressed.

This method will be invoked if the user presses the "OK" button. This method needs to return true if you want to permit the user to close the dialog. You can override this method if you want to validate the contents of your input fields and return false if the user needs to fix something. This is a handy method to overide to validate the user input.

Returns:
true if it's OK to continue (if user input was valid), false if not (this default implementation always returns true).
Since:
1.0
See Also:
onCancel()

setResult

public void setResult(int val)
Set the results (whether user hit "Cancel" or "Ok").

Parameters:
val - New int value to assign.
See Also:
getResult()

getResult

public int getResult()
Get the results (whether user hit "Cancel" or "Ok").

Returns:
Current result value - should be either OK or CANCEL.
See Also:
setResult(int)


Copyright 1998-1998-2006 null. All Rights Reserved.