public TestList() { setLayout(new BorderLayout()); final JList list = new JList(C2dTests.getNames()); final JButton button = new JButton("Run Test"); JScrollPane pane = new JScrollPane(list); DefaultListSelectionModel m = new DefaultListSelectionModel(); m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); m.setLeadAnchorNotificationEnabled(false); list.setSelectionModel(m); list.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent event) { if (event.getClickCount() == 2) button.doClick(); } }); final Preferences prefs = new LwjglPreferences( new FileHandle(new LwjglFiles().getExternalStoragePath() + ".prefs/c2d-tests")); list.setSelectedValue(prefs.getString("last", null), true); button.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String testName = (String) list.getSelectedValue(); Engine test = C2dTests.newTest(testName); LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.fullscreen = false; config.width = (int) Engine.getWidth(); config.height = (int) Engine.getHeight(); config.title = testName; config.vSyncEnabled = true; prefs.putString("last", testName); prefs.flush(); new LwjglApplication(test, config); } }); add(pane, BorderLayout.CENTER); add(button, BorderLayout.SOUTH); }