Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6176477

Specifying "initialValue" in a JOptionPane constructor works on metal PLAF only.

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.5.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
      Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      WIN XP Home SP1

      A DESCRIPTION OF THE PROBLEM :
      See synopsis

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Behavior should be the same, regardless of PLAF.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import javax.swing.*;

      public class JOptionPaneTest
      {
        public static void main(String[] args)
        {
          String plaf="";
          if (args.length!=1)
          { System.out.println("Usage: JOptionPaneTest n [n= 0-2 (PLAF)]");
            System.exit(0);
          }
          else if (args[0].equals("0"))
          { plaf = "javax.swing.plaf.metal.MetalLookAndFeel";
          }
          else if (args[0].equals("1"))
          { plaf = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
          }
          else if (args[0].equals("2"))
          { plaf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
          }
          else
            System.exit(0);
          try
          { UIManager.setLookAndFeel(plaf);
          }
          catch (Exception e)
          { System.err.println(e.toString());
          }

          String message = "Are you sure you want to format your hard drive?";
          JOptionPane optionPane = new JOptionPane(message,
      JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null,
      new String[] { "Yes", "No" }, "No");
          JDialog dlg = optionPane.createDialog(null, "Confirm");
          dlg.setVisible(true);
          Object selectedValue = optionPane.getValue();
          System.out.println(selectedValue);
          System.exit(0);
        }
      }

      ---------- END SOURCE ----------
      ###@###.### 10/8/04 21:38 GMT

            Unassigned Unassigned
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: