import gameEngine.ColorController; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Objects; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class Swing { public Swing() { } public static void swing() { JFrame frame = new JFrame("Swing Example"); frame.setDefaultCloseOperation(3); frame.setSize(300, 200); JPanel panel = new JPanel(); panel.setLayout(new GridLayout(4, 2)); JLabel keyInputLabel = new JLabel("KeyInput:"); String[] keyInputOptions = new String[]{"KeyPress", "KeyDown", "KeyUp"}; final JComboBox<String> keyInputDropdown = new JComboBox(keyInputOptions); JLabel keyCodeLabel = new JLabel("KeyCode:"); String[] keyCodeOptions = new String[]{"A", "S", "D"}; final JComboBox<String> keyCodeDropdown = new JComboBox(keyCodeOptions); JLabel colorLabel = new JLabel("Color:"); String[] colorOptions = new String[]{"Red", "Blue", "Green", "Yellow"}; final JComboBox<String> colorDropdown = new JComboBox(colorOptions); JButton updateButton = new JButton("Update"); updateButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String selectedKeyInput = (String)keyInputDropdown.getSelectedItem(); String selectedKeyCode = (String)keyCodeDropdown.getSelectedItem(); String selectedColor = (String)colorDropdown.getSelectedItem(); if (Objects.equals(selectedKeyCode, "A")) { ColorController.setCustomKeyCode(65); } if (Objects.equals(selectedKeyCode, "S")) { ColorController.setCustomKeyCode(83); } if (Objects.equals(selectedKeyCode, "D")) { ColorController.setCustomKeyCode(68); } } }); panel.add(keyInputLabel); panel.add(keyInputDropdown); panel.add(keyCodeLabel); panel.add(keyCodeDropdown); panel.add(colorLabel); panel.add(colorDropdown); panel.add(new JLabel()); panel.add(updateButton); frame.add(panel); frame.setVisible(true); } }