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

package example;

import java.awt.*;
import java.awt.event.MouseEvent;
import javax.swing.*;
import javax.swing.plaf.LayerUI;

public final class MainPanel extends JPanel {
  private MainPanel() {
    super(new BorderLayout());
    String[] model = {"aaa", "bb", "c"};
    JComboBox<String> combo = makeComboBox(model);
    combo.setEditable(true);

    JPanel p = new JPanel(new GridLayout(0, 1, 5, 5));
    setBorder(BorderFactory.createEmptyBorder(5, 20, 5, 20));
    p.add(new JLabel("setEditable(true)"));
    p.add(new JLayer<>(combo, new ToolTipLayerUI<>()));
    p.add(Box.createVerticalStrut(10));
    p.add(new JLabel("setEditable(false)"));
    p.add(new JLayer<>(makeComboBox(model), new ToolTipLayerUI<>()));
    add(p, BorderLayout.NORTH);
    setPreferredSize(new Dimension(320, 240));
  }

  private static <E> JComboBox<E> makeComboBox(E[] model) {
    return new JComboBox<E>(model) {
      @Override public void updateUI() {
        setRenderer(null);
        super.updateUI();
        ListCellRenderer<? super E> renderer = getRenderer();
        setRenderer((list, value, index, isSelected, cellHasFocus) -> {
          Component c = renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
          if (c instanceof JComponent) {
            ((JComponent) c).setToolTipText(String.format("Item%d: %s", index, value));
          }
          return c;
        });
      }<commit_msg>PMD: UseVarargs<commit_after>// -*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
// @homepage@

package example;

import java.awt.*;
import java.awt.event.MouseEvent;
import javax.swing.*;
import javax.swing.plaf.LayerUI;

public final class MainPanel extends JPanel {
  private MainPanel() {
    super(new BorderLayout());
    ComboBoxModel<String> model = new DefaultComboBoxModel<>(new String[] {"aaa", "bb", "c"});
    JComboBox<String> combo = makeComboBox(model);
    combo.setEditable(true);

    JPanel p = new JPanel(new GridLayout(0, 1, 5, 5));
    setBorder(BorderFactory.createEmptyBorder(5, 20, 5, 20));
    p.add(new JLabel("setEditable(true)"));
    p.add(new JLayer<>(combo, new ToolTipLayerUI<>()));
    p.add(Box.createVerticalStrut(10));
    p.add(new JLabel("setEditable(false)"));
    p.add(new JLayer<>(makeComboBox(model), new ToolTipLayerUI<>()));
    add(p, BorderLayout.NORTH);
    setPreferredSize(new Dimension(320, 240));
  }

  private static <E> JComboBox<E> makeComboBox(ComboBoxModel<E> model) {
    return new JComboBox<E>(model) {
      @Override public void updateUI() {
        setRenderer(null);
        super.updateUI();
        ListCellRenderer<? super E> renderer = getRenderer();
        setRenderer((list, value, index, isSelected, cellHasFocus) -> {
          Component c = renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
          if (c instanceof JComponent) {
            ((JComponent) c).setToolTipText(String.format("Item%d: %s", index, value));
          }
          return c;
        });
      }
{'fraction_non_alphanumeric': 0.15436241610738255, 'fraction_numerical': 0.01278363694471077, 'mean_word_length': 3.637037037037037, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 26, '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': '364713', 'n_tokens_mistral': 1038, 'n_tokens_neox': 996, 'n_words': 220}