package com.dbvis.flatlaftest;

import com.formdev.flatlaf.FlatLightLaf;
import com.formdev.flatlaf.util.SystemFileChooser;
import javax.swing.*;

public class App {
    public static void main(String[] args) {
	try {
            UIManager.setLookAndFeel(new FlatLightLaf());
        } catch (UnsupportedLookAndFeelException ex) {
            System.err.println("Failed to initialize LaF");
        }
        SwingUtilities.invokeLater(() -> showUI());
    }

    private static void showUI() {
	JFrame frame = new JFrame("FlatLaf Demo");
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	JPanel p = new JPanel();
	JButton button = new JButton("Oook!");
	button.addActionListener(e -> choose(frame));
	p.add(button);
	frame.add(p);
	frame.setSize(300, 200);
	frame.setLocationRelativeTo(null);
	frame.setVisible(true);
    }

    private static void choose(JFrame parent) {
	System.out.println("About to open the chooser");
	SystemFileChooser fileChooser = new SystemFileChooser();
	if (fileChooser.showOpenDialog(parent) == SystemFileChooser.APPROVE_OPTION) {
	    System.out.println("Got file: ;********: " + fileChooser.getSelectedFile());
	}
    }
}
