jdk/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java
changeset 25772 73e0efa29d55
parent 25565 ce603b34c98d
equal deleted inserted replaced
25771:afc878cc2197 25772:73e0efa29d55
    77  * @author Scott Violet
    77  * @author Scott Violet
    78  * @author Amy Fowler
    78  * @author Amy Fowler
    79  */
    79  */
    80 public class BasicOptionPaneUI extends OptionPaneUI {
    80 public class BasicOptionPaneUI extends OptionPaneUI {
    81 
    81 
       
    82     /**
       
    83      * The mininum width of {@code JOptionPane}.
       
    84      */
    82     public static final int MinimumWidth = 262;
    85     public static final int MinimumWidth = 262;
       
    86     /**
       
    87      * The mininum height of {@code JOptionPane}.
       
    88      */
    83     public static final int MinimumHeight = 90;
    89     public static final int MinimumHeight = 90;
    84 
    90 
    85     private static String newline;
    91     private static String newline;
    86 
    92 
    87     /**
    93     /**
    88      * <code>JOptionPane</code> that the receiver is providing the
    94      * {@code JOptionPane} that the receiver is providing the
    89      * look and feel for.
    95      * look and feel for.
    90      */
    96      */
    91     protected JOptionPane         optionPane;
    97     protected JOptionPane         optionPane;
    92 
    98 
       
    99     /**
       
   100      * The size of {@code JOptionPane}.
       
   101      */
    93     protected Dimension minimumSize;
   102     protected Dimension minimumSize;
    94 
   103 
    95     /** JComponent provide for input if optionPane.getWantsInput() returns
   104     /** JComponent provide for input if optionPane.getWantsInput() returns
    96      * true. */
   105      * true. */
    97     protected JComponent          inputComponent;
   106     protected JComponent          inputComponent;
   101 
   110 
   102     /** This is set to true in validateComponent if a Component is contained
   111     /** This is set to true in validateComponent if a Component is contained
   103      * in either the message or the buttons. */
   112      * in either the message or the buttons. */
   104     protected boolean             hasCustomComponents;
   113     protected boolean             hasCustomComponents;
   105 
   114 
       
   115     /**
       
   116      * The instance of {@code PropertyChangeListener}.
       
   117      */
   106     protected PropertyChangeListener propertyChangeListener;
   118     protected PropertyChangeListener propertyChangeListener;
   107 
   119 
   108     private Handler handler;
   120     private Handler handler;
   109 
   121 
   110 
   122 
   121     }
   133     }
   122 
   134 
   123 
   135 
   124 
   136 
   125     /**
   137     /**
   126       * Creates a new BasicOptionPaneUI instance.
   138      * Creates a new {@code BasicOptionPaneUI} instance.
   127       */
   139      *
       
   140      * @return a new {@code BasicOptionPaneUI} instance
       
   141      */
   128     public static ComponentUI createUI(JComponent x) {
   142     public static ComponentUI createUI(JComponent x) {
   129         return new BasicOptionPaneUI();
   143         return new BasicOptionPaneUI();
   130     }
   144     }
   131 
   145 
   132     /**
   146     /**
   153         uninstallListeners();
   167         uninstallListeners();
   154         uninstallDefaults();
   168         uninstallDefaults();
   155         optionPane = null;
   169         optionPane = null;
   156     }
   170     }
   157 
   171 
       
   172     /**
       
   173      * Installs default properties.
       
   174      */
   158     protected void installDefaults() {
   175     protected void installDefaults() {
   159         LookAndFeel.installColorsAndFont(optionPane, "OptionPane.background",
   176         LookAndFeel.installColorsAndFont(optionPane, "OptionPane.background",
   160                                          "OptionPane.foreground", "OptionPane.font");
   177                                          "OptionPane.foreground", "OptionPane.font");
   161         LookAndFeel.installBorder(optionPane, "OptionPane.border");
   178         LookAndFeel.installBorder(optionPane, "OptionPane.border");
   162         minimumSize = UIManager.getDimension("OptionPane.minimumSize");
   179         minimumSize = UIManager.getDimension("OptionPane.minimumSize");
   163         LookAndFeel.installProperty(optionPane, "opaque", Boolean.TRUE);
   180         LookAndFeel.installProperty(optionPane, "opaque", Boolean.TRUE);
   164     }
   181     }
   165 
   182 
       
   183     /**
       
   184      * Uninstalls default properties.
       
   185      */
   166     protected void uninstallDefaults() {
   186     protected void uninstallDefaults() {
   167         LookAndFeel.uninstallBorder(optionPane);
   187         LookAndFeel.uninstallBorder(optionPane);
   168     }
   188     }
   169 
   189 
       
   190     /**
       
   191      * Registers components.
       
   192      */
   170     protected void installComponents() {
   193     protected void installComponents() {
   171         optionPane.add(createMessageArea());
   194         optionPane.add(createMessageArea());
   172 
   195 
   173         Container separator = createSeparator();
   196         Container separator = createSeparator();
   174         if (separator != null) {
   197         if (separator != null) {
   176         }
   199         }
   177         optionPane.add(createButtonArea());
   200         optionPane.add(createButtonArea());
   178         optionPane.applyComponentOrientation(optionPane.getComponentOrientation());
   201         optionPane.applyComponentOrientation(optionPane.getComponentOrientation());
   179     }
   202     }
   180 
   203 
       
   204     /**
       
   205      * Unregisters components.
       
   206      */
   181     protected void uninstallComponents() {
   207     protected void uninstallComponents() {
   182         hasCustomComponents = false;
   208         hasCustomComponents = false;
   183         inputComponent = null;
   209         inputComponent = null;
   184         initialFocusComponent = null;
   210         initialFocusComponent = null;
   185         optionPane.removeAll();
   211         optionPane.removeAll();
   186     }
   212     }
   187 
   213 
       
   214     /**
       
   215      * Returns a layout manager.
       
   216      *
       
   217      * @return a layout manager
       
   218      */
   188     protected LayoutManager createLayoutManager() {
   219     protected LayoutManager createLayoutManager() {
   189         return new BoxLayout(optionPane, BoxLayout.Y_AXIS);
   220         return new BoxLayout(optionPane, BoxLayout.Y_AXIS);
   190     }
   221     }
   191 
   222 
       
   223     /**
       
   224      * Registers listeners.
       
   225      */
   192     protected void installListeners() {
   226     protected void installListeners() {
   193         if ((propertyChangeListener = createPropertyChangeListener()) != null) {
   227         if ((propertyChangeListener = createPropertyChangeListener()) != null) {
   194             optionPane.addPropertyChangeListener(propertyChangeListener);
   228             optionPane.addPropertyChangeListener(propertyChangeListener);
   195         }
   229         }
   196     }
   230     }
   197 
   231 
       
   232     /**
       
   233      * Unregisters listeners.
       
   234      */
   198     protected void uninstallListeners() {
   235     protected void uninstallListeners() {
   199         if (propertyChangeListener != null) {
   236         if (propertyChangeListener != null) {
   200             optionPane.removePropertyChangeListener(propertyChangeListener);
   237             optionPane.removePropertyChangeListener(propertyChangeListener);
   201             propertyChangeListener = null;
   238             propertyChangeListener = null;
   202         }
   239         }
   203         handler = null;
   240         handler = null;
   204     }
   241     }
   205 
   242 
       
   243     /**
       
   244      * Returns an instance of {@code PropertyChangeListener}.
       
   245      *
       
   246      * @return an instance of {@code PropertyChangeListener}
       
   247      */
   206     protected PropertyChangeListener createPropertyChangeListener() {
   248     protected PropertyChangeListener createPropertyChangeListener() {
   207         return getHandler();
   249         return getHandler();
   208     }
   250     }
   209 
   251 
   210     private Handler getHandler() {
   252     private Handler getHandler() {
   212             handler = new Handler();
   254             handler = new Handler();
   213         }
   255         }
   214         return handler;
   256         return handler;
   215     }
   257     }
   216 
   258 
       
   259     /**
       
   260      * Registers keyboard actions.
       
   261      */
   217     protected void installKeyboardActions() {
   262     protected void installKeyboardActions() {
   218         InputMap map = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
   263         InputMap map = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
   219 
   264 
   220         SwingUtilities.replaceUIInputMap(optionPane, JComponent.
   265         SwingUtilities.replaceUIInputMap(optionPane, JComponent.
   221                                        WHEN_IN_FOCUSED_WINDOW, map);
   266                                        WHEN_IN_FOCUSED_WINDOW, map);
   222 
   267 
   223         LazyActionMap.installLazyActionMap(optionPane, BasicOptionPaneUI.class,
   268         LazyActionMap.installLazyActionMap(optionPane, BasicOptionPaneUI.class,
   224                                            "OptionPane.actionMap");
   269                                            "OptionPane.actionMap");
   225     }
   270     }
   226 
   271 
       
   272     /**
       
   273      * Unregisters keyboard actions.
       
   274      */
   227     protected void uninstallKeyboardActions() {
   275     protected void uninstallKeyboardActions() {
   228         SwingUtilities.replaceUIInputMap(optionPane, JComponent.
   276         SwingUtilities.replaceUIInputMap(optionPane, JComponent.
   229                                        WHEN_IN_FOCUSED_WINDOW, null);
   277                                        WHEN_IN_FOCUSED_WINDOW, null);
   230         SwingUtilities.replaceUIActionMap(optionPane, null);
   278         SwingUtilities.replaceUIActionMap(optionPane, null);
   231     }
   279     }
   242     }
   290     }
   243 
   291 
   244     /**
   292     /**
   245      * Returns the minimum size the option pane should be. Primarily
   293      * Returns the minimum size the option pane should be. Primarily
   246      * provided for subclassers wishing to offer a different minimum size.
   294      * provided for subclassers wishing to offer a different minimum size.
       
   295      *
       
   296      * @return the minimum size of the option pane
   247      */
   297      */
   248     public Dimension getMinimumOptionPaneSize() {
   298     public Dimension getMinimumOptionPaneSize() {
   249         if (minimumSize == null) {
   299         if (minimumSize == null) {
   250             return new Dimension(MinimumWidth, MinimumHeight);
   300             return new Dimension(MinimumWidth, MinimumHeight);
   251         }
   301         }
   278         }
   328         }
   279         return null;
   329         return null;
   280     }
   330     }
   281 
   331 
   282     /**
   332     /**
   283      * Messaged from installComponents to create a Container containing the
   333      * Messaged from {@code installComponents} to create a {@code Container}
   284      * body of the message. The icon is the created by calling
   334      * containing the body of the message. The icon is the created
   285      * <code>addIcon</code>.
   335      * by calling {@code addIcon}.
       
   336      *
       
   337      * @return a instance of {@code Container}
   286      */
   338      */
   287     protected Container createMessageArea() {
   339     protected Container createMessageArea() {
   288         JPanel top = new JPanel();
   340         JPanel top = new JPanel();
   289         Border topBorder = (Border)DefaultLookup.get(optionPane, this,
   341         Border topBorder = (Border)DefaultLookup.get(optionPane, this,
   290                                              "OptionPane.messageAreaBorder");
   342                                              "OptionPane.messageAreaBorder");
   323         addIcon(top);
   375         addIcon(top);
   324         return top;
   376         return top;
   325     }
   377     }
   326 
   378 
   327     /**
   379     /**
   328      * Creates the appropriate object to represent <code>msg</code> and
   380      * Creates the appropriate object to represent {@code msg} and
   329      * places it into <code>container</code>. If <code>msg</code> is an
   381      * places it into {@code container}. If {@code msg} is an instance of
   330      * instance of Component, it is added directly, if it is an Icon,
   382      * {@code Component}, it is added directly, if it is an {@code Icon},
   331      * a JLabel is created to represent it, otherwise a JLabel is
   383      * a {@code JLabel} is created to represent it, otherwise a {@code JLabel} is
   332      * created for the string, if <code>d</code> is an Object[], this
   384      * created for the string, if {@code d} is an Object[], this method
   333      * method will be recursively invoked for the children.
   385      * will be recursively invoked for the children. {@code internallyCreated} is
   334      * <code>internallyCreated</code> is true if Objc is an instance
   386      * {@code true} if Objc is an instance of {@code Component} and was created
   335      * of Component and was created internally by this method (this is
   387      * internally by this method (this is used to correctly set
   336      * used to correctly set hasCustomComponents only if !internallyCreated).
   388      * {@code hasCustomComponents} only if {@code internallyCreated} is {@code false}).
       
   389      *
       
   390      * @param container a container
       
   391      * @param cons an instance of {@code GridBagConstraints}
       
   392      * @param msg a message
       
   393      * @param maxll a maximum length
       
   394      * @param internallyCreated {@code true} if the component was internally created
   337      */
   395      */
   338     protected void addMessageComponents(Container container,
   396     protected void addMessageComponents(Container container,
   339                                      GridBagConstraints cons,
   397                                      GridBagConstraints cons,
   340                                      Object msg, int maxll,
   398                                      Object msg, int maxll,
   341                                      boolean internallyCreated) {
   399                                      boolean internallyCreated) {
   429             }
   487             }
   430         }
   488         }
   431     }
   489     }
   432 
   490 
   433     /**
   491     /**
   434      * Returns the message to display from the JOptionPane the receiver is
   492      * Returns the message to display from the {@code JOptionPane} the receiver is
   435      * providing the look and feel for.
   493      * providing the look and feel for.
       
   494      *
       
   495      * @return the message to display
   436      */
   496      */
   437     protected Object getMessage() {
   497     protected Object getMessage() {
   438         inputComponent = null;
   498         inputComponent = null;
   439         if (optionPane != null) {
   499         if (optionPane != null) {
   440             if (optionPane.getWantsInput()) {
   500             if (optionPane.getWantsInput()) {
   512         return null;
   572         return null;
   513     }
   573     }
   514 
   574 
   515     /**
   575     /**
   516      * Creates and adds a JLabel representing the icon returned from
   576      * Creates and adds a JLabel representing the icon returned from
   517      * <code>getIcon</code> to <code>top</code>. This is messaged from
   577      * {@code getIcon} to {@code top}. This is messaged from
   518      * <code>createMessageArea</code>
   578      * {@code createMessageArea}.
       
   579      *
       
   580      * @param top a container
   519      */
   581      */
   520     protected void addIcon(Container top) {
   582     protected void addIcon(Container top) {
   521         /* Create the icon. */
   583         /* Create the icon. */
   522         Icon                  sideIcon = getIcon();
   584         Icon                  sideIcon = getIcon();
   523 
   585 
   529             top.add(iconLabel, BorderLayout.BEFORE_LINE_BEGINS);
   591             top.add(iconLabel, BorderLayout.BEFORE_LINE_BEGINS);
   530         }
   592         }
   531     }
   593     }
   532 
   594 
   533     /**
   595     /**
   534      * Returns the icon from the JOptionPane the receiver is providing
   596      * Returns the icon from the {@code JOptionPane} the receiver is providing
   535      * the look and feel for, or the default icon as returned from
   597      * the look and feel for, or the default icon as returned from
   536      * <code>getDefaultIcon</code>.
   598      * {@code getDefaultIcon}.
       
   599      *
       
   600      * @return the icon
   537      */
   601      */
   538     protected Icon getIcon() {
   602     protected Icon getIcon() {
   539         Icon      mIcon = (optionPane == null ? null : optionPane.getIcon());
   603         Icon      mIcon = (optionPane == null ? null : optionPane.getIcon());
   540 
   604 
   541         if(mIcon == null && optionPane != null)
   605         if(mIcon == null && optionPane != null)
   543         return mIcon;
   607         return mIcon;
   544     }
   608     }
   545 
   609 
   546     /**
   610     /**
   547      * Returns the icon to use for the passed in type.
   611      * Returns the icon to use for the passed in type.
       
   612      *
       
   613      * @param messageType a type of message
       
   614      * @return the icon to use for the passed in type
   548      */
   615      */
   549     protected Icon getIconForType(int messageType) {
   616     protected Icon getIconForType(int messageType) {
   550         if(messageType < 0 || messageType > 3)
   617         if(messageType < 0 || messageType > 3)
   551             return null;
   618             return null;
   552         String propertyName = null;
   619         String propertyName = null;
   570         return null;
   637         return null;
   571     }
   638     }
   572 
   639 
   573     /**
   640     /**
   574      * Returns the maximum number of characters to place on a line.
   641      * Returns the maximum number of characters to place on a line.
       
   642      *
       
   643      * @return the maximum number of characters to place on a line
   575      */
   644      */
   576     protected int getMaxCharactersPerLineCount() {
   645     protected int getMaxCharactersPerLineCount() {
   577         return optionPane.getMaxCharactersPerLineCount();
   646         return optionPane.getMaxCharactersPerLineCount();
   578     }
   647     }
   579 
   648 
   580    /**
   649     /**
   581      * Recursively creates new JLabel instances to represent <code>d</code>.
   650      * Recursively creates new {@code JLabel} instances to represent {@code d}.
   582      * Each JLabel instance is added to <code>c</code>.
   651      * Each {@code JLabel} instance is added to {@code c}.
       
   652      *
       
   653      * @param c a container
       
   654      * @param d a text
       
   655      * @param maxll a maximum length of a text
   583      */
   656      */
   584     protected void burstStringInto(Container c, String d, int maxll) {
   657     protected void burstStringInto(Container c, String d, int maxll) {
   585         // Primitive line wrapping
   658         // Primitive line wrapping
   586         int len = d.length();
   659         int len = d.length();
   587         if (len <= 0)
   660         if (len <= 0)
   600         label.setName("OptionPane.label");
   673         label.setName("OptionPane.label");
   601         configureMessageLabel(label);
   674         configureMessageLabel(label);
   602         c.add(label);
   675         c.add(label);
   603     }
   676     }
   604 
   677 
       
   678     /**
       
   679      * Returns a separator.
       
   680      *
       
   681      * @return a separator
       
   682      */
   605     protected Container createSeparator() {
   683     protected Container createSeparator() {
   606         return null;
   684         return null;
   607     }
   685     }
   608 
   686 
   609     /**
   687     /**
   610      * Creates and returns a Container containing the buttons. The buttons
   688      * Creates and returns a {@code Container} containing the buttons.
   611      * are created by calling <code>getButtons</code>.
   689      * The buttons are created by calling {@code getButtons}.
       
   690      *
       
   691      * @return a {@code Container} containing the buttons
   612      */
   692      */
   613     protected Container createButtonArea() {
   693     protected Container createButtonArea() {
   614         JPanel bottom = new JPanel();
   694         JPanel bottom = new JPanel();
   615         Border border = (Border)DefaultLookup.get(optionPane, this,
   695         Border border = (Border)DefaultLookup.get(optionPane, this,
   616                                           "OptionPane.buttonAreaBorder");
   696                                           "OptionPane.buttonAreaBorder");
   631         return bottom;
   711         return bottom;
   632     }
   712     }
   633 
   713 
   634     /**
   714     /**
   635      * Creates the appropriate object to represent each of the objects in
   715      * Creates the appropriate object to represent each of the objects in
   636      * <code>buttons</code> and adds it to <code>container</code>. This
   716      * {@code buttons} and adds it to {@code container}. This
   637      * differs from addMessageComponents in that it will recurse on
   717      * differs from addMessageComponents in that it will recurse on
   638      * <code>buttons</code> and that if button is not a Component
   718      * {@code buttons} and that if button is not a Component
   639      * it will create an instance of JButton.
   719      * it will create an instance of JButton.
       
   720      *
       
   721      * @param container a container
       
   722      * @param buttons an array of buttons
       
   723      * @param initialIndex an initial index
   640      */
   724      */
   641     protected void addButtonComponents(Container container, Object[] buttons,
   725     protected void addButtonComponents(Container container, Object[] buttons,
   642                                  int initialIndex) {
   726                                  int initialIndex) {
   643         if (buttons != null && buttons.length > 0) {
   727         if (buttons != null && buttons.length > 0) {
   644             boolean            sizeButtonsToSame = getSizeButtonsToSameWidth();
   728             boolean            sizeButtonsToSame = getSizeButtonsToSameWidth();
   731                 }
   815                 }
   732             }
   816             }
   733         }
   817         }
   734     }
   818     }
   735 
   819 
       
   820     /**
       
   821      * Constructs a new instance of a {@code ButtonActionListener}.
       
   822      *
       
   823      * @param buttonIndex an index of the button
       
   824      * @return a new instance of a {@code ButtonActionListener}
       
   825      */
   736     protected ActionListener createButtonActionListener(int buttonIndex) {
   826     protected ActionListener createButtonActionListener(int buttonIndex) {
   737         return new ButtonActionListener(buttonIndex);
   827         return new ButtonActionListener(buttonIndex);
   738     }
   828     }
   739 
   829 
   740     /**
   830     /**
   741      * Returns the buttons to display from the JOptionPane the receiver is
   831      * Returns the buttons to display from the {@code JOptionPane} the receiver is
   742      * providing the look and feel for. If the JOptionPane has options
   832      * providing the look and feel for. If the {@code JOptionPane} has options
   743      * set, they will be provided, otherwise if the optionType is
   833      * set, they will be provided, otherwise if the optionType is
   744      * YES_NO_OPTION, yesNoOptions is returned, if the type is
   834      * {@code YES_NO_OPTION}, {@code yesNoOptions} is returned, if the type is
   745      * YES_NO_CANCEL_OPTION yesNoCancelOptions is returned, otherwise
   835      * {@code YES_NO_CANCEL_OPTION} {@code yesNoCancelOptions} is returned, otherwise
   746      * defaultButtons are returned.
   836      * {@code defaultButtons} are returned.
       
   837      *
       
   838      * @return the buttons to display from the JOptionPane
   747      */
   839      */
   748     protected Object[] getButtons() {
   840     protected Object[] getButtons() {
   749         if (optionPane != null) {
   841         if (optionPane != null) {
   750             Object[] suppliedOptions = optionPane.getOptions();
   842             Object[] suppliedOptions = optionPane.getOptions();
   751 
   843 
   825         catch (NumberFormatException nfe) { }
   917         catch (NumberFormatException nfe) { }
   826         return 0;
   918         return 0;
   827     }
   919     }
   828 
   920 
   829     /**
   921     /**
   830      * Returns true, basic L&amp;F wants all the buttons to have the same
   922      * Returns {@code true}, basic L&amp;F wants all the buttons to have the same
   831      * width.
   923      * width.
       
   924      *
       
   925      * @return {@code true} if all the buttons should have the same width
   832      */
   926      */
   833     protected boolean getSizeButtonsToSameWidth() {
   927     protected boolean getSizeButtonsToSameWidth() {
   834         return true;
   928         return true;
   835     }
   929     }
   836 
   930 
   837     /**
   931     /**
   838      * Returns the initial index into the buttons to select. The index
   932      * Returns the initial index into the buttons to select. The index
   839      * is calculated from the initial value from the JOptionPane and
   933      * is calculated from the initial value from the JOptionPane and
   840      * options of the JOptionPane or 0.
   934      * options of the JOptionPane or 0.
       
   935      *
       
   936      * @return the initial index into the buttons to select
   841      */
   937      */
   842     protected int getInitialValueIndex() {
   938     protected int getInitialValueIndex() {
   843         if (optionPane != null) {
   939         if (optionPane != null) {
   844             Object             iv = optionPane.getInitialValue();
   940             Object             iv = optionPane.getInitialValue();
   845             Object[]           options = optionPane.getOptions();
   941             Object[]           options = optionPane.getOptions();
   913      *
  1009      *
   914      * This class should be treated as a &quot;protected&quot; inner class.
  1010      * This class should be treated as a &quot;protected&quot; inner class.
   915      * Instantiate it only within subclasses of {@code BasicOptionPaneUI}.
  1011      * Instantiate it only within subclasses of {@code BasicOptionPaneUI}.
   916      */
  1012      */
   917     public static class ButtonAreaLayout implements LayoutManager {
  1013     public static class ButtonAreaLayout implements LayoutManager {
       
  1014         /**
       
  1015          * The value represents if the width of children should be synchronized.
       
  1016          */
   918         protected boolean           syncAllWidths;
  1017         protected boolean           syncAllWidths;
       
  1018         /**
       
  1019          * The padding value.
       
  1020          */
   919         protected int               padding;
  1021         protected int               padding;
   920         /** If true, children are lumped together in parent. */
  1022         /** If true, children are lumped together in parent. */
   921         protected boolean           centersChildren;
  1023         protected boolean           centersChildren;
   922         private int orientation;
  1024         private int orientation;
   923         private boolean reverseButtons;
  1025         private boolean reverseButtons;
   926          * the orientation. This is done for backward compatibility
  1028          * the orientation. This is done for backward compatibility
   927          * for subclassers.
  1029          * for subclassers.
   928          */
  1030          */
   929         private boolean useOrientation;
  1031         private boolean useOrientation;
   930 
  1032 
       
  1033         /**
       
  1034          * Constructs a new instance of {@code ButtonAreaLayout}.
       
  1035          *
       
  1036          * @param syncAllWidths if the width of children should be synchronized
       
  1037          * @param padding the padding value
       
  1038          */
   931         public ButtonAreaLayout(boolean syncAllWidths, int padding) {
  1039         public ButtonAreaLayout(boolean syncAllWidths, int padding) {
   932             this.syncAllWidths = syncAllWidths;
  1040             this.syncAllWidths = syncAllWidths;
   933             this.padding = padding;
  1041             this.padding = padding;
   934             centersChildren = true;
  1042             centersChildren = true;
   935             useOrientation = false;
  1043             useOrientation = false;
   941             useOrientation = true;
  1049             useOrientation = true;
   942             this.orientation = orientation;
  1050             this.orientation = orientation;
   943             this.reverseButtons = reverseButtons;
  1051             this.reverseButtons = reverseButtons;
   944         }
  1052         }
   945 
  1053 
       
  1054         /**
       
  1055          * Sets if the width of children should be synchronized.
       
  1056          *
       
  1057          * @param newValue if the width of children should be synchronized
       
  1058          */
   946         public void setSyncAllWidths(boolean newValue) {
  1059         public void setSyncAllWidths(boolean newValue) {
   947             syncAllWidths = newValue;
  1060             syncAllWidths = newValue;
   948         }
  1061         }
   949 
  1062 
       
  1063         /**
       
  1064          * Returns if the width of children should be synchronized.
       
  1065          *
       
  1066          * @return if the width of children should be synchronized
       
  1067          */
   950         public boolean getSyncAllWidths() {
  1068         public boolean getSyncAllWidths() {
   951             return syncAllWidths;
  1069             return syncAllWidths;
   952         }
  1070         }
   953 
  1071 
       
  1072         /**
       
  1073          * Sets the padding value.
       
  1074          *
       
  1075          * @param newPadding the new padding
       
  1076          */
   954         public void setPadding(int newPadding) {
  1077         public void setPadding(int newPadding) {
   955             this.padding = newPadding;
  1078             this.padding = newPadding;
   956         }
  1079         }
   957 
  1080 
       
  1081         /**
       
  1082          * Returns the padding.
       
  1083          *
       
  1084          * @return the padding
       
  1085          */
   958         public int getPadding() {
  1086         public int getPadding() {
   959             return padding;
  1087             return padding;
   960         }
  1088         }
   961 
  1089 
       
  1090         /**
       
  1091          * Sets whether or not center children should be used.
       
  1092          *
       
  1093          * @param newValue a new value
       
  1094          */
   962         public void setCentersChildren(boolean newValue) {
  1095         public void setCentersChildren(boolean newValue) {
   963             centersChildren = newValue;
  1096             centersChildren = newValue;
   964             useOrientation = false;
  1097             useOrientation = false;
   965         }
  1098         }
   966 
  1099 
       
  1100         /**
       
  1101          * Returns whether or not center children should be used.
       
  1102          *
       
  1103          * @return whether or not center children should be used
       
  1104          */
   967         public boolean getCentersChildren() {
  1105         public boolean getCentersChildren() {
   968             return centersChildren;
  1106             return centersChildren;
   969         }
  1107         }
   970 
  1108 
   971         private int getOrientation(Container container) {
  1109         private int getOrientation(Container container) {
  1161     /**
  1299     /**
  1162      * This class should be treated as a &quot;protected&quot; inner class.
  1300      * This class should be treated as a &quot;protected&quot; inner class.
  1163      * Instantiate it only within subclasses of {@code BasicOptionPaneUI}.
  1301      * Instantiate it only within subclasses of {@code BasicOptionPaneUI}.
  1164      */
  1302      */
  1165     public class ButtonActionListener implements ActionListener {
  1303     public class ButtonActionListener implements ActionListener {
       
  1304         /**
       
  1305          * The index of the button.
       
  1306          */
  1166         protected int buttonIndex;
  1307         protected int buttonIndex;
  1167 
  1308 
       
  1309         /**
       
  1310          * Constructs a new instance of {@code ButtonActionListener}.
       
  1311          *
       
  1312          * @param buttonIndex an index of the button
       
  1313          */
  1168         public ButtonActionListener(int buttonIndex) {
  1314         public ButtonActionListener(int buttonIndex) {
  1169             this.buttonIndex = buttonIndex;
  1315             this.buttonIndex = buttonIndex;
  1170         }
  1316         }
  1171 
  1317 
  1172         public void actionPerformed(ActionEvent e) {
  1318         public void actionPerformed(ActionEvent e) {