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

public final class MainPanel extends JPanel {
    private final JComboBox<String> combo01 = new JComboBox<>(makeModel());
    private final JComboBox<String> combo02 = new JComboBox<>(makeModel());

    public MainPanel() {
        super(new BorderLayout());

        Action up = new AbstractAction() {
            @Override public void actionPerformed(ActionEvent e) {
                int index = combo02.getSelectedIndex();
                combo02.setSelectedIndex(index == 0 ? combo02.getItemCount() - 1 : index - 1);
            }
        };
        Action down = new AbstractAction() {
            @Override public void actionPerformed(ActionEvent e) {
                int index = combo02.getSelectedIndex();
                combo02.setSelectedIndex(index == combo02.getItemCount() - 1 ? 0 : index + 1);
            }
        };
        ActionMap amc = combo02.getActionMap();
        amc.put("myUp",   up);
        amc.put("myDown", down);

        InputMap imc = combo02.getInputMap();
        imc.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0),   "myUp");
        imc.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "myDown");

        Box box = Box.createVerticalBox();
        box.add(createPanel(combo01, "default:"));
        box.add(Box.createVerticalStrut(5));
        box.add(createPanel(combo02, "loop:"));
        box.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        add(box, BorderLayout.NORTH);
        setPreferredSize(new Dimension(320, 240));
    }
    private static JComponent createPanel(JComponent cmp, String str) {
        JPanel panel = new JPanel(new BorderLayout());
        panel.setBorder(BorderFactory.createTitledBorder(str));
        panel.add(cmp);
        return panel;
    }
    private static ComboBoxModel<String> makeModel() {
        DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>();
        model.addElement("aaaa");
        model.addElement("aaaabbb");
        model.addElement("aaaabbbcc");
        model.addElement("1354123451234513512");
        model.addElement("bbb1");
        model.addElement("bbb12");
        return model;
    }
    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);
    }
}

@@ -130,24 +130,59 @@
 wt.event.*;%0A
+import java.util.stream.IntStream;%0A
 import javax
@@ -578,35 +578,82 @@
         
-int index = combo02
+JComboBox c = (JComboBox) e.getSource();%0A                int i = c
 .getSele
@@ -674,38 +674,32 @@
                c
-ombo02
 .setSelectedInde
@@ -697,28 +697,24 @@
 ectedIndex(i
-ndex
  == 0 ? comb
@@ -710,22 +710,16 @@
 == 0 ? c
-ombo02
 .getItem
@@ -733,20 +733,16 @@
  - 1 : i
-ndex
  - 1);%0A 
@@ -897,27 +897,74 @@
     
-int index = combo02
+JComboBox c = (JComboBox) e.getSource();%0A                int i = c
 .get
@@ -997,22 +997,16 @@
        c
-ombo02
 .setSele
@@ -1020,23 +1020,13 @@
 ex(i
-ndex
  == c
-ombo02
 .get
@@ -1048,20 +1048,16 @@
  ? 0 : i
-ndex
  + 1);%0A 
@@ -1100,17 +1100,16 @@
 onMap am
-c
  = combo
@@ -1129,33 +1129,32 @@
 ap();%0A        am
-c
 .put(%22myUp%22,   u
@@ -1167,17 +1167,16 @@
       am
-c
 .put(%22my
@@ -1209,17 +1209,16 @@
 utMap im
-c
  = combo
@@ -1237,33 +1237,32 @@
 ap();%0A        im
-c
 .put(KeyStroke.g
@@ -1314,17 +1314,16 @@
       im
-c
 .put(Key
@@ -2111,225 +2111,74 @@
     
-model.addElement(%22aaaa%22);%0A        model.addElement(%22aaaabbb%22);%0A        model.addElement(%22aaaabbbcc%22);%0A        model.addElement(%221354123451234513512%22);%0A        model.addElement(%22bbb1%22);%0A        model.addElement(%22bbb12%22
+IntStream.range(0, 10).forEach(i -%3E model.addElement(%22item: %22 + i)
 );%0A 

use ActionEvent#getSource() to get the event source component