<commit_before>// -*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
// @homepage@

package example;

import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Objects;
import java.util.Optional;
import javax.swing.*;
import javax.swing.plaf.synth.Region;
import javax.swing.plaf.synth.SynthConstants;
import javax.swing.plaf.synth.SynthContext;
import javax.swing.plaf.synth.SynthLookAndFeel;
import javax.swing.plaf.synth.SynthStyle;

public final class MainPanel extends JPanel {
  private MainPanel() {
    super(new BorderLayout());
    // http://www.famfamfam.com/lab/icons/mini/
    Icon icon = new ImageIcon(Objects.requireNonNull(getClass().getResource("page_new.gif")));
    JButton button = new JButton(icon) {
      private transient MouseListener handler;
      @Override public void updateUI() {
        removeMouseListener(handler);
        super.updateUI();
        setFocusable(false);
        setContentAreaFilled(false);
        setFocusPainted(false);
        setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
        // setAlignmentX(Component.LEFT_ALIGNMENT);
        // setAlignmentY(Component.TOP_ALIGNMENT); // ???
        handler = new MouseAdapter() {
          @Override public void mouseEntered(MouseEvent e) {
            setContentAreaFilled(true);
          }

          @Override public void mouseExited(MouseEvent e) {
            setContentAreaFilled(false);<commit_msg>refactor: use Optional#orElseGet(...) instead of Objects.requireNonNull(...)<commit_after>// -*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
// @homepage@

package example;

import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.IOException;
import java.io.InputStream;
import java.util.Objects;
import java.util.Optional;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.plaf.synth.Region;
import javax.swing.plaf.synth.SynthConstants;
import javax.swing.plaf.synth.SynthContext;
import javax.swing.plaf.synth.SynthLookAndFeel;
import javax.swing.plaf.synth.SynthStyle;

public final class MainPanel extends JPanel {
  private MainPanel() {
    super(new BorderLayout());
    String path = "example/page_new.gif"; // http://www.famfamfam.com/lab/icons/mini/
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    Icon icon = Optional.ofNullable(cl.getResource(path)).map(url -> {
      try (InputStream s = url.openStream()) {
        return new ImageIcon(ImageIO.read(s));
      } catch (IOException ex) {
        return UIManager.getIcon("html.missingImage");
      }
    }).orElseGet(() -> UIManager.getIcon("html.missingImage"));

    JButton button = new JButton(icon) {
      private transient MouseListener handler;
      @Override public void updateUI() {
        removeMouseListener(handler);
        super.updateUI();
        setFocusable(false);
        setContentAreaFilled(false);
        setFocusPainted(false);
        setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
        // setAlignmentX(Component.LEFT_ALIGNMENT);
        // setAlignmentY(Component.TOP_ALIGNMENT); // ???
        handler = new MouseAdapter() {
          @Override public void mouseEntered(MouseEvent e) {
            setContentAreaFilled(true);
          }

          @Override public void mouseExited(MouseEvent e) {
            setContentAreaFilled(false);
{'fraction_non_alphanumeric': 0.12489307100085544, 'fraction_numerical': 0.003421727972626176, 'mean_word_length': 3.4859335038363173, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4818386', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1045, 'n_words': 199}