<commit_before>package example;
//-*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
//@homepage@
import java.awt.*;
import java.awt.event.*;
import java.lang.reflect.InvocationTargetException;
import javax.swing.*;

public class MainPanel {
    public void start(JFrame frame) {
        ImageIcon img = new ImageIcon(MainPanel.class.getResource("splash.png"));
        JWindow splashScreen = createSplashScreen(frame, img);
        splashScreen.setVisible(true);

        (new Thread() {
            @Override public void run() {
                try {
                    //dummy long task
                    Thread.sleep(6000);
                    EventQueue.invokeAndWait(new Runnable() {
                        @Override public void run() {
                            showFrame(frame);
                            //hideSplash();
                            splashScreen.setVisible(false);
                            splashScreen.dispose();
                        }
                    });
                } catch (InterruptedException | InvocationTargetException ex) {
                    ex.printStackTrace();
                }
            }
        }).start();
    }
    private static JPanel makeUI(JFrame frame) {
        JLabel label = new JLabel("Draggable Label (@title@)");
        DragWindowListener dwl = new DragWindowListener();
        label.addMouseListener(dwl);
        label.addMouseMotionListener(dwl);
        label.setOpaque(true);
        label.setForeground(Color.WHITE);
        label.setBackground(Color.BLUE);
        label.setBorder(BorderFactory.createEmptyBorder(5, 16 + 5, 5, 2));
        Box box = Box.createHorizontalBox();
        box.add(Box.createHorizontalGlue());
        box.add(new JButton(new AbstractAction("Exit") {
            @Override public void actionPerformed(ActionEvent e) {
                //frame.dispose();
                //System.exit(0);
                //frame.getToolkit().getSystemEventQueue().postEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
                frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
            }
        }));
        JPanel p = new JPanel(new BorderLayout());
        p.add(label, BorderLayout.NORTH);
        p.add(box, BorderLayout.SOUTH);
        p.add(new JLabel("Alt+Space => System Menu"));
        return p;
    }
    public static JWindow createSplashScreen(JFrame frame, ImageIcon img) {
        DragWindowListener dwl = new DragWindowListener();

        JLabel label = new JLabel(img);
        label.addMouseListener(dwl);
        label.addMouseMotionListener(dwl);

        JWindow window = new JWindow(frame);
        window.getContentPane().add(label);
        window.pack();
        window.setLocationRelativeTo(null);
        return window;
    }
    protected void showFrame(JFrame frame) {
        frame.getContentPane().add(makeUI(frame));
        frame.setMinimumSize(new Dimension(100, 100));
        frame.setSize(320, 240);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

//     protected JMenuBar createMenuBar() {
//         JMenuBar menuBar = new JMenuBar();
//         JMenu menu = new JMenu("FFFFFF");<commit_msg>refactor: use a lambda expression instead of an anonymous class(ActionListener)<commit_after>package example;
//-*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
//@homepage@
import java.awt.*;
import java.awt.event.*;
import java.lang.reflect.InvocationTargetException;
import javax.swing.*;

public class MainPanel {
    public void start(JFrame frame) {
        ImageIcon img = new ImageIcon(MainPanel.class.getResource("splash.png"));
        JWindow splashScreen = createSplashScreen(frame, img);
        splashScreen.setVisible(true);

        (new Thread() {
            @Override public void run() {
                try {
                    //dummy long task
                    Thread.sleep(6000);
                    EventQueue.invokeAndWait(new Runnable() {
                        @Override public void run() {
                            showFrame(frame);
                            //hideSplash();
                            splashScreen.setVisible(false);
                            splashScreen.dispose();
                        }
                    });
                } catch (InterruptedException | InvocationTargetException ex) {
                    ex.printStackTrace();
                }
            }
        }).start();
    }
    private static JPanel makeUI(JFrame frame) {
        JLabel label = new JLabel("Draggable Label (@title@)");
        DragWindowListener dwl = new DragWindowListener();
        label.addMouseListener(dwl);
        label.addMouseMotionListener(dwl);
        label.setOpaque(true);
        label.setForeground(Color.WHITE);
        label.setBackground(Color.BLUE);
        label.setBorder(BorderFactory.createEmptyBorder(5, 16 + 5, 5, 2));

        JButton button = new JButton("Exit");
        button.addActionListener(e -> {
            //frame.dispose();
            //System.exit(0);
            //frame.getToolkit().getSystemEventQueue().postEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
            frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
        });

        Box box = Box.createHorizontalBox();
        box.add(Box.createHorizontalGlue());
        box.add(button);

        JPanel p = new JPanel(new BorderLayout());
        p.add(label, BorderLayout.NORTH);
        p.add(box, BorderLayout.SOUTH);
        p.add(new JLabel("Alt+Space => System Menu"));
        return p;
    }
    public static JWindow createSplashScreen(JFrame frame, ImageIcon img) {
        DragWindowListener dwl = new DragWindowListener();

        JLabel label = new JLabel(img);
        label.addMouseListener(dwl);
        label.addMouseMotionListener(dwl);

        JWindow window = new JWindow(frame);
        window.getContentPane().add(label);
        window.pack();
        window.setLocationRelativeTo(null);
        return window;
    }
    protected void showFrame(JFrame frame) {
        frame.getContentPane().add(makeUI(frame));
        frame.setMinimumSize(new Dimension(100, 100));
        frame.setSize(320, 240);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

//     protected JMenuBar createMenuBar() {
//         JMenuBar menuBar = new JMenuBar();
//         JMenu menu = new JMenu("FFFFFF");
{'fraction_non_alphanumeric': 0.11442709138704191, 'fraction_numerical': 0.007731560228854183, 'mean_word_length': 2.061050638902035, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3094514', 'n_tokens_mistral': 1797, 'n_tokens_neox': 1711, 'n_words': 340}