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: KMessageDialog.java,v $ 023 Revision 1.12 2004/05/05 23:20:24 markl 024 comment block updates 025 026 Revision 1.11 2004/03/16 06:43:39 markl 027 LocaleManager method change 028 029 Revision 1.10 2003/01/19 09:38:51 markl 030 Added new constructors that take a parent dialog. 031 032 Revision 1.9 2001/03/20 00:54:55 markl 033 Fixed deprecated calls. 034 035 Revision 1.8 2001/03/12 09:56:55 markl 036 KLabel/KLabelArea changes. 037 038 Revision 1.7 2001/03/12 05:19:59 markl 039 Source code cleanup. 040 041 Revision 1.6 1999/07/19 04:10:17 markl 042 Minor tweaks. 043 044 Revision 1.5 1999/06/14 00:50:26 markl 045 no change 046 047 Revision 1.4 1999/06/03 09:39:59 markl 048 Fixed call to KLabel constructor. 049 050 Revision 1.3 1999/04/19 06:06:08 markl 051 I18N changes, new constructor. 052 053 Revision 1.2 1999/01/10 03:22:17 markl 054 added GPL header & RCS tag 055 ---------------------------------------------------------------------------- 056*/ 057 058package kiwi.ui.dialog; 059 060import java.awt.*; 061import java.awt.event.*; 062import javax.swing.*; 063 064import kiwi.ui.*; 065import kiwi.util.*; 066 067/** This class represents a <i>Kiwi</i> message dialog. This dialog displays a 068 * textual message, and has an <i>OK</i> button. 069 * 070 * <p><center> 071 * <img src="snapshot/KMessageDialog.gif"><br> 072 * <i>An example KMessageDialog.</i> 073 * </center> 074 * 075 * @author Mark Lindner 076 */ 077 078public class KMessageDialog extends ComponentDialog 079 { 080 private KLabelArea l_text; 081 082 /** Construct a new <code>KMessageDialog</code>. Constructs a new, modal 083 * <code>KMessageDialog</code> with a default window title. 084 * 085 * @param parent The parent window for this dialog. 086 */ 087 088 public KMessageDialog(Frame parent) 089 { 090 this(parent, "", true); 091 } 092 093 /** Construct a new <code>KMessageDialog</code>. Constructs a new, modal 094 * <code>KMessageDialog</code> with a default window title. 095 * 096 * @param parent The parent window for this dialog. 097 * 098 * @since Kiwi 1.4 099 */ 100 101 public KMessageDialog(Dialog parent) 102 { 103 this(parent, "", true); 104 } 105 106 /** Construct a new <code>KMessageDialog</code>. 107 * 108 * @param parent The parent window for the dialog. 109 * @param title The title for the dialog. 110 * @param modal A flag specifying whether this dialog will be modal. 111 */ 112 113 public KMessageDialog(Frame parent, String title, boolean modal) 114 { 115 super(parent, title, modal, false); 116 setResizable(false); 117 } 118 119 /** Construct a new <code>KMessageDialog</code>. 120 * 121 * @param parent The parent window for the dialog. 122 * @param title The title for the dialog. 123 * @param modal A flag specifying whether this dialog will be modal. 124 * 125 * @since Kiwi 1.4 126 */ 127 128 public KMessageDialog(Dialog parent, String title, boolean modal) 129 { 130 super(parent, title, modal, false); 131 setResizable(false); 132 } 133 134 /** Show or hide the dialog. */ 135 136 public void setVisible(boolean flag) 137 { 138 if(flag) 139 b_ok.requestFocus(); 140 super.setVisible(flag); 141 } 142 143 /** Build the dialog user interface. */ 144 145 protected Component buildDialogUI() 146 { 147 LocaleData loc = LocaleManager.getDefault().getLocaleData("KiwiDialogs"); 148 149 l_text = new KLabelArea(loc.getMessage("kiwi.dialog.prompt.message"), 3, 150 30); 151 l_text.setForeground(Color.black); 152 153 setIcon(KiwiUtils.getResourceManager().getIcon("exclamation.gif")); 154 setComment(""); 155 if(getTitle().length() == 0) 156 setTitle(loc.getMessage("kiwi.dialog.title.message")); 157 158 return(l_text); 159 } 160 161 /** Set the message. Sets the dialog's message. 162 * 163 * @param text The text for the message. 164 */ 165 166 public void setMessage(String text) 167 { 168 l_text.setText(text); 169 pack(); 170 } 171 172 } 173 174/* end of source file */