test/javax/swing/JFileChooser/8046391/bug8046391.java

Print this page




  30 */
  31 
  32 import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
  33 import sun.awt.OSInfo;
  34 import sun.awt.OSInfo.OSType;
  35 
  36 import javax.swing.JFileChooser;
  37 import javax.swing.SwingUtilities;
  38 import javax.swing.UIManager;
  39 import javax.swing.UnsupportedLookAndFeelException;
  40 
  41 public class bug8046391  {
  42 
  43     public static void main(String[] args) throws Exception {
  44         OSType type = OSInfo.getOSType();
  45         if (type != OSType.WINDOWS) {
  46             System.out.println("This test is for Windows only... skipping!");
  47             return;
  48         }
  49 
  50         SwingUtilities.invokeAndWait(() -> {


  51             try {
  52                 UIManager.setLookAndFeel(new WindowsLookAndFeel());
  53             } catch (UnsupportedLookAndFeelException e) {
  54                 e.printStackTrace();
  55             }
  56             System.out.println("Creating JFileChooser...");
  57             JFileChooser fileChooser = new JFileChooser();
  58             System.out.println("Test passed: chooser = " + fileChooser);

  59         });
  60         // Test fails if creating JFileChooser hangs
  61     }
  62 
  63 }


  30 */
  31 
  32 import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
  33 import sun.awt.OSInfo;
  34 import sun.awt.OSInfo.OSType;
  35 
  36 import javax.swing.JFileChooser;
  37 import javax.swing.SwingUtilities;
  38 import javax.swing.UIManager;
  39 import javax.swing.UnsupportedLookAndFeelException;
  40 
  41 public class bug8046391  {
  42 
  43     public static void main(String[] args) throws Exception {
  44         OSType type = OSInfo.getOSType();
  45         if (type != OSType.WINDOWS) {
  46             System.out.println("This test is for Windows only... skipping!");
  47             return;
  48         }
  49 
  50         SwingUtilities.invokeAndWait(new Runnable() {
  51             @Override
  52             public void run() {
  53                 try {
  54                     UIManager.setLookAndFeel(new WindowsLookAndFeel());
  55                 } catch (UnsupportedLookAndFeelException e) {
  56                     e.printStackTrace();
  57                 }
  58                 System.out.println("Creating JFileChooser...");
  59                 JFileChooser fileChooser = new JFileChooser();
  60                 System.out.println("Test passed: chooser = " + fileChooser);
  61             }
  62         });
  63         // Test fails if creating JFileChooser hangs
  64     }
  65 
  66 }