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 java
.awt
.BorderLayout
;
42 import java
.awt
.Component
;
43 import java
.awt
.Dialog
;
44 import java
.awt
.Frame
;
45 import javax
.accessibility
.Accessible
;
46 import javax
.accessibility
.AccessibleContext
;
47 import javax
.swing
.plaf
.OptionPaneUI
;
49 public class JOptionPane
extends JComponent
51 public static final int DEFAULT_OPTION
= 0;
52 public static final int YES_NO_OPTION
= 1;
53 public static final int YES_NO_CANCEL_OPTION
= 2;
54 public static final int OK_CANCEL_OPTION
= 3;
55 public static final int YES_OPTION
= 4;
56 public static final int NO_OPTION
= 5;
57 public static final int CANCEL_OPTION
= 6;
58 public static final int OK_OPTION
= 7;
59 public static final int CLOSED_OPTION
= 8;
61 public static final int ERROR_MESSAGE
= 0;
62 public static final int INFORMATION_MESSAGE
= 1;
63 public static final int WARNING_MESSAGE
= 2;
64 public static final int QUESTION_MESSAGE
= 3;
65 public static final int PLAIN_MESSAGE
= 4;
67 final static String VALUE_PROPERTY
= "value_prop";
68 final static String INPUT_VALUE_PROPERTY
= "input_value_prop";
70 final static String UNINITIALIZED_VALUE
= "uninit";
72 // Ronald: shouldnt by public ?
80 public JDialog dialog
;
82 /*****************************************************************************
88 ***********************************/
97 this(m
, PLAIN_MESSAGE
);
100 JOptionPane(Object m
,
103 this(m
, mtype
, DEFAULT_OPTION
);
106 JOptionPane(Object m
,
110 this(m
, mtype
, otype
, null);
113 JOptionPane(Object m
,
118 this(m
, mtype
, otype
, icon
, null);
121 JOptionPane(Object m
,
127 this(m
, mtype
, otype
, icon
, args
, null);
130 JOptionPane(Object msg
,
137 // this(m, mtype, otype, icon, args, init);
149 /*****************************************************************************
155 ***********************************/
158 public void setValue(Object v
)
160 public Object
getValue()
163 public String
getUIClassID()
164 { return "JOptionPane"; }
167 public void setUI(OptionPaneUI ui
) {
171 public OptionPaneUI
getUI() {
172 return (OptionPaneUI
)ui
;
175 public void updateUI() {
176 setUI((OptionPaneUI
)UIManager
.getUI(this));
180 public AccessibleContext
getAccessibleContext()
185 protected String
paramString()
187 return "JOptionPane";
190 public static void showMessageDialog(Component frame
,
195 DoShowOptionDialog(frame
,
205 public static void showMessageDialog(Component frame
,
211 DoShowOptionDialog(frame
,
221 public static void showMessageDialog(Component frame
,
224 showMessageDialog(frame
,
230 public static void showMessageDialog(Component frame
,
234 //System.out.println("++++++++++++++++++creating message dialog:"+msg + ", frame="+frame);
235 DoShowOptionDialog(frame
,
245 public static int showConfirmDialog(JFrame frame
,
253 public static String
showInputDialog(JFrame frame
,
262 return (String
) DoShowOptionDialog(frame
,
272 public static Object
showInputDialog(JFrame frame
,
280 return DoShowOptionDialog(frame
,
291 // everybody comes here eventually
292 public static int showOptionDialog(Component frame
,
301 Integer a
= (Integer
) DoShowOptionDialog(frame
,
314 public static Object
DoShowOptionDialog(Component frame
,
324 JOptionPane p
= new JOptionPane(msg
,
330 System
.out
.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ " + p
.msg
);
337 a
= new JDialog((Frame
)frame
,
341 else if (frame
instanceof Dialog
)
343 a
= new JDialog((Dialog
) frame
,
347 else if (frame
instanceof Frame
)
349 a
= new JDialog((Frame
) frame
,
355 System
.out
.println("HUUUUHHH, not a frame or dialog !");
357 a
= new JDialog((Frame
)null,
364 a
.getContentPane().setLayout(new BorderLayout());
365 a
.getContentPane().add(p
,
366 BorderLayout
.CENTER
);
372 Object s
= p
.getValue();
374 System
.out
.println("RESULT FROM DIALOG = " + s
);