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

Incorrect size of Approve button in custom JFileChooser

XMLWordPrintable

    • b11
    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM:
      When JFileChooser is added to a JFrame, the open button is not shown properly. The button size is smaller compared to its actual size. The issue is observed in Metal, Nimbus and Motif look and feel and when custom Dialogue type is set without setting Approve Button Text.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM:
      Compile and run the code below under Metal Look and Feel (Default Look and feel in windows and Linux is Metal, whereas in MacOS the look and feel has to be set).

      EXPECTED VERSUS ACTUAL BEHAVIOR:
      EXPECTED -
      The Open button to be seen properly as Cancel button, without reducing its size.
      ACTUAL -
      The Open button size is smaller compared to its actual size.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import javax.swing.*;
      public class FileChooserTest {
          public static void main(String[] args) throws UnsupportedLookAndFeelException, ClassNotFoundException, InstantiationException, IllegalAccessException {
              UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
              JFileChooser fc = new JFileChooser();
              JFrame frame = new JFrame();
              frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
              fc.setDialogType(JFileChooser.CUSTOM_DIALOG);
              frame.add(fc, BorderLayout.CENTER);
              frame.pack();
              frame.setVisible(true);
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always

            tr Tejesh R
            tr Tejesh R
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: