001/* ---------------------------------------------------------------------------- 002 The Kiwi Toolkit - A Java Class Library 003 Copyright (C) 1998-2004 Mark A. Lindner 004 005 This library is free software; you can redistribute it and/or 006 modify it under the terms of the GNU General Public License as 007 published by the Free Software Foundation; either version 2 of the 008 License, or (at your option) any later version. 009 010 This library is distributed in the hope that it will be useful, 011 but WITHOUT ANY WARRANTY; without even the implied warranty of 012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 General Public License for more details. 014 015 You should have received a copy of the GNU General Public License 016 along with this library; if not, write to the Free Software 017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 018 02111-1307, USA. 019 020 The author may be contacted at: mark_a_lindner@yahoo.com 021 ---------------------------------------------------------------------------- 022 $Log: DialogDismissEvent.java,v $ 023 Revision 1.6 2004/05/05 22:16:57 markl 024 comment block updates 025 026 Revision 1.5 2003/01/19 09:34:08 markl 027 Javadoc & comment header updates. 028 029 Revision 1.4 2001/03/12 05:56:36 markl 030 Javadoc cleanup. 031 032 Revision 1.3 2001/03/12 01:38:46 markl 033 Source code cleanup. 034 035 Revision 1.2 1999/01/10 03:26:20 markl 036 added GPL header & RCS tag 037 ---------------------------------------------------------------------------- 038*/ 039 040package kiwi.event; 041 042import java.awt.Dialog; 043 044/** Event generated by one of the Kiwi dialog classes when it has been 045 * dismissed via an <i>OK</i> or <i>Cancel</i> button. The event object 046 * stores the type of dismissal. 047 * 048 * @see kiwi.event.DialogDismissListener 049 * 050 * @author Mark Lindner 051 */ 052 053public class DialogDismissEvent 054 { 055 /** Dismissal type; the <i>Cancel</i> button was pressed. */ 056 public static final int CANCEL = 0; 057 058 /** Dismissal type; the <i>OK</i> button was pressed. */ 059 public static final int OK = 1; 060 061 private int type; 062 private Object obj; 063 private Dialog source; 064 065 /** Construct a new <code>DialogDismissEvent</code>. 066 * 067 * @param source The dialog that is the source of this event. 068 * @param type The dismissal type; one of the numeric constants defined 069 * above. 070 */ 071 072 public DialogDismissEvent(Dialog source, int type) 073 { 074 this(source, type, null); 075 } 076 077 /** Construct a new <code>DialogDismissEvent</code>. 078 * 079 * @param source The dialog that is the source of this event. 080 * @param type The dismissal type; one of the numeric constants defined 081 * above. 082 * @param userObject An arbitrary user object to associate with this event. 083 */ 084 085 public DialogDismissEvent(Dialog source, int type, Object userObject) 086 { 087 this.source = source; 088 this.type = type; 089 this.obj = userObject; 090 } 091 092 /** Get the source of this event. 093 * 094 * @return the <code>Dialog</code> that generated this event. 095 */ 096 097 public Dialog getSource() 098 { 099 return(source); 100 } 101 102 /** Get the user object associated with this event. 103 * 104 * @return The user object associated with this event, or <code>null</code> 105 * if none was associated. 106 */ 107 108 public Object getUserObject() 109 { 110 return(obj); 111 } 112 113 /** Determine if the dialog was cancelled. 114 * 115 * @return <code>true</code> if the dialog was dismissed via the 116 * <i>Cancel</i> button; equivalent to <code>getType() == 117 * CANCEL</code>. 118 */ 119 120 public boolean isCancelled() 121 { 122 return(type == CANCEL); 123 } 124 125 /** Get the dismissal type. 126 * 127 * @return The dismissal type; one of the numeric constants defined above. 128 */ 129 130 public int getType() 131 { 132 return(type); 133 } 134 135 } 136 137/* end of source file */