|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Window
java.awt.Dialog
javax.swing.JDialog
com.ccg.swing.OkCancelDialog
public class OkCancelDialog
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);
}
}
| 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 java.awt.Dialog |
|---|
addNotify, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int OK
getResult() when "OK"
button pressed.
getResult(),
Constant Field Valuespublic static final int CANCEL
getResult() when
"Cancel" button pressed.
getResult(),
Constant Field Values| Constructor Detail |
|---|
public OkCancelDialog(JFrame parent,
JComponent yourPanel,
ResourceBundle rb,
String id)
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).
onOK()| Method Detail |
|---|
public boolean onCancel()
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.
onOK()public void actionPerformed(ActionEvent ae)
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.
actionPerformed in interface ActionListenerae - The ActionEvent object associated with the cause.onOK()public boolean onOK()
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.
onCancel()public void setResult(int val)
val - New int value to assign.getResult()public int getResult()
OK or CANCEL.setResult(int)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||