Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.File;

import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.filechooser.FileFilter;

public class Main {
    public static void main(String[] args) throws Exception {
        String[] properties = { "os.name", "java.version", "java.vm.version", "java.vendor" };
        for (String property : properties) {
            System.out.println(property + ": " + System.getProperty(property));
        }
        JFileChooser jfc = new JFileChooser();
        jfc.showOpenDialog(null);
        jfc.addChoosableFileFilter(new FileFilter() {
            @Override
            public boolean accept(File f) {
                return f.isDirectory() || f.getName().toLowerCase().endsWith(".obj");
            }

            @Override
            public String getDescription() {
                return "Wavefront OBJ (*.obj)";
            }

            @Override
            public String toString() {
                return getDescription();
            }
        });
        int result = JOptionPane.showConfirmDialog(null, "Description was 'All Files'?");
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        SwingUtilities.updateComponentTreeUI(jfc);
        jfc.showOpenDialog(null);
        result = JOptionPane.showConfirmDialog(null, "Description was 'All Files'?");

        result = JOptionPane.showConfirmDialog(null, "Description was 'All Files'?");
        for (UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                SwingUtilities.updateComponentTreeUI(jfc);
                break;
            }
        }
        jfc.showOpenDialog(null);
        result = JOptionPane.showConfirmDialog(null, "Description was 'All Files'?");
    }
}