2 Copyright (C) 2002 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
41 import javax
.swing
.plaf
.*;
42 import javax
.accessibility
.AccessibleContext
;
43 import javax
.accessibility
.AccessibleRole
;
44 import javax
.accessibility
.AccessibleState
;
45 import javax
.accessibility
.AccessibleStateSet
;
47 public class JOptionPane
extends JComponent
49 public static final int DEFAULT_OPTION
= 0;
50 public static final int YES_NO_OPTION
= 1;
51 public static final int YES_NO_CANCEL_OPTION
= 2;
52 public static final int OK_CANCEL_OPTION
= 3;
53 public static final int YES_OPTION
= 4;
54 public static final int NO_OPTION
= 5;
55 public static final int CANCEL_OPTION
= 6;
56 public static final int OK_OPTION
= 7;
57 public static final int CLOSED_OPTION
= 8;
59 public static final int ERROR_MESSAGE
= 0;
60 public static final int INFORMATION_MESSAGE
= 1;
61 public static final int WARNING_MESSAGE
= 2;
62 public static final int QUESTION_MESSAGE
= 3;
63 public static final int PLAIN_MESSAGE
= 4;
65 final static String VALUE_PROPERTY
= "value_prop";
66 final static String INPUT_VALUE_PROPERTY
= "input_value_prop";
68 final static String UNINITIALIZED_VALUE
= "uninit";
70 // Ronald: shouldnt by public ?
78 public JDialog dialog
;
80 /*****************************************************************************
86 ***********************************/
95 this(m
, PLAIN_MESSAGE
);
101 this(m
, mtype
, DEFAULT_OPTION
);
104 JOptionPane(Object m
,
108 this(m
, mtype
, otype
, null);
111 JOptionPane(Object m
,
116 this(m
, mtype
, otype
, icon
, null);
119 JOptionPane(Object m
,
125 this(m
, mtype
, otype
, icon
, args
, null);
128 JOptionPane(Object msg
,
135 // this(m, mtype, otype, icon, args, init);
147 /*****************************************************************************
153 ***********************************/
156 public void setValue(Object v
)
158 public Object
getValue()
161 public String
getUIClassID()
162 { return "JOptionPane"; }
165 public void setUI(OptionPaneUI ui
) {
169 public OptionPaneUI
getUI() {
170 return (OptionPaneUI
)ui
;
173 public void updateUI() {
174 setUI((OptionPaneUI
)UIManager
.getUI(this));
178 public AccessibleContext
getAccessibleContext()
183 protected String
paramString()
185 return "JOptionPane";
188 public static void showMessageDialog(Component frame
,
193 DoShowOptionDialog(frame
,
203 public static void showMessageDialog(Component frame
,
209 DoShowOptionDialog(frame
,
219 public static void showMessageDialog(Component frame
,
222 showMessageDialog(frame
,
228 public static void showMessageDialog(Component frame
,
232 //System.out.println("++++++++++++++++++creating message dialog:"+msg + ", frame="+frame);
233 DoShowOptionDialog(frame
,
243 public static int showConfirmDialog(JFrame frame
,
251 public static String
showInputDialog(JFrame frame
,
260 return (String
) DoShowOptionDialog(frame
,
270 public static Object
showInputDialog(JFrame frame
,
278 return DoShowOptionDialog(frame
,
289 // everybody comes here eventually
290 public static int showOptionDialog(Component frame
,
299 Integer a
= (Integer
) DoShowOptionDialog(frame
,
312 public static Object
DoShowOptionDialog(Component frame
,
322 JOptionPane p
= new JOptionPane(msg
,
328 System
.out
.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ " + p
.msg
);
335 a
= new JDialog((Frame
)frame
,
339 else if (frame
instanceof Dialog
)
341 a
= new JDialog((Dialog
) frame
,
345 else if (frame
instanceof Frame
)
347 a
= new JDialog((Frame
) frame
,
353 System
.out
.println("HUUUUHHH, not a frame or dialog !");
355 a
= new JDialog((Frame
)null,
362 a
.getContentPane().setLayout(new BorderLayout());
363 a
.getContentPane().add(p
,
364 BorderLayout
.CENTER
);
370 Object s
= p
.getValue();
372 System
.out
.println("RESULT FROM DIALOG = " + s
);