Source Code Cross Referenced for SOptionPane.java in  » Swing-Library » wings3 » org » wings » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Swing Library » wings3 » org.wings 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.wings;
002:
003:        import org.apache.commons.logging.Log;
004:        import org.apache.commons.logging.LogFactory;
005:        import org.wings.plaf.OptionPaneCG;
006:        import org.wings.resource.ResourceManager;
007:
008:        import javax.swing.*;
009:        import java.awt.event.ActionEvent;
010:        import java.awt.event.ActionListener;
011:        import java.util.StringTokenizer;
012:        import org.wings.session.SessionManager;
013:
014:        /**
015:         * An immodal dialog component offering several options for selection (like Yes/No, etc.)
016:         *
017:         * @author <a href="mailto:haaf@mercatis.de">Armin Haaf</a>
018:         */
019:        public class SOptionPane extends SDialog implements  ActionListener {
020:            private final transient static Log log = LogFactory
021:                    .getLog(SOptionPane.class);
022:
023:            /**
024:             * Action Performed Value if Yes is Choosen
025:             */
026:            public static final String YES_ACTION = "YES";
027:
028:            /**
029:             * Action Performed Value if No is choosen
030:             */
031:            public static final String NO_ACTION = "NO";
032:
033:            /**
034:             * Action Performed Value if Ok is choosen
035:             */
036:            public static final String OK_ACTION = "OK";
037:
038:            /**
039:             * Action Performed Value if Cancel is choosen
040:             */
041:            public static final String CANCEL_ACTION = "CANCEL";
042:
043:            /**
044:             * Action Performed Value Unknow
045:             */
046:            public static final String UNKNOWN_ACTION = "UNKNOWN";
047:
048:            /**
049:             * Return value if Ok is choosen
050:             */
051:            public static final int OK_OPTION = JOptionPane.OK_OPTION;
052:
053:            /**
054:             * Return value if Cancel is choosen
055:             */
056:            public static final int CANCEL_OPTION = JOptionPane.CANCEL_OPTION;
057:
058:            /**
059:             * Return Value if Yes is choosen
060:             */
061:            public static final int YES_OPTION = JOptionPane.YES_OPTION;
062:
063:            /**
064:             * Return value if no is choosen
065:             */
066:            public static final int NO_OPTION = JOptionPane.NO_OPTION;
067:
068:            public static final int RESET_OPTION = 999;
069:
070:            /**
071:             * Type meaning look and feel should not supply any options -- only
072:             * use the options from the JOptionPane.
073:             */
074:            public static final int DEFAULT_OPTION = JOptionPane.DEFAULT_OPTION;
075:
076:            /**
077:             * Used for showConfirmDialog.
078:             */
079:            public static final int OK_CANCEL_OPTION = JOptionPane.OK_CANCEL_OPTION;
080:
081:            /**
082:             * Used for showConfirmDialog.
083:             */
084:            public static final int OK_CANCEL_RESET_OPTION = OK_CANCEL_OPTION + 1000;
085:
086:            /**
087:             * Used for showConfirmDialog.
088:             */
089:            public static final int YES_NO_OPTION = JOptionPane.YES_NO_OPTION;
090:
091:            /**
092:             * Used for showConfirmDialog.
093:             */
094:            public static final int YES_NO_RESET_OPTION = YES_NO_OPTION + 1000;
095:
096:            /**
097:             * Used for showConfirmDialog.
098:             */
099:            public static final int YES_NO_CANCEL_OPTION = JOptionPane.YES_NO_CANCEL_OPTION;
100:
101:            /**
102:             * Used for showConfirmDialog.
103:             */
104:            public static final int YES_NO_CANCEL_RESET_OPTION = YES_NO_CANCEL_OPTION + 1000;
105:
106:            //
107:            // Message types. Used UI to determine the kind of icon to display,
108:            // and possibly what behavior to give based on the type.
109:            //
110:            /*
111:             * Error messages.
112:             */
113:            public static final int ERROR_MESSAGE = javax.swing.JOptionPane.ERROR_MESSAGE;
114:            /*
115:             * Information messages.
116:             */
117:            public static final int INFORMATION_MESSAGE = javax.swing.JOptionPane.INFORMATION_MESSAGE;
118:            /*
119:             * Warning messages.
120:             */
121:            public static final int WARNING_MESSAGE = javax.swing.JOptionPane.WARNING_MESSAGE;
122:            /*
123:             * Questions.
124:             */
125:            public static final int QUESTION_MESSAGE = javax.swing.JOptionPane.QUESTION_MESSAGE;
126:            /*
127:             * No icon.
128:             */
129:            public static final int PLAIN_MESSAGE = javax.swing.JOptionPane.PLAIN_MESSAGE;
130:
131:            /**
132:             * ContentPane with border layout.
133:             */
134:            private final SContainer contents = new SPanel(new SBorderLayout());
135:
136:            /**
137:             * Panel with Option Messages
138:             */
139:            private final SContainer optionData = new SPanel(
140:                    new SFlowDownLayout(SConstants.LEFT, 0, 0));
141:
142:            /**
143:             * Panel with Option Buttons
144:             */
145:            protected final SContainer optionButtons = new SPanel(
146:                    new SFlowLayout(SConstants.RIGHT, 0, 0));
147:
148:            /**
149:             * OK Button
150:             */
151:            protected final SButton optionOK = createButton(UIManager
152:                    .getString("OptionPane.okButtonText", SessionManager
153:                            .getSession().getLocale()));
154:
155:            /**
156:             * Cancel Button
157:             */
158:            protected final SButton optionCancel = createButton(UIManager
159:                    .getString("OptionPane.cancelButtonText", SessionManager
160:                            .getSession().getLocale()));
161:
162:            /**
163:             * Yes Button
164:             */
165:            protected final SButton optionYes = createButton(UIManager
166:                    .getString("OptionPane.yesButtonText", SessionManager
167:                            .getSession().getLocale()));
168:
169:            /**
170:             * No Button
171:             */
172:            protected final SButton optionNo = createButton(UIManager
173:                    .getString("OptionPane.noButtonText", SessionManager
174:                            .getSession().getLocale()));
175:
176:            /**
177:             * Icon for Inform Dialog
178:             */
179:            private static final SIcon MESSAGE_IMAGE = (SIcon) ResourceManager
180:                    .getObject("SOptionPane.messageIcon", SIcon.class);
181:
182:            /**
183:             * Icon for Input Dialog
184:             */
185:            private static final SIcon QUESTION_IMAGE = (SIcon) ResourceManager
186:                    .getObject("SOptionPane.questionIcon", SIcon.class);
187:
188:            /**
189:             * Icon for Show Confirm Dialog
190:             */
191:            private static final SIcon YES_NO_IMAGE = (SIcon) ResourceManager
192:                    .getObject("SOptionPane.yesnoIcon", SIcon.class);
193:
194:            /**
195:             * Icon for Warning Dialog
196:             */
197:            public static final SIcon WARNING_IMAGE = (SIcon) ResourceManager
198:                    .getObject("SOptionPane.warningIcon", SIcon.class);
199:
200:            /**
201:             * Icon for Error Dialog
202:             */
203:            private static final SIcon ERROR_IMAGE = (SIcon) ResourceManager
204:                    .getObject("SOptionPane.errorIcon", SIcon.class);
205:
206:            // The label that contains the option pane image.
207:            protected final SLabel imageLabel = new SLabel();
208:
209:            /**
210:             * The chosen option
211:             *
212:             * @see #OK_OPTION
213:             * @see #YES_OPTION
214:             * @see #CANCEL_OPTION
215:             * @see #NO_OPTION
216:             */
217:            protected Object selected = null;
218:
219:            /*
220:             * Icon used in pane.
221:             */
222:            protected SIcon icon;
223:
224:            /*
225:             * Message to display.
226:             */
227:            protected Object message;
228:
229:            /*
230:             * Options to display to the user.
231:             */
232:            protected Object[] options;
233:
234:            /*
235:             * Value that should be initialy selected in options.
236:             */
237:            protected Object initialValue;
238:
239:            /*
240:             * Message type.
241:             */
242:            protected int messageType;
243:            private Object inputValue;
244:
245:            /**
246:             * Default Constructor for <code>SOptionPane</code>
247:             * Against the Standard Swing Implementation there is no Standard Message
248:             */
249:            public SOptionPane() {
250:                this (null);
251:            }
252:
253:            /*
254:             * Creates a instance of <code>SOptionPane</code> with a message
255:             *
256:             * @param message the <code>Object</code> to display
257:             */
258:            public SOptionPane(Object message) {
259:                this (message, PLAIN_MESSAGE);
260:            }
261:
262:            /*
263:             * Creates an instance of <code>SOptionPane</code> to display a message
264:             * with the specified message and the default options,
265:             *
266:             * @param message the <code>Object</code> to display
267:             * @param messageType the type of message to be displayed:
268:             *                    ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE,
269:             *                    QUESTION_MESSAGE, or PLAIN_MESSAGE
270:             */
271:            public SOptionPane(Object message, int messageType) {
272:                this (message, messageType, DEFAULT_OPTION);
273:            }
274:
275:            /**
276:             * Creates an instance of <code>JOptionPane</code> to display a message
277:             * with the specified message type and options.
278:             *
279:             * @param message     the <code>Object</code> to display
280:             * @param messageType the type of message to be displayed:
281:             *                    ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE,
282:             *                    QUESTION_MESSAGE, or PLAIN_MESSAGE
283:             * @param optionType  the options to display in the pane:
284:             *                    DEFAULT_OPTION, YES_NO_OPTION, YES_NO_CANCEL_OPTION
285:             *                    OK_CANCEL_OPTION
286:             */
287:            public SOptionPane(Object message, int messageType, int optionType) {
288:                this (message, messageType, optionType, null);
289:            }
290:
291:            /**
292:             * Creates an instance of <code>JOptionPane</code> to display a message
293:             * with the specified message type, options, and icon.
294:             *
295:             * @param message     the <code>Object</code> to display
296:             * @param messageType the type of message to be displayed:
297:             *                    ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE,
298:             *                    QUESTION_MESSAGE, or PLAIN_MESSAGE
299:             * @param optionType  the options to display in the pane:
300:             *                    DEFAULT_OPTION, YES_NO_OPTION, YES_NO_CANCEL_OPTION
301:             *                    OK_CANCEL_OPTION
302:             * @param icon        the <code>Icon</code> image to display
303:             */
304:            public SOptionPane(Object message, int messageType, int optionType,
305:                    SIcon icon) {
306:                this (message, messageType, optionType, icon, null);
307:            }
308:
309:            /**
310:             * Creates an instance of JOptionPane to display a message
311:             * with the specified message type, icon, and options.
312:             * None of the options is initially selected.
313:             * <p/>
314:             * The options objects should contain either instances of
315:             * <code>Component</code>s, (which are added directly) or
316:             * <code>Strings</code> (which are wrapped in a <code>JButton</code>).
317:             * If you provide <code>Component</code>s, you must ensure that when the
318:             * <code>Component</code> is clicked it messages <code>setValue</code>
319:             * in the created <code>JOptionPane</code>.
320:             *
321:             * @param message     the <code>Object</code> to display
322:             * @param messageType the type of message to be displayed:
323:             *                    ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE,
324:             *                    QUESTION_MESSAGE, or PLAIN_MESSAGE
325:             * @param optionType  the options to display in the pane:
326:             *                    DEFAULT_OPTION, YES_NO_OPTION, YES_NO_CANCEL_OPTION
327:             *                    OK_CANCEL_OPTION; only meaningful if the
328:             *                    <code>options</code> parameter is <code>null</code>
329:             * @param icon        the <code>Icon</code> image to display
330:             * @param options     the choices the user can select
331:             */
332:            public SOptionPane(Object message, int messageType, int optionType,
333:                    SIcon icon, Object[] options) {
334:                this (message, messageType, optionType, icon, options, null);
335:            }
336:
337:            /**
338:             * Creates an instance of <code>JOptionPane</code> to display a message
339:             * with the specified message type, icon, and options, with the
340:             * initially-selected option specified.
341:             *
342:             * @param message      the <code>Object</code> to display
343:             * @param messageType  the type of message to be displayed:
344:             *                     ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE,
345:             *                     QUESTION_MESSAGE, or PLAIN_MESSAGE
346:             * @param optionType   the options to display in the pane:
347:             *                     DEFAULT_OPTION, YES_NO_OPTION, YES_NO_CANCEL_OPTION
348:             *                     OK_CANCEL_OPTION; only meaningful if the
349:             *                     <code>options</code> parameter is <code>null</code>
350:             * @param icon         the Icon image to display
351:             * @param options      the choices the user can select
352:             * @param initialValue the choice that is initially selected
353:             */
354:            public SOptionPane(Object message, int messageType, int optionType,
355:                    SIcon icon, Object[] options, Object initialValue) {
356:                this .message = message;
357:                this .options = options;
358:                this .initialValue = initialValue;
359:                this .icon = icon;
360:                SGridLayout layout = new SGridLayout(1);
361:                setLayout(layout);
362:                initPanel();
363:                setOptionType(optionType);
364:                setMessageType(messageType);
365:                setModal(true);
366:            }
367:
368:            public void setCG(OptionPaneCG cg) {
369:                super .setCG(cg);
370:            }
371:
372:            /*
373:             * The chosen option.
374:             * @see #OK_OPTION
375:             * @see #YES_OPTION
376:             * @see #NO_OPTION
377:             * @see #CANCEL_OPTION
378:             */
379:            public final Object getValue() {
380:                return selected;
381:            }
382:
383:            public Object getInputValue() {
384:                return inputValue;
385:            }
386:
387:            private void initPanel() {
388:                imageLabel.setVerticalAlignment(SConstants.TOP_ALIGN);
389:                imageLabel.setStyle("SOptionPaneImage");
390:                imageLabel.setToolTipText(null);
391:
392:                optionButtons.add(optionNo, "NO");
393:                optionButtons.add(optionCancel, "CANCEL");
394:                optionButtons.add(optionYes, "YES");
395:                optionButtons.add(optionOK, "OK");
396:                optionButtons.setPreferredSize(SDimension.FULLWIDTH);
397:                optionButtons.setStyle("SOptionPaneButtons");
398:
399:                optionData.setPreferredSize(SDimension.FULLWIDTH);
400:
401:                contents.add(imageLabel, SBorderLayout.WEST);
402:                contents.add(optionData, SBorderLayout.CENTER);
403:                contents.setPreferredSize(SDimension.FULLWIDTH);
404:
405:                add(contents);
406:                add(optionButtons);
407:            }
408:
409:            /**
410:             * Generic Button creation
411:             */
412:            protected final SButton createButton(String label) {
413:                SButton b = new SButton(label);
414:                b.setName(getName() + label);
415:                b.addActionListener(this );
416:                return b;
417:            }
418:
419:            public void actionPerformed(ActionEvent e) {
420:                log.debug("action " + e);
421:                hide();
422:                selected = e.getSource();
423:
424:                if (e.getSource() == optionOK) {
425:                    fireActionPerformed(OK_ACTION);
426:                } else if (e.getSource() == optionYes) {
427:                    fireActionPerformed(YES_ACTION);
428:                } else if (e.getSource() == optionNo) {
429:                    fireActionPerformed(NO_ACTION);
430:                } else if (e.getSource() == optionCancel) {
431:                    fireActionPerformed(CANCEL_ACTION);
432:                } else {
433:                    fireActionPerformed(UNKNOWN_ACTION);
434:                }
435:            }
436:
437:            protected void fireActionPerformed(String pActionCommand) {
438:                if (pActionCommand != null)
439:                    super .fireActionPerformed(pActionCommand);
440:            }
441:
442:            protected void resetOptions() {
443:                optionOK.setVisible(false);
444:                optionYes.setVisible(false);
445:                optionNo.setVisible(false);
446:                optionCancel.setVisible(false);
447:            }
448:
449:            SContainer customButtons = null;
450:
451:            public void setOptions(Object[] options) {
452:                resetOptions();
453:
454:                if (customButtons == null)
455:                    customButtons = new SPanel();
456:
457:                for (int i = 0; i < options.length; i++) {
458:                    if (options[i] instanceof  SComponent) {
459:                        if (options[i] instanceof  SAbstractButton)
460:                            ((SAbstractButton) options[i])
461:                                    .addActionListener(this );
462:                        customButtons.add((SComponent) options[i]);
463:                    } else {
464:                        SButton b = new SButton(options[i].toString());
465:                        b.addActionListener(this );
466:                        customButtons.add(b);
467:                    }
468:                }
469:
470:                add(customButtons);
471:            }
472:
473:            /**
474:             * Sets the option pane's message type.
475:             * Dependent to the MessageType there wil be displayed a different Message Label
476:             *
477:             * @param newType an integer specifying the kind of message to display:
478:             *                ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE,
479:             *                QUESTION_MESSAGE, or PLAIN_MESSAGE
480:             *                <p/>
481:             *                description: The option pane's message type.
482:             */
483:            public void setMessageType(int newType) {
484:                switch (newType) {
485:                case ERROR_MESSAGE: {
486:                    imageLabel.setIcon(ERROR_IMAGE);
487:                    break;
488:                }
489:                case INFORMATION_MESSAGE: {
490:                    imageLabel.setIcon(MESSAGE_IMAGE);
491:                    break;
492:                }
493:                case WARNING_MESSAGE: {
494:                    imageLabel.setIcon(WARNING_IMAGE);
495:                    break;
496:                }
497:                case QUESTION_MESSAGE: {
498:                    imageLabel.setIcon(QUESTION_IMAGE);
499:                    break;
500:                }
501:                case PLAIN_MESSAGE:
502:                default: {
503:                    imageLabel.setIcon(null);
504:                }
505:                }
506:
507:                messageType = newType;
508:            }
509:
510:            /**
511:             * Returns the message type.
512:             *
513:             * @return an integer specifying the message type
514:             * @see #setMessageType
515:             */
516:            public int getMessageType() {
517:                return messageType;
518:            }
519:
520:            public void setOptionType(int newType) {
521:                resetOptions();
522:
523:                switch (newType) {
524:                case DEFAULT_OPTION:
525:                    optionOK.setVisible(true);
526:                    optionOK.requestFocus();
527:                    break;
528:
529:                case OK_CANCEL_OPTION:
530:                    optionOK.setVisible(true);
531:                    optionOK.requestFocus();
532:                    optionCancel.setVisible(true);
533:                    break;
534:
535:                case OK_CANCEL_RESET_OPTION:
536:                    optionOK.setVisible(true);
537:                    optionOK.requestFocus();
538:                    optionCancel.setVisible(true);
539:                    break;
540:
541:                case YES_NO_OPTION:
542:                    optionYes.setVisible(true);
543:                    optionYes.requestFocus();
544:                    optionNo.setVisible(true);
545:                    break;
546:
547:                case YES_NO_RESET_OPTION:
548:                    optionYes.setVisible(true);
549:                    optionYes.requestFocus();
550:                    optionNo.setVisible(true);
551:                    break;
552:
553:                case YES_NO_CANCEL_OPTION:
554:                    optionYes.setVisible(true);
555:                    optionYes.requestFocus();
556:                    optionNo.setVisible(true);
557:                    optionCancel.setVisible(true);
558:                    break;
559:
560:                case YES_NO_CANCEL_RESET_OPTION:
561:                    optionYes.setVisible(true);
562:                    optionYes.requestFocus();
563:                    optionNo.setVisible(true);
564:                    optionCancel.setVisible(true);
565:                    break;
566:                }
567:            }
568:
569:            public void showOption(SComponent c, String title, Object message) {
570:                if (title != null)
571:                    setTitle(title);
572:
573:                optionData.removeAll();
574:                if (message instanceof  SComponent) {
575:                    optionData.add((SComponent) message);
576:                } else {
577:                    StringTokenizer stringTokenizer = new StringTokenizer(
578:                            message.toString(), "\n");
579:                    while (stringTokenizer.hasMoreElements()) {
580:                        optionData.add(new SLabel(stringTokenizer.nextElement()
581:                                .toString()));
582:                    }
583:                }
584:                show(c);
585:            }
586:
587:            public void showPlainMessage(SComponent parent, Object message,
588:                    String title) {
589:                showOption(parent, title, message);
590:
591:                setOptionType(SOptionPane.DEFAULT_OPTION);
592:                setMessageType(SOptionPane.PLAIN_MESSAGE);
593:            }
594:
595:            public void showQuestion(SComponent parent, Object message,
596:                    String title) {
597:                showOption(parent, title, message);
598:
599:                setOptionType(SOptionPane.OK_CANCEL_OPTION);
600:                setMessageType(SOptionPane.QUESTION_MESSAGE);
601:            }
602:
603:            public void showInput(SComponent parent, Object message,
604:                    SComponent inputElement, String title) {
605:                showOption(parent, title, message);
606:                optionData.add(inputElement);
607:                inputValue = inputElement;
608:
609:                setOptionType(SOptionPane.OK_CANCEL_OPTION);
610:                setMessageType(SOptionPane.QUESTION_MESSAGE);
611:            }
612:
613:            public void showYesNo(SComponent parent, Object question,
614:                    String title) {
615:                showOption(parent, title, question);
616:                setOptionType(YES_NO_OPTION);
617:                setMessageType(SOptionPane.QUESTION_MESSAGE);
618:            }
619:
620:            public void showQuestion(SComponent parent, Object question,
621:                    String title, int type) {
622:                showOption(parent, title, question);
623:                setOptionType(type);
624:                setMessageType(SOptionPane.QUESTION_MESSAGE);
625:            }
626:
627:            // -------------------------------------------------------------------
628:            // MESSAGE DIALOGS
629:            // -------------------------------------------------------------------
630:
631:            public static void showMessageDialog(SComponent parent,
632:                    Object message) {
633:                showMessageDialog(parent, message, null,
634:                        SOptionPane.INFORMATION_MESSAGE, null);
635:            }
636:
637:            public static void showMessageDialog(SComponent parent,
638:                    Object message, String title) {
639:                showMessageDialog(parent, message, title,
640:                        SOptionPane.INFORMATION_MESSAGE, null);
641:            }
642:
643:            public static void showMessageDialog(SComponent parent,
644:                    Object message, ActionListener al) {
645:                showMessageDialog(parent, message, null,
646:                        SOptionPane.INFORMATION_MESSAGE, al);
647:            }
648:
649:            public static void showMessageDialog(SComponent parent,
650:                    Object message, String title, int messageType) {
651:                showMessageDialog(parent, message, title, messageType, null);
652:            }
653:
654:            public static void showMessageDialog(SComponent parent,
655:                    Object message, String title, int messageType,
656:                    ActionListener al) {
657:                SOptionPane p = new SOptionPane();
658:
659:                p.showOption(parent, title, message);
660:                p.setMessageType(messageType);
661:                p.addActionListener(al);
662:            }
663:
664:            // -------------------------------------------------------------------
665:            // PLAIN MESSAGE DIALOGS
666:            // -------------------------------------------------------------------
667:
668:            public static void showPlainMessageDialog(SComponent parent,
669:                    Object message) {
670:                showPlainMessageDialog(parent, message, null, null);
671:            }
672:
673:            public static void showPlainMessageDialog(SComponent parent,
674:                    Object message, String title) {
675:                showPlainMessageDialog(parent, message, title, null);
676:            }
677:
678:            public static void showPlainMessageDialog(SComponent parent,
679:                    Object message, ActionListener al) {
680:                showPlainMessageDialog(parent, message, null, al);
681:            }
682:
683:            public static void showPlainMessageDialog(SComponent parent,
684:                    Object message, String title, ActionListener al) {
685:                SOptionPane p = new SOptionPane();
686:
687:                p.showOption(parent, title, message);
688:                p.setMessageType(SOptionPane.PLAIN_MESSAGE);
689:                p.addActionListener(al);
690:            }
691:
692:            // -------------------------------------------------------------------
693:            // INPUT DIALOGS
694:            // -------------------------------------------------------------------
695:
696:            public static void showInputDialog(SComponent parent,
697:                    Object question, String title, SComponent inputElement,
698:                    ActionListener al) {
699:                showInputDialog(parent, question, title,
700:                        SOptionPane.QUESTION_MESSAGE, inputElement, al);
701:            }
702:
703:            public static void showInputDialog(SComponent parent,
704:                    Object question, String title, int messageType,
705:                    SComponent inputElement, ActionListener al) {
706:                SOptionPane p = new SOptionPane();
707:
708:                p.showInput(parent, question, inputElement, title);
709:                p.setMessageType(messageType);
710:                p.addActionListener(al);
711:            }
712:
713:            // -------------------------------------------------------------------
714:            // QUESTION DIALOGS
715:            // -------------------------------------------------------------------
716:
717:            public static void showQuestionDialog(SComponent parent,
718:                    Object question, String title, ActionListener al) {
719:                SOptionPane p = new SOptionPane();
720:
721:                p.showQuestion(parent, question, title);
722:                p.setMessageType(SOptionPane.QUESTION_MESSAGE);
723:                p.addActionListener(al);
724:            }
725:
726:            // -------------------------------------------------------------------
727:            // PLAIN QUESTION DIALOGS
728:            // -------------------------------------------------------------------
729:
730:            public static void showPlainQuestionDialog(SComponent parent,
731:                    Object question, String title, ActionListener al) {
732:                SOptionPane p = new SOptionPane();
733:
734:                p.showQuestion(parent, question, title);
735:                p.setMessageType(SOptionPane.PLAIN_MESSAGE);
736:                p.addActionListener(al);
737:            }
738:
739:            // -------------------------------------------------------------------
740:            // CONFIRM DIALOGS
741:            // -------------------------------------------------------------------
742:
743:            public static void showConfirmDialog(SComponent parent,
744:                    Object message, String title) {
745:                showConfirmDialog(parent, message, title, 0, null);
746:            }
747:
748:            public static void showConfirmDialog(SComponent parent,
749:                    Object message, String title, ActionListener al) {
750:                showConfirmDialog(parent, message, title, 0, al);
751:            }
752:
753:            public static void showConfirmDialog(SComponent parent,
754:                    Object message, String title, int type) {
755:                showConfirmDialog(parent, message, title, type, null);
756:            }
757:
758:            public static void showConfirmDialog(SComponent parent,
759:                    Object message, String title, int type, ActionListener al) {
760:                showConfirmDialog(parent, message, title, type, al, null);
761:            }
762:
763:            public static void showConfirmDialog(SComponent parent,
764:                    Object message, String title, int type, ActionListener al,
765:                    SLayoutManager layout) {
766:                SOptionPane p = new SOptionPane();
767:
768:                if (layout != null) {
769:                    p.optionButtons.setLayout(layout);
770:                } // end of if ()
771:
772:                p.showQuestion(parent, message, title, type);
773:                p.addActionListener(al);
774:            }
775:
776:            // -------------------------------------------------------------------
777:            // YES-NO DIALOGS
778:            // -------------------------------------------------------------------
779:
780:            public static void showYesNoDialog(SComponent parent,
781:                    Object question, String title, ActionListener al) {
782:                SOptionPane p = new SOptionPane();
783:                p.addActionListener(al);
784:
785:                p.showYesNo(parent, question, title);
786:            }
787:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.