001: /*
002: * @(#)JideOptionPane.java 3/27/2006
003: *
004: * Copyright 2002 - 2006 JIDE Software Inc. All rights reserved.
005: */
006:
007: package com.jidesoft.dialog;
008:
009: import javax.swing.*;
010:
011: /**
012: * <code>JideOptionPane</code> is an enhanced version of JOptionPane.
013: * <p/>
014: * This component is still in beta, thus we didn't include the UIDefault needed by this component into LookAndFeelFactory by default.
015: * If you want to use it, please refer to JideOptionPaneDemo's getDemoPanel method where we add all necessary UIDefaults
016: * using UIDefaultCustomizer.
017: */
018: public class JideOptionPane extends JOptionPane {
019: private Object _title;
020: private Object _details;
021: // private boolean _bannerVisible = true;
022:
023: /**
024: * Bound property name for <code>details</code>.
025: */
026: public static final String DETAILS_PROPERTY = "details";
027:
028: /**
029: * Bound property name for <code>title</code>.
030: */
031: public static final String TITLE_PROPERTY = "title";
032:
033: public JideOptionPane() {
034: }
035:
036: public JideOptionPane(Object message) {
037: super (message);
038: }
039:
040: public JideOptionPane(Object message, int messageType) {
041: super (message, messageType);
042: }
043:
044: public JideOptionPane(Object message, int messageType,
045: int optionType) {
046: super (message, messageType, optionType);
047: }
048:
049: public JideOptionPane(Object message, int messageType,
050: int optionType, Icon icon) {
051: super (message, messageType, optionType, icon);
052: }
053:
054: public JideOptionPane(Object message, int messageType,
055: int optionType, Icon icon, Object[] options) {
056: super (message, messageType, optionType, icon, options);
057: }
058:
059: public JideOptionPane(Object message, int messageType,
060: int optionType, Icon icon, Object[] options,
061: Object initialValue) {
062: super (message, messageType, optionType, icon, options,
063: initialValue);
064: }
065:
066: public static final int CLOSE_OPTION = 3;
067:
068: /**
069: * Overrides the method in JOptionPane to allow a new option - CLOSE_OPTION.
070: *
071: * @param newType
072: */
073: @Override
074: public void setOptionType(int newType) {
075: if (newType != DEFAULT_OPTION && newType != YES_NO_OPTION
076: && newType != YES_NO_CANCEL_OPTION
077: && newType != OK_CANCEL_OPTION
078: && newType != CLOSE_OPTION)
079: throw new RuntimeException(
080: "JOptionPane: option type must be one of JOptionPane.DEFAULT_OPTION, JOptionPane.YES_NO_OPTION, JOptionPane.YES_NO_CANCEL_OPTION or JOptionPane.OK_CANCEL_OPTION");
081:
082: int oldType = optionType;
083:
084: optionType = newType;
085: firePropertyChange(OPTION_TYPE_PROPERTY, oldType, optionType);
086: }
087:
088: /**
089: * Sets the details object. The object can be a string or a component. If it is a string,
090: * it will be put into a JTextArea. If it is a component, it will be used directly.
091: * As long as the value is not null, a "Details" button will be added to button panel
092: * allowing you to show or hide the details panel.
093: *
094: * @param details
095: */
096: public void setDetails(Object details) {
097: Object oldDetails = _details;
098: _details = details;
099: firePropertyChange(DETAILS_PROPERTY, oldDetails, _details);
100: }
101:
102: public Object getDetails() {
103: return _details;
104: }
105:
106: public Object getTitle() {
107: return _title;
108: }
109:
110: public void setTitle(Object title) {
111: Object old = _title;
112: _title = title;
113: firePropertyChange(TITLE_PROPERTY, old, _title);
114: }
115:
116: // public boolean isBannerVisible() {
117: // return _bannerVisible;
118: // }
119: //
120: // public void setBannerVisible(boolean bannerVisible) {
121: // _bannerVisible = bannerVisible;
122: // }
123: }
|