Modifiable JOptionPane : JOptionPane Dialog « Swing « Java Tutorial






/*
 * $Id: ModifiableJOptionPane.java,v 1.1.1.1 2005/04/07 18:36:21 pocho Exp $
 */


import java.awt.Component;
import java.awt.HeadlessException;

import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;


/**
 * {@link javax.swing.JOptionPane} that can be modified for creating resizable
 * dialogs and so on. Default implementation of {@link javax.swing.JOptionPane}
 * creates allways unresizable dialog.
 * 
 * @version $Name:  $ - $Revision: 1.1.1.1 $ - $Date: 2005/04/07 18:36:21 $
 */
public class ModifiableJOptionPane extends JOptionPane {
  
  private boolean resizable;

  public ModifiableJOptionPane() {
    super();
  }

  /**
   * @param message
   */
  public ModifiableJOptionPane(Object message) {
    super(message);
  }

  /**
   * @param message
   * @param messageType
   */
  public ModifiableJOptionPane(Object message, int messageType) {
    super(message, messageType);
  }

  /**
   * @param message
   * @param messageType
   * @param optionType
   */
  public ModifiableJOptionPane(Object message, int messageType, int optionType) {
    super(message, messageType, optionType);
  }

  /**
   * @param message
   * @param messageType
   * @param optionType
   * @param icon
   */
  public ModifiableJOptionPane(Object message, int messageType, int optionType,
                              Icon icon) {
    super(message, messageType, optionType, icon);
  }

  /**
   * @param message
   * @param messageType
   * @param optionType
   * @param icon
   * @param options
   */
  public ModifiableJOptionPane(Object message, int messageType, int optionType,
                              Icon icon, Object[] options) {
    super(message, messageType, optionType, icon, options);
  }

  /**
   * @param message
   * @param messageType
   * @param optionType
   * @param icon
   * @param options
   * @param initialValue
   */
  public ModifiableJOptionPane(Object message, int messageType, int optionType,
                              Icon icon, Object[] options, Object initialValue) {
    super(message, messageType, optionType, icon, options, initialValue);
  }

  
  /**
   * @see javax.swing.JOptionPane#createDialog(java.awt.Component, java.lang.String)
   */
  public JDialog createDialog(Component parentComponent, String title)
      throws HeadlessException {
    JDialog dialog = super.createDialog(parentComponent, title);
    dialog.setResizable(isResizable());
    return dialog;
  }
  
  
  /**
   * @see javax.swing.JOptionPane#createInternalFrame(java.awt.Component, java.lang.String)
   */
  public JInternalFrame createInternalFrame(Component parentComponent,
                                            String title) {
    JInternalFrame frame = super.createInternalFrame(parentComponent, title);
    frame.setResizable(isResizable());
    return frame;
  }
  
  public void setResizable(boolean b) {
    this.resizable = b;
  }
  
  public boolean isResizable() {
    return resizable;
  }
}








14.56.JOptionPane Dialog
14.56.1.Creating a JOptionPane
14.56.2.The JOptionPane Message Argument is an Object, not a String.
14.56.3.The JOptionPane Message Type and Icon Arguments
14.56.4.The JOptionPane Option Type Argument
14.56.5.The JOptionPane Options and Initial Value Arguments
14.56.6.JOptionPane Option Position Constants
14.56.7.Using JOptionPane to Display a Message
14.56.8.Using JOptionPane to Prompt User Confirmation
14.56.9.Using JOptionPane to prompt user confirmation: a demoUsing JOptionPane to prompt user confirmation: a demo
14.56.10.Using JOptionPane to Obtain User Input
14.56.11.Using JOptionPane with a predefined selectionsUsing JOptionPane with a predefined selections
14.56.12.Display JOptionPane
14.56.13.JOptionPane Utility Class: Get selection from JOptionPaneJOptionPane Utility Class: Get selection from JOptionPane
14.56.14.Message Pop-UpsMessage Pop-Ups
14.56.15.Confirm Pop-UpsConfirm Pop-Ups
14.56.16.Input Pop-UpsInput Pop-Ups
14.56.17.Big value list for JOptionInput DialogBig value list for JOptionInput Dialog
14.56.18.Option Pop-UpsOption Pop-Ups
14.56.19.String Array Option PopupsString Array Option Popups
14.56.20.Complex message argumentsComplex message arguments
14.56.21.Adding Components to the Button Area: Using JOptionPane with a JButton containing a text label and an iconAdding Components to the Button Area: Using JOptionPane with a JButton containing a text label and an icon
14.56.22.Sample JOptionPane in a JDialogSample JOptionPane in a JDialog
14.56.23.Instant Input DialogsInstant Input Dialogs
14.56.24.JOptionPane WARNING_MESSAGEJOptionPane WARNING_MESSAGE
14.56.25.Dialog without parent componentDialog without parent component
14.56.26.To displays a dialog with a list of choices in a drop-down list boxTo displays a dialog with a list of choices in a drop-down list box
14.56.27.Understanding the Message PropertyUnderstanding the Message Property
14.56.28.Using JOptionPane with a JSliderUsing JOptionPane with a JSlider
14.56.29.Displaying Multiline MessagesDisplaying Multiline Messages
14.56.30.Setting JOptionPane button labels to FrenchSetting JOptionPane button labels to French
14.56.31.Tip Of Day Dialog
14.56.32.About dialogAbout dialog
14.56.33.Create a Confirm Dialog Box
14.56.34.Create a Message Dialog Box
14.56.35.Yes no cancel dialog
14.56.36.OK cancel option dialog
14.56.37.Dialog with default options
14.56.38.Customize JOptionPane buttons
14.56.39.Modal dialog with yes/no button
14.56.40.Modal dialog with OK/cancel and a text field
14.56.41.Wait for a click and then quit
14.56.42.Localize a JOptionPane dialog
14.56.43.Modifiable JOptionPane
14.56.44.Customizing a JOptionPane Look and Feel