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

public final class MainPanel extends JPanel {
    public MainPanel() {
        super((LayoutManager) null);
        add(makeLabelIcon());
        setPreferredSize(new Dimension(320, 240));
    }
    private JLabel makeLabelIcon() {
        ImageIcon i = new ImageIcon(getClass().getResource("duke.gif"));
        Dimension d = new Dimension(i.getIconWidth(), i.getIconHeight());
        final BufferedImage image = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_ARGB);
        Graphics g = image.createGraphics();
        i.paintIcon(null, g, 0, 0);
        g.dispose();
        final JLabel icon = new JLabel(i) {
            @Override public boolean contains(int x, int y) {
                return super.contains(x, y) && ((image.getRGB(x, y) >> 24) & 0xFF) != 0;
            }
        };
        icon.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
        MouseAdapter l = new MouseAdapter() {
            private final transient Point start = new Point();
            private Point loc;
            @Override public void mousePressed(MouseEvent e) {
                start.setLocation(e.getPoint());
            }
            @Override public void mouseDragged(MouseEvent e) {
                loc = icon.getLocation(loc);
                int x = loc.x - start.x + e.getX();
                int y = loc.y - start.y + e.getY();
                icon.setLocation(x, y);
            }
        };
        icon.addMouseListener(l);
        icon.addMouseMotionListener(l);
        icon.setBounds(new Rectangle(22, 22, d.width, d.height));
        return icon;
    }
    public static void main(String... args) {
        EventQueue.invokeLater(new Runnable() {
            @Override public void run() {
                createAndShowGUI();
            }
        });
    }
    public static void createAndShowGUI() {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | InstantiationException
               | IllegalAccessException | UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        }
        JFrame frame = new JFrame("@title@");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.getContentPane().add(new MainPanel());
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}<commit_msg>refactor: use ImageIO.read(...) to get BufferedImage<commit_after>package example;
//-*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
//@homepage@
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.*;

public final class MainPanel extends JPanel {
    public MainPanel() {
        super(new BorderLayout());

        BufferedImage image;
        try {
            image = ImageIO.read(getClass().getResource("duke.gif"));
        } catch (IOException ex) {
            ex.printStackTrace();
            return;
        }
        JLabel icon = makeLabelIcon(image);
        icon.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
        icon.setSize(icon.getPreferredSize());
        icon.setLocation(20, 20);

        JDesktopPane desktop = new JDesktopPane();
        desktop.setOpaque(false);
        desktop.add(icon);
        add(desktop);
        setPreferredSize(new Dimension(320, 240));
    }
    private JLabel makeLabelIcon(BufferedImage image) {
        MouseAdapter handler = new ComponentMoveHandler();
        return new JLabel(new ImageIcon(image)) {
            @Override public boolean contains(int x, int y) {
                return super.contains(x, y) && ((image.getRGB(x, y) >> 24) & 0xFF) != 0;
            }
            @Override public void updateUI() {
                removeMouseListener(handler);
                removeMouseMotionListener(handler);
                super.updateUI();
                //handler = new ComponentMoveHandler();
                addMouseListener(handler);
                addMouseMotionListener(handler);
            }
        };
    }
    public static void main(String... args) {
        EventQueue.invokeLater(new Runnable() {
            @Override public void run() {
                createAndShowGUI();
            }
        });
    }
    public static void createAndShowGUI() {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | InstantiationException
               | IllegalAccessException | UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        }
        JFrame frame = new JFrame("@title@");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.getContentPane().add(new MainPanel());
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}

class ComponentMoveHandler extends MouseAdapter {
    private final Point startPt = new Point();
    @Override public void mousePressed(MouseEvent e) {
        startPt.setLocation(e.getPoint());
    }
    @Override public void mouseDragged(MouseEvent e) {
        Component c = e.getComponent();
        c.setLocation(c.getX() - startPt.x + e.getX(), c.getY() - startPt.y + e.getY());
    }
}
{'fraction_non_alphanumeric': 0.11836142831248866, 'fraction_numerical': 0.0061627696211709266, 'mean_word_length': 2.2670219064535226, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4260274', 'n_tokens_mistral': 1562, 'n_tokens_neox': 1516, 'n_words': 325}