modsListPanel.setLayout(new BorderLayout(0, 0));
actionPanel = new JPanel();
panel.add(actionPanel, BorderLayout.SOUTH);
final ModsManager mods = parent.getApi().getLauncher().getMods();
model = new DefaultListModel<ModsManager.Mod>();
for (ModsManager.Mod mod : mods.getMods())
{
model.addElement(mod);
}
modsList = new JList<ModsManager.Mod>(model);
modsList.setAutoscrolls(true);
modsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane scrollPane = new JScrollPane(modsList);
modsListPanel.add(scrollPane, BorderLayout.CENTER);
JPanel actionsPanel = new JPanel();
modsPanel.add(actionsPanel);
actionsPanel.setLayout(new GridLayout(0, 1, 5, 5));
JButton addModButton = new JButton("Add mod");
addModButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
actionPanel.removeAll();
fillAddMod(actionPanel);
validate();
}
});
actionsPanel.add(addModButton);
JButton editModButton = new JButton("Edit mod");
editModButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
actionPanel.removeAll();
fillEditMod(actionPanel);
validate();
}
});
actionsPanel.add(editModButton);
JButton removeModButton = new JButton("Remove mod");
removeModButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
actionPanel.removeAll();
if (modsList.getSelectedValue() != null)
{
ModsManager.Mod selected = modsList.getSelectedValue();
model.removeElement(selected);
mods.getMods().remove(selected);
}
validate();
}
});